#help-development

1 messages ¡ Page 2044 of 1

wet breach
#

odd your keyboard doesn't haven't a tilde though

plain helm
#

European keyboards don't have it

#

or at least Italian ones don't

#

idk if they're different in other EU nations

wet breach
#

do you have an alt gr key?

plain helm
#

yes

wet breach
#

then you have easy access to the tilde and backtick keys 🙂

plain helm
#

alt gr gives me access to the €

#

and

wet breach
#

alt gr + 7

#

gives you back tick

plain helm
#

nope

#

doesn't do anything for me

wet breach
#

then do this

#

alt gr + 7 and then hit 0

vocal cloud
#

this is easier than alt 96

wet breach
#

about to tell you

#

on some layouts

#

alt codes you know about sometimes don't work

plain helm
#

guys i'll just get it from the file it's not a problem

#

ty anyways

vocal cloud
#

Add a Cortana voice command for it 🤡

wet breach
#

its alt gr + Ăš

#

I was looking at the wrong layout from MS

plain helm
#

doesn't work for me, idk what's wrong lmao

#

thanks for the help though

wet breach
#

well accordingly

#

for you its alt code 60

#

as well

#

weird your laptop keyboard isn't following the typical layout though

#

wonder if it requires the function key to be used too

plain helm
#

nope i tried it as well

wet breach
#

lol

quiet ice
#

Which Euro Keyboard are you using?

plain helm
plain helm
quiet ice
#

If you have the accent grave (If that is the accent I think it is) you need to Press it twice in Order to get two backticks

quiet ice
#

That File will Take forever to Download with 16 kbits/s

#

There is a reason I often shoot very much in the dark

#

And the download failed. I cease to understand how https is so unreliable

#

Like, FTP is so much faster and reliable (If you increase the timeout)

wet breach
#

lol

#

technically could increase the timeout for https

#

in firefox for example
network.http.keep-alive.timeout 115 is the default you could increase it

#

same with websockets

#

chrome probably has similar setting somewhere

#

but I don't know it since that isn't my go to browser

tender shard
#

am I the only one who ALWAYS has problems wit jitpack?

wet breach
#

I sometimes have issues with it

#

especially its caching thing

#

so I stopped using it

rough drift
tender shard
#

when you remove some unused imports and now you have to recommit 20% of the whole codebase lol

glossy venture
#

Class100.java

#

tf

tender shard
# glossy venture `Class100.java`
package de.jeff_media.angelchest;

/**
 * This is the 100th class added to the original AngelChest source code, NOT including all the shaded libraries etc
 *
 * It's useless and has been added on 30th June 2019 at 12:50 CEST
 *
 * The total number of files contained in AngelChest.jar at this time was 1923, of which 1633 were .class files.
 */
public class Class100 {
}
glossy venture
#

bruh

tender shard
#

I didn't like it having 99 classes

#

I wanted it to be 100

glossy venture
#

bruh

smoky oak
#

thanks imma do that

quasi flint
#

no u dont

smoky oak
#

open source lol

#

watch me

quasi flint
tender shard
granite owl
#

does this already exist in the standard libs?

#
public class Pair<A, B> 
{
    public A first;
    public B second;

    public Pair(A first, B second)
    {
        super();
        this.first = first;
        this.second = second;
    }
}
#

seems abit silly to declare a pair

#

also can the plugin somehow detect this line from its plugin.yml ```yml
api-version: 1.18

#

(to auto disable itself if versions dont match cause i use nms methods)

tender shard
#

but to detect the NMS version, you need a bit reflection

#

I always do sth like this:

        if(nms) {
            final String packageName = JeffLib.class.getPackage().getName();
            final String internalsName = Bukkit.getServer().getClass().getPackage().getName().split("\\.")[3];
            try {
                //abstractNmsHandler = (AbstractNMSHandler) Class.forName(packageName + ".internal.nms." + internalsName + ".NMSHandler").newInstance();
                abstractNmsHandler = (AbstractNMSHandler) Class.forName(packageName + ".internal.nms." + internalsName + ".NMSHandler").getDeclaredConstructor().newInstance();
            } catch (final ClassNotFoundException | InstantiationException | IllegalAccessException | ClassCastException | NoSuchMethodException | InvocationTargetException exception) {
                plugin.getLogger().warning("The included JeffLib version (" + version + ") does not fully support the Minecraft version you are currently running: " + internalsName);
                exception.printStackTrace();
            }
        }

now "internalsName" is e.g. "v1_18_R2"

granite owl
#

hehe teye

#

cause i wanna avoid nms as much as possible

#

but since i plan a plugin for custom entities that injects its entities into the server

#

version mismatch could crash things

tender shard
#

what MC version are you on?

#

because if it's 1.17+ you HAVE to use the remapped jar for custom entities, otherwise it won't compile. But you should be using remapped anyway 😛

granite owl
#

1.18

#

and yes

#

ive noticed that

#

using it

chrome beacon
#

Remapped makes things much easier

granite owl
#

how so

#

it just complicated it for me

#

to import it

#

because i didnt know of the change

#

otherwise it seems pmuch similar to me

chrome beacon
#

How is a(), b(), c() simillar to coolMethodName(). All you really need to do is copy paste remap config in to your pom and you're good to go

#

Takes less than 5min

granite owl
#

so it took the vanilla obfuscating out

tender shard
#

with remapped, you can basically code sth once for 1.17.1, then compile exactly the same code against 1.18.2 mappings and it'll still work in 99% of cases

granite owl
#

hm

smoky oak
#

what's the regex for 'all non numeral characters' ?

tender shard
#

\d

#

if you only mean [0-9] at least

#

do you also want to allow floats / doubles?

smoky oak
#

no

#

i want to extract the number from a string

#

wait

#

\d does numbers

#

not not numbers

tender shard
#

ooh

#

\D

smoky oak
#

huh

#

ok then

tender shard
quasi walrus
#

hello id like some help with getting 1.18.2 plugin development started [idk if im doing it right]

i downloaded the buildtools.jar that i made a bat

java -jar BuildTools.jar --rev 1.18.2 now im just waiting is this right?

quasi walrus
#

um idk what nms code means, im just familiar with how 1.16.5 does it all i really need is the jar that you add to dependences

tender shard
#

then you don't need to worry about NMS

#

but anyway, I highly suggest you to use maven. it might seem a bit complicated at first, but it actually makes everything much easier

#

my blog post explains everything you need to do to get a working maven setup

quasi walrus
#

oh

smoky oak
#

is this normal for /data get @p ?

tender shard
tender shard
smoky oak
#

ah makes sense

#

does that also contain the creative saved items?

tender shard
#

no, the creative inventory is 100% client sided

quasi walrus
#

um could i still get help with getting the jar file for dependences the build tools stopped running and the spigot-1.18.2.jar doesnt work

tender shard
smoky oak
#

huh

tender shard
#

but you can't really rely on it

smoky oak
#

pdc contains book pages

tender shard
#

yes sure

#

well, not really PDC. the book pages are inside an NBT tag

#

but PDC basically IS NBT

smoky oak
#

ah i see

tender shard
#

it's simply an interface to access it using spigot API instead of NMS

smoky oak
#

imma assume getinventory interfaces with PDC then

tender shard
#

wdym?

smoky oak
#

well if the inventory is stored in the PDC

tender shard
#

no, it's not

#

PDC is stored inside an NBT tag called "BukkitValues"

smoky oak
#

ah note taken

tender shard
#

check out the 6lth line from the bottom

#

everything inside BukkitValues is the data you get from player.getPersistentDataContainer()

quasi walrus
#

is there no way to make 1.18.2 plugins without maven?

smoky oak
#

gradle

quasi walrus
#

um

quasi flint
#

There ist a was without

#

But Just dont

quasi walrus
#

eh

#

all i need is the dependency file or at least how to get it q~q

smoky oak
#

thats just the spigot api

cold field
#

Heya guys quick question. Do you know any lib that helps me build JSON messages?

chrome beacon
#

Adventure

quasi walrus
cold field
chrome beacon
#

You can shade it in to your plugin if you want it

cold field
#

Uhm, ok great ty

chrome beacon
undone axleBOT
#

Bootstrap Jar
The main spigot-1.18.jar is now a bootstrap jar which contains all libraries. You cannot directly depend on this jar. You should depend on Spigot/Spigot-API/target/spigot-api-1.18-R0.1-SNAPSHOT-shaded.jar, or the entire contents of the bundler directory from your server, or use a dependency manager such as Maven or Gradle to handle this automatically.

Please read the release notes for further information: https://www.spigotmc.org/threads/9-years-of-spigotmc-spigot-bungeecord-1-18-1-18-1-release.534760/#post-4305163

quasi walrus
eternal needle
#

if i need to transleate a list with color codes in config do i need to have it a spesial place?

tardy delta
#

ChatColor.translateAlternateColors

#

On each element

lean gull
#

anyone know a good tutorial on world gen? i tried the one on the bukkit fandom but its old and outdated

sterile token
#

The spigot one

#

Search it liKe: "Spigotmc World gen"

lean gull
#

can you send me a link

quaint mantle
#

Hello world

sage dragon
#

Cancelling EntityChangeBlockEvent seems to remove Falling Blocks, is that correct behaviour?

glossy venture
#

you mean when it hits the ground?

#

because then, yes

grim ice
#

i need a lib idea

smoky oak
#

how can i find all entities in a radius around a location? Is my only option to spawn in an invisible entity and use the getNear function (alternative to iterating through every entity in the world and checking their location)?

#

update: get all entities in a chunk and iterate through those

crimson terrace
#

that being said, that method iterates through all entities in that world to see which ones are close enough to the location specified. You wont get around that I believe

grim ice
smoky oak
#

can i do a for (a : aset; b : bset) in some way/form? I have two sets i need to iterate through and perform an operation on each of the entry pairs of the sets (they have guaranteed the same length)

#

also does null count as duplicate entry in a set?

grim ice
#

nested loo[p

#

loop

#

for each a in aset, loop through b in b set

#

or make a wrapper class

smoky oak
#

ah not what i meant

#

i need to perform an operation on every pair in the set per index so to speak

#

also i just realized i need to use ArrayList

glossy venture
#

you can get 2 iterators

#

for (a : b) is just syntatic sugar

#

@smoky oak

Iterator<...> asetIter = aset.iterator();
Iterator<...> bsetIter = bset.iterator();
while (asetIter.hasNext() && bsetIter.hasNext()) {
  var aItem = asetIter.next();
  var bItem = bsetIter.next();
} 
``` something like this
#

fucking ugly but it works

#

idk for sure im doing the order right

#

one sec

smoky oak
#

isnt that the complicated equivalent of java for(int i = aset.length()){ var aI = aset.get(i); var bI = bset.get(i); }

#

where's the difference?

glossy venture
#

Set<...> isnt ordered it doesnt have a get(int) method right

smoky oak
#

well i realized i could get duplicate entries

#

so i corrected myself

#

to ArrayList

glossy venture
#

oh

#

bruh

#

yeah then just do that

dusty herald
#

Sets can't get duplicate entries though?

smoky oak
#

correct

#

im trying to get all entities in specific bounding boxes

dusty herald
#

oh ok

smoky oak
#

which might be in the same chunk

dusty herald
#

I thought u meant that sets can

smoky oak
#

as such a set for the location.getChunk.getEntities() might have duplicates

#

also does a location point to the corner of a block with the lowest coords or to the middle of it?

glossy venture
#

block location is an int i think

smoky oak
#

which does not answer the question

brave sparrow
smoky oak
#
box = new BoundingBox();
box.resize(l.getX()-.5,l.getY()+.5,l.getZ()-.5,l.getX()+.5,l.getY()+1.5,l.getZ()+.5);

reason i ask is bc im unsure if i have to use 1.0 instead of 0.5 here

brave sparrow
#

You add 0.5 to each to get the middle

smoky oak
#

ah

#

so it's 1

#

thanks

smoky oak
#

if two in same chunk

#

dupe

brave sparrow
#

Ah, so you’re checking chunks multiple times and combining them into one aggregate collection

#

I see

smoky oak
#

it's the only solution i found so far

#
        List<BoundingBox> pset = new ArrayList<>();
        List<Entity[]> eset = new ArrayList<>();
        BoundingBox box;
        for(Block b : blockList){
            if(b.getType() == Material.WAXED_COPPER_BLOCK){
                l = b.getLocation();
                box = new BoundingBox();
                box.resize(l.getX(),l.getY()+1,l.getZ(),l.getX()+1,l.getY()+2,l.getZ()+1);
                pset.add(box);
                eset.add(l.getChunk().getEntities());
            }
        }
brave sparrow
#

Yeah that’s not a bad solution, it just wasn’t clear from your original explanation that two could occur in the same chunk at once

#

Whoa whoa whoa

#

Why are you adding arrays to it

#

Why not just have a List<Entity> and stick them all in that

smoky oak
#

bc Chunk::getEntities() returns Entity[]

brave sparrow
#

So?

#

You can iterate through that array

smoky oak
#

might be a solution

brave sparrow
#

If all you’re going to do with that array later is iterate through it you might as well

smoky oak
#

this looks disgusting but i guess it works

      Set<ItemStack> r_set = new HashSet<>();
        for(BoundingBox b : bset){
            for(Entity e : eset){
                if(e instanceof ItemStack && b.contains(e.getLocation().toVector())){
                    r_set.add((ItemStack) e);
                }
            }
        }

        return r_set.toArray(new ItemStack[0]);```
grim ice
#

an entity cant exist twice

#

normally

#

looks disgusting because of how you did it

smoky oak
#

no but the array returned from Chunk::getEntities() can be the same if it's called in the same chunk twice

grim ice
#

what is rset

smoky oak
#

set of ItemStack[] array to be returned before conversion

#

done that way to make sure i dont get an arrayIndexOutOfBoundsException

grim ice
#

what does it do

smoky oak
#

store all entities found in the defined bounding boxes

grim ice
#
        Set<ItemStack> entitiesFound = new HashSet<>();

        for(BoundingBox boundingBox : boundingBoxes){

            for(Entity entityEntry : entities){

                if(entityEntry instanceof ItemStack && boundingBox.contains(entityEntry.getLocation().toVector()))

                entitiesFound.add((ItemStack) entityEntry);

            }
        }

        return entitiesFound.toArray(new ItemStack[0]);```
brave sparrow
#

Wait wait wait

#

First of all

#

Entities can’t be item stacks

grim ice
#

Yep

brave sparrow
#

They’re Items

#

Second of all

grim ice
#

not my code

#

just fixed naming for it

#

Lo

#

now it looks much better

glossy venture
#

why convert it to an array

brave sparrow
#

Why do you care if they’re in the chunks twice if the end result is a set

#

That will eliminate duplicates anyway

glossy venture
grim ice
#

the loop will never run anyways

#

Entity is never an itemstack

smoky oak
#

actually due to the fact the bounding boxes cant overlap, the duplicates would have in both iterations of the code only been added once to the return set

#

also for some reason it doesnt throw an error

#

yet

brave sparrow
#

There’s no error because you’re checking for entity instanceof ItemStack

#

Which will always return false

#

So it never goes any further

smoky oak
#

ah

grim ice
#

moterius

#

do u know java

smoky oak
#

good enough in most cases

#

doesnt mean i know the bukkit api from the top of my head

grim ice
#

ic

smoky oak
#
if(e instanceof Item && b.contains(e.getLocation().toVector())){
  r_set.add(((Item) e).getItemStack());```, then?
#

yep

brave sparrow
#

why are you doing b.contains

#

if they're in the collection of entities they were in a bounding box

#

you don't need to check it again

#

right?

smoky oak
#

it's not boundingBox.getEntities but location.getEntities

#

the b.contains is to make sure the entities are inside the bounding box and not just in the same chunk as it

brave sparrow
#

oh you're not using the bounding box to filter the entities before this?

smoky oak
#

im doing the filter here

smoky oak
#

I've been specifically told not to use them because they iterate through all entities in that world

#

also since when the fuck are entities considered dupilcates when the only difference betwen is the location

brave sparrow
fading lake
#

wait when did spigot create a util class for bounding boxes?

brave sparrow
#

¯_(ツ)_/¯

fading lake
#

seems pog

smoky oak
#

well then imma replace that set with a list

brave sparrow
#

@smoky oak i just ran the numbers with a quick test program

#

if your world has

#

500000 entities currently loaded in

#

which btw would freeze your server anyway

#

the time to check them all against 25 bounding boxes is about 234 milliseconds

warm light
#

How to check if Inventory is not a Chest Inventory?

smoky oak
#

I'm going to take a look at it then

warm light
brave sparrow
#

plus you can use the Predicate one to only return Items

smoky oak
#

my method either returns duplicates or, when using a list instead of a set, removes some entities

warm light
#

nvm got it

#

I have created an inv using this.
what is the inv type?

river oracle
#

Whatever you set it to though its a chest ui if no type is not specified

warm light
#

ok. thanks

desert musk
#

i wanna make a plugin now where you can make potions recharge their use either through doing damage to mobs or gaining xp

#

is that feasible?

desert musk
cobalt tinsel
#

@EventHandler(ignoreCancelled = true)
public void onPlayerMove(PlayerMoveEvent event) {
Profile profile = Profile.getByUuid(event.getPlayer().getUniqueId());
Match match = profile.getMatch();

    if (event.getPlayer().getLocation().getBlock().getType() == Material.WATER) {
        if(match.getKit().getName().equalsIgnoreCase("Sumo")) {
            event.getPlayer().setHealth(0);
            event.getPlayer().spigot().respawn();
        }
    }
}
#

why is that not working

grim ice
#

so true how is it not working

#

i wonder

cobalt tinsel
#

if(match.getKit().getName().equalsIgnoreCase("Sumo")) {

#

this line is working

#

i tested

eternal oxide
#

You should test event.getTo() not the players location

cobalt tinsel
#

ok

#

hmm

#

if (event.getTo().getBlock().getType() == Material.WATER) {
if(match.getKit().getName().equalsIgnoreCase("Sumo")) {
event.getPlayer().setHealth(0);
event.getPlayer().spigot().respawn();
}
}
}

#

like that?

eternal oxide
#

yes, that will trigger when you step into water

cobalt tinsel
#

kk

grim ice
#

also

#

start with less expensive checks

#

check the block before that

eternal oxide
#

^

lusty raft
#

Might want to check for the water before you get the profile aswell

#

nvm

#

beat me to it

eternal oxide
#

yes, always early exit in teh move event if you can

cobalt tinsel
#

well didn't worked

tardy delta
#

Don't People know that && exists?

#

Of early returns

cobalt tinsel
tardy delta
#

That's not because of that lol

lusty raft
#

..

prisma needle
#

Getting data from Offline Players

safe edge
#

C:\Program Files\Java\jdk1.8.0_321\bin\java.exe -jar BuildTools.jar --rev 1.8.3 What should I add to run java 8 ?

desert musk
#

can you completely make your own enchantments using only a plugin?

ivory sleet
#

Basically yeah

desert musk
#

great

#

is there a player property or function that allows you to make them “wet” all the time

ivory sleet
#

Altho you’d have to in principle add custom lore for displayable visibility in regards to the client

#

wym by wet?

desert musk
#

specifically so they don’t get burnt or have riptide effects

#

(so they can fly during the day basically)

#

((with a trident))

#

weird sounding question but idk

lusty raft
#

You can do all of that

desert musk
#

pog

#

im having a difficult time trying to figure out where to split up my plugin features

lusty raft
#

you can also use my plugin eliteenchantments and code your own effect

desert musk
#

like i could either make a large conglomerate plugin that incorporates all the features i need for my server

#

or i could split it up tediously into multiple plugins

lusty raft
#

It's best to make a core plugin with small features and then separate plugins for large features ie. enchants, events etc.

desert musk
#

cool

lusty raft
#

That way if something breaks you don't need to disable your whole plugin with all the features only the plugin that is broken

desert musk
#

right

#

makes sense

ivory sleet
#

I mean in spigot it doesn’t impact that much how you like to isolate features into jars tho

desert musk
#

yeah but i just want to be neat basically

#

also a lot of the features im making i don’t see anywhere else and i might wanna publicize them

#

but i’m not gonna do that for just a very niche plugin that incorporates all these weird features into one package

ivory sleet
#

Well in enterprise or more professional environments you might wanna extract modules that may change for fragile reasons into separate ones/jars such that the entire system doesn’t have to recompile everytime a binary incompatibility change takes place

desert musk
#

yeah

#

i mean i’ve literally never made a plugin before so i don’t know what it’s like updating through minecraft’s changes

ivory sleet
#

Yeah, got a lot of fun ahead of you then

desert musk
#

lol

#

i should look into mcmmo

#

although what i’ve seen of it i don’t really like all that much

ivory sleet
#

Is mcmmo’s source good?

desert musk
#

but it might be fun to have

lusty raft
#

It's not too bad if you are only working on plugins for your own server

desert musk
#

mhm

lusty raft
#

Ngl if you want to look at some good code to learn from... hate to say it since he is ugly but Auxilor plugins code

ivory sleet
#

But yeah since you did wanna code enchants even looking at sth like splodgeboxs or auxilors enchant plugin could enhance your understandings possibly

ivory sleet
#

Auxilors code is probably good enough

lusty raft
#

My code isn't public but hopefully soon will be 🤞

ivory sleet
#

Last time I looked some of the design choices in his lib was questionable although nothing you’d have to worry about pricedown

#

Ah

desert musk
#

coming from c++ to java is there anything i should really know, like am i allowed to just jump from cpp to java as a cheat or should i just learn the whole lang

ivory sleet
#

Well

#

No manual memory management basically

desert musk
#

rip

#

but ig that’s fine

lusty raft
#

c++ is pretty similar but there are a lot of differences in practises etc.
Shouldn't be too hard to learn Java tho for you

ivory sleet
#

Or well you still have it with Unsafe and VarHandle to some extent

#

But like the gc will handle memory for you

desert musk
#

right

ivory sleet
#

Like it’s genuinely hard to achieve a memory leak if you think enough whilst coding

desert musk
#

lol

#

i’ll try to learn the language in general though ig because ik learning a language for the express purpose of a single project rarely goes well

#

like it’s better to familiarize yourself with the whole environment

#

it’s like ppl that don’t know c++ that ask to learn how to make game hacks from me

ivory sleet
#

Idk

#

Some people do fairly well when working on sth whilst learning the language

#

Others don’t

desert musk
#

mhm

#

i’m just hasted by how the server is currently up and running and i have so many ideas but can’t apply them all in time

ivory sleet
#

But if you came far in cpp (like even multithreading, templates and object orientation) Java will most likely be a piece of cake for you

desert musk
#

ok good

desert musk
#

takes so long to implement stuff

#

currently everythings running in the server using only datapacks lmfao

ivory sleet
#

Hehe yeah well I tend to use libraries

desert musk
#

and it works but some stuff is missing

desert musk
ivory sleet
#

So usually doesn’t take that long for me, altho as they say there are no zero cost abstractions

#

In the start none

desert musk
#

mm

#

ok

ivory sleet
#

But have a look at GitHub repositories such as awesome-java and awesome-minecraft

desert musk
#

interesting

#

i will

ivory sleet
#

Alright good luck (>:

desert musk
#

yes

tender shard
#

I hate noteblockapi

vocal cloud
#

Header files are optional dogekek

manic delta
#
File file = new File("mySchem.schematic");
Vector pos1 = new Vector(loc1.getX(),loc1.getY(),loc1.getZ());
Vector pos2 = new Vector(loc2.getX(),loc2.getY(),loc2.getZ());
World world = new BukkitWorld(loc1.getWorld());
CuboidRegion region = new CuboidRegion(world, pos1, pos2);

can someone help me?, I want to save a world edit selection to a schematic file, this is because I want to save copies of certain places to be able to paste them later (It's for a minigame) I've been looking for days how to do it and the ways I found don't work and in the world edit discord do not support 1.8, maybe some of you know

#

Im using world edit api and 1.8 version

chrome beacon
#

Time to update 😉

lapis widget
hasty prawn
#

Not really, updating is always a fantastic option! 😄

crude loom
#

Hi, I'm trying to detect when an item is being burnt by lava, here is my code:

@EventHandler
    public void onEntityDamage(EntityDamageEvent event){
        Entity entity = event.getEntity();
        if(entity instanceof Item && event.getCause() == EntityDamageEvent.DamageCause.LAVA)
        {
            Bukkit.broadcastMessage("burnt");
        }
    }

But because the item is being damaged twice this event fires twice, any idea on how to fix this?

chrome beacon
#

If you only want it to fire once save the UUID to a Set and don't do anything if the Set contains the UUID

#

Alternativly only do stuff if it's in the Set depending on what you want

crude loom
#

Oh that's smart

#

I'll do that, thanks! :D

#

If an item takes damage once, it's impossible for it to survive right?

stiff zinc
#

Well yea

crude loom
#

And if multiple items will get burnt at the same time will it add it to the same list? Or is it like every user has it's own list

#

Or every time the event runs or whatever

stiff zinc
#

That would depend on what you are actually trying to do

crude loom
#

If I just add the id of the item to a list every time it's being damaged with the event

#

Then another item is being damaged

#

Will it be the same list? or does it create a new one in the memory?

#

Also if I check a value in the config every time this event fires
Will this be intensive for the server?

granite owl
#

does someone have exp with deserializing inventories from player dats?

#

to view the inventories of offline players

echo sentinel
#

When I have InventoryClickEvent and action is HOTBAR_SWAP, how can I get two items that are swapped?

stiff zinc
#

@crude loom use EntityCombustEvent

#

For when the item burns

#

No need for a list

crude loom
echo sentinel
#

for example when i have stick on slot 1 inventory and on slot 2 I have diamond, when I hover over stick and press 2 on keyboard items get swapped, but when I use e.getCursor() + "\n" + e.getCurrentItem() it returns ItemStack{AIR x 0} ItemStack{STICK x 1}

#

so my question is how can I get both items that are swapped

grim ice
#

@granite owl when a player logs out

#

store his inventory

#

ez

#

however you like it

viral crag
echo sentinel
#

What can I do with inventoryView

sage dragon
#

Is getServerInfo case sensitive?

ivory sleet
#

iirc yes

wispy plume
#

How can I open a book for player in 1.12.2? got a solution

granite owl
#

like ofc i can serialize it from the object in memory

#

but i was thinking of accessing the "real" inventory directly from the players file

#

and write to that

viral crag
granite owl
#

prism

lapis lark
#

Hi, do you know if EntityShootBowEvent will be triggered for pillager crossbow shoot?

undone axleBOT
agile sand
#

Hello! How I can create an empty ConfigurationSection object?
Simply create a "yamlconfiguration" object, or what I need to do?

ivory sleet
#

ConfigurationSection::createSection exists

agile sand
ivory sleet
#

well

#

you do have some other options

#

but I'd stick with createSection

#

for instance you could pass a new MemorySection() or simply a new MemoryConfiguration()

lean gull
#

anyone got a good tutorial for world gen? i tried the one on the bukkit fandom but its outdated

crude loom
#

Should Player.getInventory().remove() remove 1 item from a stack if it's amount is more than 1? or should it just remove the whole stack regardless of the amount

tall dragon
crude loom
#

I see, how do I remove 1 item from the stack then?

tall dragon
#

loop through the inv till u find the matching item

#

and decrement the amount

crude loom
#

I will try that, thanks :D

#

Oh, setting the amount to 0 is the same as removing the item, I see
Anyways, this works now thanks for the help :D

tall dragon
#

👍

granite owl
#

is LootGenerateEvent the callback that fires when opening villager/dungeon etc chests?

grim ice
#

WTF

#

NO

#

use removeItem

smoky oak
#

uuuuuuuuuuummmmmmmmm........
does anyone know why in the world it seems impossible for bukkit to give me two item instances as long as they're duplicates of each other?
I set up a scan that tells me the items over a block, but this scan does NOT work once i throw down items with the same type & stack size?????
code is basically this (with a check if it's in a bounding box):

Collection<ItemStack> ent_col = new HashSet<>();
for(Entity e : allEntitiesInWorld){
    if(e instanceof Item)
      ent_col.add(((Item) e).getItemStack());
}
print(toMaterialString(ent_col));

And the following happens:
[1x Amethyst block] -> AMETHYST_BLOCK
[1x Amethyst block][1x Copper block] -> AMETHYST_BLOCK+COPPER_BLOCK
[1x Amethyst block][2x Amethyst block] -> AMETHYST_BLOCK+AMETHYST_BLOCK
and here's the dumb part:
[1x Amethyst block][1x Amethyst block] -> AMETHYST_BLOCK

#

the fuck???

hasty prawn
#

HashSet requires unique elements.

smoky oak
#

dont items have location?

ivory sleet
#

Item does, but ItemStack nope

smoky oak
#

urgh

hasty prawn
#

^

tall dragon
#

how would you remove 1 item from a stack

#

that method removes as much as it can find of the same type & amount

tardy delta
#

oh is the signature of the Set#add method add(Object) instead of add(E) to make you able to add objects which extend E but arent cast already?

ivory sleet
tardy delta
#

wait

#

it was with map

#

:c

#

not all people were drunk when they wrote this

lean gull
tardy delta
#

but for example map:
V remove(Object key);
boolean containsKey(Object key);

ivory sleet
#

yes

tardy delta
#

to avoid casting?

viral crag
ivory sleet
#

nah

#

mainly due to backwards compat

tardy delta
#

oh i thought the person who wrote this drank to much

lean gull
#

even if i can get the tree populator to work, idk how to make it so it creates a new world and idk how to make it customizable

viral crag
#

then perhaps you shouldnt be doing it?

lean gull
#

not knowing something = shouldnt do it?

viral crag
#

maybe, try getting one of those 3 things to work first?

lean gull
#

it won't help

viral crag
#

probably not

#

making bread so you have sliced bread to make a sandwich is never a good idea

manic delta
hasty prawn
#

OCM

tardy delta
#

then go to the shame corner

#

its right there

viral crag
#

6 million pvp plugins and none of them work 😆

manic delta
#

meh

hybrid spoke
#

i can pvp without a plugin

tardy delta
#

i cant pvp

manic delta
#

i think i will try cloning the world

tardy delta
#

sorry god

manic delta
#

bcs no one can help

#

💀

hybrid spoke
tardy delta
#

good

viral crag
manic delta
#

both

viral crag
#

i sure someone might if you paid them

manic delta
#

meh

#

i just will clone the world

#

it's an empty world anyway

viral crag
#

most of those are 1.12-ish no?

#

yeah - I generally only see them when someone runs curseforge

ivory sleet
#

afaik there aren't any good ones

#

like actually good ones

viral crag
#

classes i'd think you could handle via luckperms tracks, races would be more difficult if it goes beyond factions

#

pretty large design undertaking and probably why no good ones are out there or maintained at current release

#

put no sarcasm in those last posts

#

hahaha werent you all about yourself a short while ago?

hasty prawn
#

Well that's basically impossible

viral crag
#

write down a list, put it on a map and include space for forks/features to ignore until your done your main list

#

you will never satisfy everyone and to go out of your way to support legacy items is not worth it

hasty prawn
#

Well you've already failed to make everyone satisfied

viral crag
#

then you have special cases to put in your feature requests to ignore until the core is done

#

you will eventually come to the conclusion that some requests are stupid or impossible

#

one hopes so, however you still want your core to be stable and maintainable

ivory sleet
#

I'd say most important thing with big projects is to get stuff done, doesn't have to be perfect the first time but make sure you progress, else you'll get rather demotivated hastily

viral crag
#

measurable stuff done!

ivory sleet
#

From personal experience I've worked with talented people, but (some of them) pay too much attention to insignificant details like "Oh you use singleton here, must refactor :))))", which of course makes sense but it slows the rest of the team down enormously, well Idk if you're working with some1 now but you get the gist of it I hope

(Well this doesnt go without saying that paying attention to details isn't always bad, but yeah, find a balance :^))

viral crag
#

if you know how to use them, gantt charts are valuable for visualizing that type of issue

rich inlet
#

Hey,
my PlayerInteractEvent somehow gets fired twice, even after I checked for event.getHand() == EquipmentSlot.HAND. This is my code:

event.setCancelled(true); if (item == null) return; if(event.getHand() == null) return; if (event.getHand().equals(EquipmentSlot.HAND)) { if (event.getAction() == Action.RIGHT_CLICK_AIR || event.getAction() == Action.RIGHT_CLICK_BLOCK) { int itemSlot = player.getInventory().getHeldItemSlot(); if (itemSlot == 0) { //code } } }

rich inlet
#

Yes, but the offhand is EquipmentSlot.OFF_HAND

last sleet
#

If I wanted to add, for example, a "COMMON" or "RARE" or "EPIC", etc. tag into an item when crafted (so adding that tag when crafting vanilla items), would I need to override all vanilla crafts and replace them with my own "custom" recipe, just to add those tags, or is there a better way?

last sleet
viral crag
#

Represents an event that is called when a player interacts with an object or air, potentially fired once for each hand. The hand can be determined using getHand().

#

you know what hand you want, are you cancelling the other one?

last sleet
#

Thanks!

rich inlet
#
            event.setCancelled(true);
            if (item == null) return;
            if(event.getHand() == null) return;
            if (event.getHand().equals(EquipmentSlot.HAND)) {
                if (event.getAction() == Action.RIGHT_CLICK_AIR || event.getAction() == Action.RIGHT_CLICK_BLOCK) {
                    int itemSlot = player.getInventory().getHeldItemSlot();
                    if (itemSlot == 0) {
                    // Code
                    }
                }
            }
rich inlet
tardy delta
#

no need for equals

rich inlet
#

Okay, but still calls two times. But only, if I look directly down. When looking at another block or in the air, its fine

tardy delta
#

interact event?

rich inlet
#

Yes

tardy delta
#

for each hand

ivory sleet
#

make sure you didnt register it twice btw

rich inlet
#

I didnt, I already checked

#

And there is always a golden pressure plate beneath me, when this event is called. Maybe this helps

#

I think it has to do with hat, because it always calls twice when I look at the pressureplate. When I look at the pixel on the edge of the pressure plate, where just the block beneath is, then its fine

viral crag
#

I would say do a quick console output and check, not sure what you have would cancel both events. As EquipmentSlot[] is an array it might still be valid if you dont remove the HAND enum

smoky oak
#

try doing a if(Hand == EquipmentSlot.MAIN_HAND)

#

something along those lines

#

wait

rich inlet
#

There is no MAIN_HAND, only HAND and OFF_HAND

smoky oak
#

yea i just realized

#

ah

#

do event.getHand() == EquipmentSlot.HAND instead of .equals

#

might be the issue

rich inlet
viral crag
#

wait, on a pressureplate?

rich inlet
#

Yes

smoky oak
#

maybe the game triggers the event twice since its a redstone component?

rich inlet
#

Standing on a pressure plate is a playerinteractevent hmm

viral crag
#

so the hand interacts with the pressureplate and the pressure plate interacts with the hand

rich inlet
#

And is there a way to fix this?

viral crag
#

check if your on a pressure plate and suppress one. however before that make sure it doent happen on a regular block

#

it shouldnt

rich inlet
viral crag
#

check if you are interacting with a pressure plate and choose which one to ignore and which one to handle it

rich inlet
#

So i can basically check if the Action is PHYSICAL?

viral crag
#

mmm i think you will also have the same issue with buttons and sculk sensors

rich inlet
#

ANd if so, return

smoky oak
#

anyone else here hating regex too?

viral crag
#

yeah one of the action types might work

rich inlet
#

if(event.getAction() == Action.PHYSICAL) return; does not help

viral crag
#

PHYSICAL
Stepping onto or into a block (Ass-pressure) Examples: Jumping on soil Standing on pressure plate Triggering redstone ore Triggering tripwire

rich inlet
#

Well, my event should only trigger if it's not the Physical one, but the right clicking

viral crag
#

unless what you are doing is supposed to be on the pressure plate

sinful hedge
#

do you knows a Discord bot plugin that displays the status and player count of a Minecraft server in the sidebar?

rich inlet
sleek pond
#

Yea your right

viral crag
sleek pond
smoky oak
#

why does this not work?

replaceFirst("~ /.*"+separator+"(.*)/","");```
it's supposed to cut off every slash in the file string but the string returns unmodified
viral crag
#

its a habit and code rule for certain types of programming, there should only ever be one return and always at the end.

smoky oak
#

i read the file location in

viral crag
#

anyway, drop in a comment to make sure which event you are handling and responding to

smoky oak
#

imma try something else

rich inlet
smoky oak
#

aha

#
String name = s.getType().getName();
name = name.substring(name.lastIndexOf(separator+1),name.length()-4);```
#

no regex necessary

viral crag
rich inlet
#

I already checked them and have no clue, and I already sent them in here

#

if (event.getAction() != Action.RIGHT_CLICK_AIR && event.getAction() != Action.RIGHT_CLICK_BLOCK) return; also doesnt help

viral crag
#

are you firing in both conditions or just one?

rich inlet
#

Only when the hand is the main hand

sharp bough
#

that works as expected

#

if that fires twice then you are registering the event twice

grim ice
#

give me lib ideas

crude loom
#

I don't really know the difference between the different sever types, like paper, bukkit and spigot so if I give someone a plugin I coded in spigot should it work no matter what his server type is or do I need to do something?

brave sparrow
grim ice
#

spigot plugins work in bukkit and paper, except if you use .spigot() functions i think

#

but paper will always work with spigot

crude loom
#

I see, is there a server type that wont work with my plugin?

brave sparrow
viral crag
grim ice
#

Spigot plugins are fine with paper servers
paper plugins are not fine with spigot servers

smoky oak
#

alternatively i use indexOf(".")

brave sparrow
grim ice
#

if its in paper it might not

crude loom
smoky oak
#

forge

grim ice
#

yeah but theyre uncommon

viral crag
brave sparrow
#

@crude loom a Bukkit plugin works for Bukkit, Spigot, Paper, whatever is downstream from Paper, etc. A spigot plugin is guaranteed to work for anything spigot or later, and may work for bukkit. And so on and so on and so on

brave sparrow
crude loom
brave sparrow
#

Forge and spigot are totally unrelated yes

brave sparrow
viral crag
#

i agree

brave sparrow
#

An early return is no different from throwing everything inside one big if statement, it just makes the indenting more annoying

crude loom
ivory sleet
#

Maybe one of the Files functions could help you out

brave sparrow
#

Which is harder to read:
if (a != null) {
if (a.b() != null) {
if (!a.b().c()) {
//stuff
}
}
}

Or

if (a == null) return;
if (a.b() == null ) return;
if (!a.b().c()) return;
//stuff

ivory sleet
#

Files::newDirectoryStream or perhaps Files::walkFileTree zacken

brave sparrow
#

Correct

ivory sleet
#

well, most compilers do compile down to the former iirc

#

mostly due to performance but yeah

brave sparrow
#

Lol

#

It also gets compiled to bytecode, but that doesn’t mean our actual source should be a bunch of bytecode

ivory sleet
#

yeah

#

n yeah File::listFiles is probably fine for your case zacken altho not particularly scalable

tardy delta
#

nullable operators when

ivory sleet
#

never

#

Optional can help you out instead (with a bunch of flatMaps)

#

I literally gave you two reliable api methods but sure

tardy delta
#

a?.b?.c() looks a lot cleaner than Optional.ofNullable(a).map(a::b).map(b::c).orElse(null)

ivory sleet
#

I agree

#

but Java's null is unoptimized alr

#

so idk

buoyant viper
#

i personally use

tardy delta
#

dunno what the difference is between flatmap and map tho

buoyant viper
ivory sleet
#

flat map is a monad

#

map is not a monad

tardy delta
#

lemme translate that

#

what does monad mean?

ivory sleet
#

basically
(M<T>, T -> M<R>) -> M<R> is a monad

#

or in Java

#
class M<T> {
  public <R> M<R> flatMap(M<T> this, Function<T,M<R>> function) {
    //TODO
  }
}```
#

M<T> this can be removed so

#
class M<T> {
  public <R> M<R> flatMap(Function<T,M<R>> function) {
    //TODO
  }
}```
#

simply

#

map is just

#

(M<T>, T -> R) -> M<R>

tardy delta
#

lol thats not simple

ivory sleet
#

so <R> M<R> map(M<T> this, Function<T,R> function) instead

#

basically flatMap is a computation builder, whilst map is not

tardy delta
ivory sleet
#

ye

desert musk
#

im makin a plugin where a user can select where they want to respawn after death

tardy delta
#

is anyone ever using that lol

desert musk
#

how should i go about making a "limbo" world or thing so that i can prompt them and receive their answer

ivory sleet
#

yes

#

there are Optional religious people

#

because they simply believe touching null is too low level for Java

tardy delta
#

isnt that a kind of disease? 🤔

ivory sleet
#

idk

#

I mean depending on pov it could make sense

tardy delta
#

i believe even satan is afraid of doing that

desert musk
#

lol

ivory sleet
#

myeah

#

well it wouldn't be bad if Java added null chain operator

#

but its probably low priority

crude loom
#

How does the plugin know what is the correct usage and when to send the message of wrong usage from the plugin.yml?

ivory sleet
#

might be added in jdk 69 or sth

tardy delta
#

kek

ivory sleet
#

cuz they scarcely add newer features such as those

#

they mostly observe other languages and how those features are seen upon by respective language developers

tough crane
#

Hey ,
does anyone have a site / support to learn how to use APIs between plugins? and learn what an "api" is? ^^

ivory sleet
#

cause they want to add necessary and non rushed features (where there have been proper theory around it), unlike a certain language Kot...

tardy delta
#

lin..

wet breach
ivory sleet
#

just the usage

#

but thats for /help

#

so in reality you would need to manually prompt a given command sender the appropriate messages

ivory sleet
#

not much different from normal code

#

learning them takes time as they are all a bit different in terms of design and depending on what the api is for

tough crane
#

basically it's just being able to add events from other plugins to my plugins?

ivory sleet
#

there's no general way to suddenly fully unlock knowledge for every api that presently exists in this world

#

hmm

#

to some extent

viral crag
#

... can you access other plugin handlers ?

ivory sleet
#

but like an api is a very foggy term

quiet ice
ivory sleet
#

think they mean custom event classes provided by other plugins

quiet ice
#

event handlers?

viral crag
#

event handlers in this case

quiet ice
#

As in event listeners or the event handler list in an event class?

ivory sleet
tough crane
ivory sleet
#

might be worth doing it eagerly, as soon as the server starts since creating a world can lag a bit

#

Tasic thing is, a mere Java class alone can be seen as an "API" from the view of other classes

viral crag
quiet ice
viral crag
#

that is true also

quiet ice
#

Do you want to spoonfeed a block change to a specific block logging plugin? This is one way to do it without using their API

#

But it should be possible to do

sharp bough
#

@ivory sleet hey if im trying to keep a json in memory for quick access of a lot of data moving arround consantly, is it better to use normal json for example:
https://pastecord.com/viqahisaqo.cs that would generate the image, or learn gson and use that instead?

ivory sleet
#

whats normal json?

#

simplejson?

sharp bough
#

JsonObject() and JsonArray()

#

among others

ivory sleet
#

those are not normal

sharp bough
#

but mainly those

ivory sleet
#

they are not contained within the java library itselfg

#

those are from a dependency

#

what is the name of that dependency?

#

anyhow yes I would strongly encourage learning gson, or jackson or moshi, those three are the ones most devs out there use in fact

#

so being knowledgable in those particular three wont harm you

sharp bough
#

com.google.gson.JsonObject

ivory sleet
#

thats gson

#

you're just using an arguably legacy way of dealing with the json tree structure

sharp bough
#

and by any chance do you know which one i should use if i want a lot of data moving around efficiently?

#

otherwise im gonna google a few things

quaint mantle
#

When using saveResource("example.yml", true/false);
What does the true/false do ?

tender shard
#

replace eixsting

vocal cloud
#

Liver failure

ivory sleet
#

@sharp bough type adapter

#

mainly

vocal cloud
#

Constant state of failing liver

sharp bough
vocal cloud
#

Or is it kidneys

viral crag
#

poor vitamin and lack of exercise creating a storage of uric acid - ideally the whites of your eyes should have a blue tinge

quiet ice
#

My personal favourite for json parsing is org.json:json. But I am sure a lot disapprove here

wet breach
viral crag
#

oh, your just a mongrel 😛

#

not aware of any health related things to iris color other than cataracts - oh and glacuoma

#

someone will still think you are pretty

#

...

wet breach
#

ah you are one of the rare people then

echo basalt
#

mine are green/gray

#

rip no emotes

quaint mantle
# tender shard replace eixsting

So if there is for example

one:
  test: false
two:
  test: false

in the file thats already created, it wont replace them, but if it has new content thats not there, it'll add it, right?

tender shard
#

no

#

it will overwrite the existing file if the parameter is set to true

#

and if it's false, it will say "could not save resource asd.yml"

quaint mantle
#

Aha, understood.

echo basalt
#

only good use-case scenario is restoring to defaults if the file is invalid

#

but there are much better ways to do it

quaint mantle
viral crag
#

you can read from the file, are you expecting them to be different?

crude loom
#

What is the common way to show the user the list of the plugin's commands and syntaxes?

tender shard
tender shard
crude loom
#

Yeah that works, thanks!

crude loom
viral crag
#

yeah you can dump em in the plugin.yml or use annotations

crude loom
#

Wait but the help commands shows the description and usage of the command

#

How do I show the syntax?

tough crane
#

what is a file pom.xml in plugins opensources ? i can add repository and dependency inside

viral crag
tender shard
tough crane
#

sorry if i'm super dumb but i'm trying to learn 😂

crude loom
quaint mantle
#

Or would it be better to use a database for things such as creating mines and stuff?

tough crane
#

ok so this is where I add the dependencies and libraries of my api or libs?

grim ice
#

basically ur configuration file that maven uses to turn your project into a jar file

#

simplest terms

viral crag
crude loom
#

Ah, and this I do where?

grim ice
#

i need

#

a library idea

#

i cant

viral crag
#

its a part of spigot

#

i currently am playing with using annotations now

vocal cloud
#

I have a library for annotations to register everything hes_UwU

viral crag
#

yes it generates it's own plugin.yml looks like this for commands @Command(name = "contributor", desc = "Contributor Command", aliases = {"SAcontributor"}, permission = "QuadArrows.contributor", permissionMessage = "You do not have permission!", usage = "Only returns authors")

#

then you only need your CommandExecutor

fallen sandal
#

..

viral crag
#

i originally thought it might be that way too

fallen sandal
#


                    //ab.addField("Cannot Retrieve Online Players..", "", true);
                    ab.addField(p.getDisplayName(), "", true);

                }

                else {
                    ab.addField("Cannot Retrieve Online Players..", "", true);
                    
                }``` in this code
viral crag
#

oracle seems to have had other ideas

quiet ice
#

oracle?

tardy delta
#

Integer.parseInt(String.valueOf(1))

quiet ice
#

don't worry, it's commented out

fallen sandal
#

when someone playing in my server like if 1 or more than 1 player is playing its sending embed message

#

but if no one playing its not sending any message

fallen sandal
tardy delta
#

lol no

quiet ice
#

nonono

fallen sandal
#

lol

viral crag
tardy delta
#

what are you even doing

quiet ice
#

Yes, but nothing prevents you from acctually doing it like proposed

tardy delta
#

::isEmpty kek

quiet ice
#

It's not an oracle limitation but a plugin-annotations limitation

fallen sandal
#

what should i do .-.

quasi flint
#

::isEmpty

quiet ice
#

Are you sure that the lines of code are called when there are no players online?

fallen sandal
#

ok

quiet ice
#

Also beware that getOnlinePlayers can be inaccurate in some conditions

fallen sandal
#

but when the player is less than one or noone playing its not sending any message

quiet ice
#

Player being dead for example

tardy delta
#

ah

quiet ice
#

It makes sense given that there is no player entity, but under some circumstances it can be an issue

mellow edge
#

is possible to kick the person from the server if he refuses costum resource pack download

fallen sandal
#

no

quiet ice
#

Just throw a few sysouts at it and check if it is called

fallen sandal
#

trying this if (Bukkit.getOnlinePlayers().size() == 0)

viral crag
mellow edge
#

ok

fallen sandal
#

still same

quiet ice
#

are you sure this is called?

fallen sandal
#

yes

#

cant i send image here?

low temple
quiet ice
#

It's not of relevancy

low temple
#

I forget what data type Bukkit.getOnlinePlayers() returns tho

quiet ice
#

Player most likely

low temple
#

Yeah but is it an array of players or List?

tardy delta
#

Collection<? extends Player>

#

so craftplayers

quiet ice
#

@fallen sandal Actually, could you just send the whole code?

low temple
#

Yeah then you can use #isEmpty()

fallen sandal
#

mm

quiet ice
#

and they were never seen again

viral crag
#

why not just add/subtract from a scoreboard objective?

fallen sandal
#

my internet sucks

quiet ice
#

Then using discord may not be the wisest choice

fallen sandal
#

import net.dv8tion.jda.api.EmbedBuilder;
import net.dv8tion.jda.api.entities.Message;
import net.dv8tion.jda.api.entities.MessageChannel;
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
import net.dv8tion.jda.api.hooks.ListenerAdapter;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;

import java.awt.*;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
import java.util.List;

import static org.bukkit.Bukkit.getServer;

public class getonlineplayers extends ListenerAdapter {
    
    @Override
    public void onMessageReceived(MessageReceivedEvent event) {
        if (event.getAuthor().equals(event.getJDA().getSelfUser())) return;
        Message msg = event.getMessage();
        if (msg.getContentRaw().equals("!onplayers"))
        {
            MessageChannel channel = event.getChannel();
            for (Player p : Bukkit.getOnlinePlayers()) {
                EmbedBuilder ab = new EmbedBuilder(); //Creates the embed.
                String logo = "https://swapnocraft.com/favicon.ico";
                SimpleDateFormat formatter = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
                Date date = new Date();
                ab.setTitle("Swapno Online Players");

                ab.setColor(Color.decode("#00aaff"));

                if (Bukkit.getOnlinePlayers().size() == 0) {
                    ab.addField("No one Playing..", "", true);
                }
                else {
                    ab.addField(p.getDisplayName(), "", true);
                }
                ab.setFooter("Developed With Love By Akash :)    " + formatter.format(date), logo);
                event.getTextChannel().sendMessageEmbeds(ab.build()).queue();
            }
        }
    }
}```
fallen sandal
quiet ice
#

Ah

#

this explains it

fallen sandal
#

what

quiet ice
#

Your Bukkit.getOnlinePlayers().size() == 0 is called for every online player

fallen sandal
#

yes

quiet ice
#

And if there are no online players?

fallen sandal
#

ab.addField("No one Playing..", "", true);?

wide coyote
#

its in the for loop

quiet ice
#

Nope! It will never get called

fallen sandal
#

ah

quaint mantle
#

Are we allowed to limit the amount of IPs a plug-in can be used on?
I want to try and prevent paid plugins from being leaked, but am not 100% sure if spigot allows for this.
Whilst this is not going to stop everyone, it may stop people that don’t understand Java very well

tender shard
wide coyote
#

you can listen for InventoryClickEvent and InventoryDragEvent

fallen sandal
wide coyote
quiet ice
#

You can, just outside your for loop

quaint mantle
sharp bough
vocal cloud
#

I always say. Show me a plugin that has some anti-copy prevention and I'll show you a cracked plugin lol

sharp bough
#

it would be for a beta version of the server, so not that much usage

sharp bough
#

mm i think im gonna use that

fallen sandal
quiet ice
#

You do not even need p

#

At least not there

fallen sandal
#

Player p = Bukkit.getOnlinePlayers();

#

??

quiet ice
#
if (players.isEmpty()) {
    // Empty!
} else {
    for (Player p : players) {

    }
}

Would be how I would do it

fallen sandal
#

ok

quiet ice
#

Unless you want to send that JDA message for every online player

#

At which point you just need to move the if statement over the for loop

tardy delta
#
if (players.isEmpty()) {
    // Empty!
} else for (Player p : players) {

    }```kekw
ivory sleet
#

else for eyes_left

fallen sandal
#

Incompatible types. Found: 'org.bukkit.entity.Player', required: 'java.lang.String'

tardy delta
#

i did else try to

#

oh not pushed to github yet

ivory sleet
#

oh god

#

that looks so cursed

#

I can of sth like else var x = 1; also

#

holy crap

#

ew

fallen sandal
#

okay so

#

i had changed some stuff and made like the old one

#
                // Empty!
                ab.addField("No one Playing..", "", true);
            } else {

                for (Player p : Bukkit.getOnlinePlayers()) {

                    ab.addField(p.getDisplayName(), "", true);
                }

            }```
#

and its working what i wanted

#

thanks for help :))

sharp bough
#

?doc

#

?docs

#

?documentation

tardy delta
#

?j-docs

#

?jd

fierce glacier
#

how to add a potion effect to a monster please ?

brisk estuary
#

Does anybody know how can I use javax.annotation classes? I'm using Intellij IDEA but it doesn't recognize the availability of these classes via maven dependency and the imports are shown as unavailable. How can I fix it?

fierce glacier
#

thank !

sacred mountain
tardy delta
#

ye because you dont need brackets for an if else

sacred mountain
#

o

tardy delta
#
if (true) { doSomething(); }
if (true)
    doSomething();```
#
if (true)
    doSomething();
else try doSomeException();
catch (Exception e) {}```
would probably work
sacred mountain
#

damn

#

do you guys put spaces in between operations

#

like a+b or a + b

tardy delta
#

spaces

sacred mountain
#

good

tardy delta
#

without is horrible

sacred mountain
#

yes exactly

vocal cloud
#

Ctrl Alt L

tardy delta
#

doesnt do anything

vocal cloud
#

formats the current file

strong parcel
#

Is it possible to have text both bold and underlined in a written book?

#

I have tried ChatColor.UNDERLINE + ChatColor.BOLD, but Java does not like that.

hexed hatch
#

put a blank string between them

#
  • "" +
tardy delta
#

or call toString explicitly

strong parcel
spring minnow
#

i have a problem with an event etting called twice

#

can someone send me the ' thing cuz idk how to do it on italian keyboard?

#

so i send the code

#

xDDD

plush gulch
#

is there an event that triggers when a sound is played or when a player hears a sound?

spring minnow
#

mhh, i don't think so

#

never heard of it

#

also, would be quite difficult to manage

#

imagine that in a whole server like everything plays a sound, imagine mananing that xD

#

even if you had an event like this you wouldn't be able to detect what made it for the all things that makes sounds

#

what do you need it for?

plush gulch
#

I want to make a challenge for myself to hear all minecraft sounds

#

do you know if something like this exists in modded?

spring minnow
#

wait what

#

and you would to make like that every time a sound is played, you get a warning?

#

something like that?

#

@,@

plush gulch
#

well every time a new sound is played its checked off the list

spring minnow
#

oh

#

i don't think there is a way to do that

#

i also checked the event folder of bukkit do be 100% sure and there is no event for this

vocal cloud
#

Forge has a client sound event

plush gulch
spring minnow
#

np

#

MikeTheShadow

vocal cloud
#

hm

spring minnow
#

can you send me the ' thing