#help-development

1 messages · Page 1403 of 1

wraith rapids
#

an instance doesn't do anything

#

there's nothing to synchronize

eternal oxide
#

You could synchronise the Class and that will sync everything in it

wraith rapids
#

you mean to synchronized (MyClass.class) {} ?

mortal hare
#

yea ik, but i can't in this particular situation since thread unsafe code is ran not only from my classes

#

no

wraith rapids
#

@ elgar

#

yeah you can't make code that wasn't written with synchronization in mind be synchronized

mortal hare
#

that what i was asking for, but i guess i'll just run that code in the main thread instead

wraith rapids
#

like yeah you can make every method of your class synchronized yes, but he needs to operate on the methods of a class from nms

maiden briar
#

Not solved yet

wraith rapids
#

he can't exactly modify the source and make all of the related nms methods synchronized

mortal hare
#

^^

eternal oxide
#

Then he needs to make an access wrapper

wraith rapids
#

an access wrapper is only useful if all of the access is done through that wrapper

eternal oxide
#

Thats the point of an access wrapper

wraith rapids
#

which again would involve making the nms spaghetti use that wrapper

mortal hare
#

well problem is that its NMS class, its not that the only one plugin uses it

eternal oxide
#

ah, so access beyond his control

mortal hare
#

yes

eternal oxide
#

Then I suggest you give up

wraith rapids
#

basically yeah

mortal hare
#

eh

young knoll
#

Just uhh

wraith rapids
#

best you can do is sync to main thread

young knoll
#

Mixin the NMS stuff

mortal hare
#

im just gonna run inside the main thread

sharp bough
#

if i wanna do a plugin in 1.12, do i use JDK ver 13, or 11?

young knoll
#

Most servers use 8

#

If it’s private you can use whatever you want

sharp bough
#

1.8?

young knoll
#

Java 8, 1.8, same thing

wraith rapids
#

lots of servers are going to switch to 11 soon and have switched already

maiden briar
wraith rapids
#

what with the whole paper wanting to move away from 8 thing

sleek pond
wraith rapids
#

they've gotten a bunch of shared hosts up in the arms and changing the default runtime to 11

#

and apparently paper won't support 8 as of 1.17

wraith rapids
#

which fucking pisses me off because I like my _ variable names

mortal hare
#

guys its 2021, java 8 is 7 years old.

wraith rapids
#

but 9 and 11 fucked up reflection and made it gay

young knoll
#

1.8 is 6 years old

sleek pond
mortal hare
sleek pond
#

lmao

wraith rapids
#

can't access the internals of propietary classes anymore

mortal hare
#

because i've saw these kind of vars thrown around there

sleek pond
#

I know of a python dev here

wraith rapids
#

f.e the root field of the Field class

young knoll
#

The only change I seem to recall is not being able to reflect away final

wraith rapids
#

there are hidden classes and fields now

#

quite a few of the base library classes now have their fields and internals invisible to reflection

mortal hare
#

why?

wraith rapids
#

because muh security or some shit

#

muh stability

mortal hare
#

bullshit

minor garnet
#

for a class to save data would i use an arraylist or a list?

wraith rapids
#

muh "can't let noobs run around tearing the system apart because it might explode"

#

what do you care if my system explodes

#

it's my fucking system

mortal hare
#

if someone modifies the fields via unwanted software you're already fucked

wraith rapids
#

i can blow it up if I want

young knoll
#

List is the abstract class

wraith rapids
#

I should be allowed every freedom to blow it the fuck up

#

in any way I desire

sharp bough
#

wtf is that

wraith rapids
#

is what

sharp bough
#

how can i disable it

wraith rapids
#

disable what

sharp bough
#

whats it called?

wraith rapids
#

the popup?

sharp bough
#

the purple thing

mortal hare
#

popup

sharp bough
#

yea

wraith rapids
#

press esc or something

mortal hare
#

reference popup

wraith rapids
#

it shows you what the method parameters are

#

and is very useful in conjunction with auto completion

#

if you want to hide the box, press esc and it goes away

#

if you want to bring it back up, press ctrl-p

sharp bough
#

quite annoying sometime s

wraith rapids
#

it's a life saver once you get used to it

#

or would you rather flip between your browser and look at the javadocs each time you forget the exact order of the arguments

digital plinth
#

is there another method to make player chat other than player.chat()?

worldly ingot
#

o.O

#

"Is there another way to do what this does exactly what I want?"

eternal oxide
#

Yes Bukkit.getPlayer(name).chat 🙂

worldly ingot
#

I still fear people that write Bukkit.getPlayer(player.getName())

#

I wonder if they know something that I don't

quiet ice
#

well, it does prevent the use of offline mode servers

worldly ingot
#

No it doesn't PES_CryHands

young knoll
#

player.getPlayer.getPlayer.chat

eternal oxide
#

Interestingly if you run this code in the PlayerRespawnEvent it should throw an NPE java Bukkit.getPlayer(event.getPlayer().getname()).chat("test");

digital plinth
digital plinth
eternal oxide
#

More code has to be better.

urban trout
#

howdy do, how would i make a random message chooser?

digital plinth
#

math.random

urban trout
#

so like if i did /hey, it'd say something like hi, hey, hello

#

okay thanks

ivory sleet
#

list.get(ThreadLocalRandom.current().nextInt(list.size()))

urban trout
#

hi its me again

                String[] arr={"Tip 1", "Tip 2", "Tip 3", "Tip 4", "Tip 5"}; 
                Random r=new Random(); 
                int randomTip=r.nextInt(arr.length);
                player.sendMessage("§6§lTip:§7 (arr[randomTip])");
                return true;```

how would i add my random tip to the message
sharp bough
#

why do i get this error?

#

mc ver 1.12

#

the second starting doesnt run

#

the if condition brakes the plugin

sharp bough
#

player.sendMessage("§6§lTip:§7"+ (arr[randomTip]));

#

i think

urban trout
#

o

#

last time i tried that it was underlined

#

oh lit it worked

#

thanks a bunch

sudden raft
sudden raft
solemn shoal
#

how does spigot internally represent rgb color?

south onyx
#

https://pastebin.com/r4Pd3w23
here is the code im getting an error in

@EventHandler
    public void onInteract(PlayerInteractEvent e) {
        if (e.getItem().getType() == Material.COMPASS) {
            System.out.println("hi");
        }
    }

line 31 is the if statement

solemn shoal
#

yes i mean bungee, not the bukkit one

urban trout
#

hello its me again again, would it be possible to stop any mobs apart from zombies spawning?

solemn shoal
#

o hi 7smile7

lost matrix
#

Hi ;D

solemn shoal
#

do you still have that color mapping thing?

#

at this point im just implementing my own RGB color class lol

weary fossil
#

i try your code now

#

one moment

urban trout
wraith rapids
#

declare a method that takes a single parameter, EntitySpawnEvent, and annotate the declaration with @EventHandler

urban trout
#

mm ok

#

ty

quaint mantle
#

I need devs, admins and mods for my servers dm me if you are capable (Vouluntary job)

eternal oxide
#

?services

queen dragonBOT
wraith rapids
#

good luck getting anyone even remotely competent from this discord

ivory sleet
#

Lol

lost matrix
wraith rapids
#

what am i looking at

solemn shoal
#

thats looking pretty sweet

solemn shoal
lost matrix
wraith rapids
#

ah

#

yeah, looks about right

#

ish

lost matrix
#

I think i missed some weights. But that alright so far. I just didnt get it to work in O(log n) so its O(n) for now

solemn shoal
#

i mean if possible ill send RGB regardless

wraith rapids
#

doesn't adventure have that built in though

solemn shoal
#

adventure?

wraith rapids
#

the new ™ text formatting library

#

it's bundled in with paper now

#

but you can still use it on splögget if you depend on it as you would with anything else

solemn shoal
#

huh..

lost matrix
#

?paste

queen dragonBOT
lost matrix
wraith rapids
#

let's take a look see at adventure's impl

solemn shoal
#

@lost matrix wait

#

your implementation is 100% compatible with my RGBColor class LOL

#

if i got rid of the function taking the single int

wraith rapids
#

adventure looks like it's using hsv to calculate the distance rather than rgb

#

i'm not a color guy so i don't know how much of a difference that makes, if any

solemn shoal
#

it uses hue, saturation and brightness instead of red green and blue

wraith rapids
#

yes, i know that

quaint mantle
#

Some users are having the problem that the database.dB file is not generating, would there be any reason why ? Or should I just make a create db file méthode on startup

solemn shoal
#

@lost matrix

wraith rapids
#

couldn't you just have put that in a static block

#

anonymous initializers are haram

solemn shoal
#

its a lookup map

wraith rapids
#

yes, i know that

#

my gripe is with the way how it's being populated

solemn shoal
#

idk its smile's code

obtuse basin
#

Is there a way adding extra Permissions for Arguments in a Command?

solemn shoal
#

imagine if minecraft supported ANSI color syntax

olive lance
#

what changed in 1.16.5 that i cant connect to 1.16.3?

wraith rapids
#

the protocol version

#

in particular, the social interactions menu or whatever the hell it was called

solemn shoal
#

i think the social interaction menu is bs

eternal oxide
wraith rapids
#

the "i am a fragile snowflake and my mind will explode if I have to look at mean words on my screen" menu

unreal quartz
#

microsoft™️

wraith rapids
#

thankfully you can pretty much turn it off on the server side

solemn shoal
#

can you?

wraith rapids
#

yeah

#

since it relies on exact-match usernames and uuids

#

just have your chat plugin not send the sender uuid of a message

#

and if you have literally any chat formatting, it won't be blocked by the username filter either

solemn shoal
#

mmm

#

the messiest code in my plugin

#

anyways

wraith rapids
#

the username has to be like exactly <youSuckBalls>: youSuckBalls' message or whatever the vanilla default is

solemn shoal
#
Scan started!
Exception in thread "main" java.lang.NoClassDefFoundError: net/thearcanebrony/spigotav/FSUtil
        at net.thearcanebrony.spigotav.CLI.Scan(CLI.java:30)
        at net.thearcanebrony.spigotav.CLI.main(CLI.java:11)
Caused by: java.lang.ClassNotFoundException: net.thearcanebrony.spigotav.FSUtil
        at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:602)
        at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
        at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
        ... 2 more```
lost matrix
#

I would add bodies even if its only for one line. I hate those dangling statements.

quaint mantle
solemn shoal
#

why am i getting a classnotfound lol

#

recursively find all jars in a folder @quaint mantle

wraith rapids
#

only case where i don't use the curly fucks is if the if clause and the thing i'm running fit on the same line

solemn shoal
#

as can be seen by the function name

olive lance
#

what does hide matched names even do

lost matrix
wraith rapids
#

in the social interactions menu?

quaint mantle
wraith rapids
#

it tries to block the messages from the players with that name

#

but 90% of the time it doesn't work because the chat format has to be exactly vanilla

olive lance
#

i got a NPE running buildtools

#

jk

lost matrix
quaint mantle
wraith rapids
#

it only finds all files with a .jar file extension

lost matrix
solemn shoal
#

but i dont see how it could be causing an error?

quaint mantle
#

ohhh

solemn shoal
quaint mantle
wraith rapids
#

if you really want to be thorough you'll have to open up each file and see the first few bytes if it's a zip

solemn shoal
quaint mantle
#

in a folder, didnt know he wanted sub-dirs

solemn shoal
#

lol

#

if you specify recursive it calls itself for each directory

quaint mantle
#

seems slow

#

i feel like theres a method for this already

lost matrix
solemn shoal
#

how do you mean "a body"

wraith rapids
#

make it a 1 liner 👀

#

or add {}

#

anything else is haram

solemn shoal
#

nah

lost matrix
solemn shoal
#

there, fixed

lost matrix
wraith rapids
#

i'll burn your house down

solemn shoal
#

😂

olive lance
#

buildtools made my battery go from 50 to 10 real quick

quaint mantle
#

if u wanna use that, its optional i think it just does what you are doing

solemn shoal
#

intellij you ok?

#

oh wait nvm

#

its working fine

#

anyways

#

best way to check mc version?

#

i guess i should be using jsemver?

quaint mantle
#

you could use something like this

#

🤷🏿‍♂️

#

getBukkitVersion

unreal quartz
#

or,

version = Bukkit.getServer().getClass().getPackage().getName().replace(".", ",").split(",")[3];
``` works too
quaint mantle
#

eh

#

regex looks better

solemn shoal
#

well yeah, im already using getBukkitVersion but thats a string

quaint mantle
#

lmfao

#

is a string not what you want

solemn shoal
#

nah

unreal quartz
#

you're gonna have to parse it yourself then

solemn shoal
#

ill just jsemver

wraith rapids
#

do you have a question you want to ask

lost matrix
#

you dont want to filter but to sort. And then call findFirst() on the sorted stream

solemn shoal
#

ah yes

wraith rapids
#

yatopia 👀

solemn shoal
#

jsemver can parse the second one lol

minor garnet
#

calm down i'm getting confused, you mean to use a sorted method and them call findFirst() ??

solemn shoal
#

anyways ill check later

lost matrix
#
  public Optional<Entity> getClosest(final Location loc, final double radius) {
    final List<Entity> entities = Arrays.asList(loc.getChunk().getEntities());
    return entities.stream().min((e1, e2) -> (int) (e1.getLocation().distanceSquared(loc) - e2.getLocation().distanceSquared(loc)));
  }
quaint mantle
#

is there a method for getting the 2 corners of a chunk from .getChunk()?

wraith rapids
#

not directly

minor garnet
#

what would be the radius?

eternal oxide
#

Yes, Math

wraith rapids
#

but you can calculate them very easily

quaint mantle
wraith rapids
#

get the chunk coordinate with Chunk::getX and Y

#

left-shift by 4

#

that gets you the min corner

quaint mantle
#

so the .getChunk().getX() is the x corner?

#

or

wraith rapids
#

add 15 to x and z and 255 to y

#

and you get the max corner

quaint mantle
#

uhhh

wraith rapids
#

no, chunk::GetX is the chunk coordinate

#

a chunk that spans blocks from 16 -> 31 has a chunk coordinate of 1

#

a chunk that spans blocks from 0 -> 15 has a chunk coordinate of 0

lost matrix
# minor garnet what would be the radius?

The radius should be used for getting the entities in a radius instead of just getting the entities in a chunk.
Getting them in a chunk wont work in many occasions.

minor garnet
#

I do not know if you had decreased in the intention to solve the problem between a block being an entity of the chunk

#

oh right

quaint mantle
eternal oxide
#

<< 4

quaint mantle
#

what the fukc

lost matrix
eternal oxide
#

google bit shifting values in java

quaint mantle
wraith rapids
#

yes, that gets the minimum x border of the chunk

#

<< is kind of like multiplication

#

but not really

quaint mantle
#

okay

eternal oxide
#

Think binary and move all the digits left by 4 slots.

minor garnet
wraith rapids
#

inb4 what is binary

lost matrix
minor garnet
#

and i put a small value : Entity suc = getClosest(ping.add(0, -1.5, 0), 0.1).get(); ping is a location

quaint mantle
lost matrix
minor garnet
#

im using 1.12.2 api

chrome beacon
#

That's because the armorstand is inside the block

minor garnet
#

yes but

#

nvm

#

noo, wait

chrome beacon
#

Make the armor stand small and don't let it be inside a block

minor garnet
#

i put this on y

chrome beacon
#

Yeah I'm aware of what you're trying to do

minor garnet
#

in case if I made a small stand armor there would be a problem with the euler angle and also the items would be small

wraith rapids
#

muh angel

chrome beacon
#

Fine try using Dinnerbone armor stands

minor garnet
#

dont work

chrome beacon
#

I'm not even sure that works 🤷

minor garnet
#

i already tried it xd

minor garnet
#

I mean it would have to be as close as possible to where the player clicked

lost matrix
#

Then getting them in a chunk is really bad because a player could click on the border of one chunk.

minor garnet
#

eeh i'm not very good with streams

lost matrix
minor garnet
#

i need being updated

wraith rapids
#

real men use for loops anyway

lost matrix
# minor garnet i need being updated

Like this

  public Optional<Entity> getClosest(final Location loc, final double radius) {
    final Collection<Entity> entities = loc.getWorld().getNearbyEntities(loc, radius, radius, radius);
    double smallestDistance = radius + 1;
    Entity closest = null;
    for (final Entity entity : entities) {
      final double distance = entity.getLocation().distanceSquared(loc);
      if (distance < smallestDistance) {
        smallestDistance = distance;
        closest = entity;
      }
    }
    return Optional.ofNullable(closest);
  }
quaint mantle
#

would this be correct?
e.getEntity().getLocation().getChunk().getX()<<4 // gets x of minimum e.getEntity().getLocation().getChunk().getZ()<<4 // gets z of minimum

wraith rapids
#

yes

#

congratulations

quaint mantle
#

oh fuck

wraith rapids
#

you have copied and pasted your previous line

quaint mantle
#

lfmao

wraith rapids
#

and changed 1 character

quaint mantle
#

LMAO

#

i was confused ok

#

thanks

wraith rapids
#

to get the maximum, add 15

lost matrix
minor garnet
#

but cant do that condition in the stream and get ?

lost matrix
# quaint mantle would this be correct? `e.getEntity().getLocation().getChunk().getX()<<4 // get...

This is way cleaner than all those chained method calls:

    final Entity entity = event.getEntity();
    final Location entityLocation = entity.getLocation();
    final Chunk entityChunk = entityLocation.getChunk();
    final int chunkX = entityChunk.getX();
    final int chunkZ = entityChunk.getZ();
    final int minBlockX = chunkX << 4;
    final int minBlockZ = chunkZ << 4;
    final int maxBlockX = minBlockX + 15;
    final int maxBlockZ = minBlockX + 15;
eternal night
#

objective reality

wraith rapids
#

well, uh

#

pretty sure that has more self repetition than the direct call chains tbh

#

good job making it all final though

solemn shoal
#

What's the best way to set the xp merge radius in a plugin?

eternal oxide
#

7smile7 would final his final if he could

solemn shoal
#

Or disable it

quaint mantle
#

ty

lost matrix
wraith rapids
#

World probably has a method for setting it

#

bratwurst

#

that is a giant blob of repeated code

worldly ingot
#

No. It's a Spigot config option

solemn shoal
#

^

worldly ingot
#

Set the appropriate path

wraith rapids
#

isn't it configurable per-world though?

solemn shoal
#

I mean without changing the config

worldly ingot
#

Well you can adjust it but not save it, but it will still work in memory

wraith rapids
#

i remember it being in the world-settings

solemn shoal
#

Last i tried it didnt apply until you rebooted the server

worldly ingot
#

Maybe we cache the config there. I'd have to check

olive lance
#

how can i give someone night vision for less than 10s without it pulsing?

lost matrix
solemn shoal
#

Maybe i implemented it wrong

lost matrix
worldly ingot
#

no, looks like it is per-world and that's not exposed

solemn shoal
#

It is per world yeah

#

As it is in per world settings in the config

solemn shoal
#

Because its interfering with a thing i do in my retro features plugin

#

Or can i set it with reflection?

wraith rapids
#

what's the char length for a book again

#

256?

olive lance
#

and 3 free resources

solemn shoal
#

Once im at my pc ill check the spigot source

wraith rapids
#

ugh 256 characters is so narrow

#

how am I supposed to fit anything in it

olive lance
#

nvm I see that it takes a while to update. I just added two step

wraith rapids
#

no wait what the fuck that's the total number of characters

#

it's like 20 chars per row

#

yeah i'm not gonna be able to fit my fancy cui shit in it

#

how very sad

narrow berry
#

hello i have a problem with bungeecord, i can't go from server to server via npc

#

[20:46:34 INFO]: ---------------------{CommandNPC Error}---------------------
[20:46:34 INFO]: Topic
[20:46:34 INFO]: BungeeCord Command
[20:46:34 INFO]:
[20:46:34 INFO]: BungeeCord is disabled in config.yml, yet an NPC has the
[20:46:34 INFO]: command /server registered to it.
[20:46:34 INFO]:
[20:46:34 INFO]: Class: NPCListener Method: onClick(Player, NPC,
[20:46:34 INFO]: ClickType)
[20:46:34 INFO]:
[20:46:34 INFO]: ---------------------{CommandNPC Error}---------------------

solemn shoal
#

anyways enable bungeecord in config.yml

narrow berry
#

ok can you tell which setting is responsible for that?

solemn shoal
#

idk

#

i dont use commandnpc

#

if i were you i'd read the config

narrow berry
#

I'm reading now, but I don't see an option responsible for it

chrome beacon
#

99.9% sure you're not

solemn shoal
#

if, lets say, everything were public

#

((CraftServer) getServer()).getServer().worldServer.values().stream().findFirst().get().spigotConfig.expMerge

#

would this be a bad way?

#

ofcourse i wouldnt just get first world

kind coral
#

does minecraft server or either spigot save players inside some sort of storage? i am trying to remove a custom entity bound to a player like doing so. Tho i think it will throw a NPE when getting the player. how could i go around this if any of you knows?

eternal oxide
#

Are you editing files?

kind coral
#

ok so i have a playerdata, but i need the UUID to access that, so i don't know if Bukkit will throw null upon trying to get a offline player

eternal oxide
#

If you need to store data on a player use the PDC

kind coral
kind coral
#

im on 1.8.8 i don't think it exists. Persistent Data Container if i got it right

#

yeah

eternal oxide
#

Nope it won't

kind coral
#

so idk have you got any idea?

eternal oxide
#

You'll have to use NMS tags

#

I don;t do 1.8

wraith rapids
#

shoots himself in the foot
ouch! that hurt! help me

main dew
#
                    if (packet instanceof PacketPlayOutPlayerInfo) {
                        final Object a = Utils.getField(packet, "a");
                        final List<Object> b = (List<Object>) Utils.getField(packet, "b");
                        final Object playerInfoData = b.get(0);
                        final Object gameProfile = Utils.getField(playerInfoData, "d");
                        final String name = (String) Utils.getField(gameProfile, "name");
                        if (name != null) {
                            final Player pl = Bukkit.getPlayer(name);
                            if (pl != null) {
                                if (a.toString().equals("ADD_PLAYER")) {
                                    ((CraftPlayer) pl).getHandle().listName = CraftChatMessage.fromString(name)[0];
                                    final PacketPlayOutPlayerInfo nev = new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER, ((CraftPlayer) nev).getHandle());
                                    ((CraftPlayer) pl).getHandle().listName = CraftChatMessage.fromString(name)[0];
                                    super.write(context, nev, channelPromise);
                                    return;
                                }
                            }
                        }
                    }```
alpine urchin
#

whats up

main dew
#

I try translate this to ProtocolLib

alpine urchin
#

yeah?

main dew
#

but I have problem ;/

alpine urchin
#

whats the problem

main dew
#

idk how create new packet with constructor

#

PacketContainer playerInfo = new PacketContainer(PacketType.Play.Server.PLAYER_INFO);

#

I have but this is null

#

final PacketPlayOutPlayerInfo nev = new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER, ((CraftPlayer) nev).getHandle());

#

I want translate PacketPlayOutPlayerInfo to PacketContainer

#

@alpine urchin you have idea?

alpine urchin
#

hm

#

i can't remmeber how to use protocollib wrappers lmfao

#

they have a specific wrapper for that packet

buoyant epoch
kind coral
#

how could i make commands executed by my plugin silent

alpine urchin
#

silent?

toxic mesa
#

how do u mean silent

buoyant epoch
alpine urchin
#

@pure glacier he wants to use ProtocolLib

sharp bough
#

this is so dumb but why cant i put Main there?

public class RespawnEvent implements Listener {

    @EventHandler
    public void onRespawnEvent(PlayerRespawnEvent event) {
        System.out.println("test");
        Inventory inv = Bukkit.createInventory(null, 54, "test");

        Player player = event.getPlayer();


        BukkitScheduler scheduler = Bukkit.getServer().getScheduler();
        scheduler.scheduleSyncDelayedTask(Main, new Runnable() {
            @Override
            public void run() {
                Bukkit.getLogger().info("test1");
            }
        }, 2L);

    }
}
pure glacier
#

ah i see

#

nvm

sharp bough
#

in the delayed task

kind coral
buoyant epoch
#

Ex. A public static Main instance

kind coral
alpine urchin
#

#

hm

buoyant epoch
#

Then in onEnable instance = this @sharp bough

sharp bough
#

oh

buoyant epoch
#

Then make a getter for it.

sharp bough
#

i have this public static Main get(){
return instance;
}

#

i just have to add Main.get()

obtuse basin
#

which getconfig do I need to Import for Configs?

sharp bough
#

thanks that makes sense

alpine urchin
#

what command are you executing @kind coral `

#

just recreate the feature

buoyant epoch
kind coral
#

many commands from other plugins like essentials ezblocks etc. etc. etc.

sharp bough
#

instance = this;

#

private static Main instance;

#

yea

alpine urchin
sharp bough
#

on enable

kind coral
#

i need my plugin to not send message in the console when it executes thoose commands

alpine urchin
#

and you don't call Main.get() before setting it right

sharp bough
#

no

alpine urchin
#

with the bukkit api atleast

#

might be some hacky way to do it with some reflection

#

that i don't know of

buoyant epoch
#

Aekit let's u do it I believe.

sharp bough
#

does anyone know why when i replace the .jar from the target to the plugins folder my "replace" file does not popup anymore?

#

i get the message but i have to click the open files , click the message and then replace

buoyant epoch
#

Use a bash/batch script to build it, delete old jar and copy new jar.

sharp bough
#

i have on idea what a bash script is, i will google it later, thanks

alpine urchin
#

@kind coral which command are you executing? is it a spigot command or custom

#

cause the easiest solution would be to recreate the action

kind coral
alpine urchin
#

i see

kind coral
#

tho i really don't want to silent all my plugin it will be useless.

alpine urchin
#

maybe my boy, homeboy @odd gulch knows

#

benz basically he wants to use Bukkit to execute a command without having it be visible in the console.

#

do you have any idea

torn oyster
#

guys

#

why isnt this luckperms dependency working

#
        <dependency>
            <groupId>net.luckperms</groupId>
            <artifactId>api</artifactId>
            <version>5.3</version>
            <scope>provided</scope>
        </dependency>```
quiet ice
#

did you import the correct repo?

torn oyster
#

there isnt a repo listed anywhere

#

can u give the repo

quiet ice
novel hornet
#

Can anyone help me for some reason my plugin is showing up in my plugin list

quiet ice
#

It should work, not entirely sure what you messed up; did you try to rebuild your maven application?

torn oyster
#

ill send whole xml

#

?paste

queen dragonBOT
torn oyster
#

Cannot resolve net.luckperms:api:5.3

novel hornet
quiet ice
#

That is even less useless than the full error message

torn oyster
#

that is literally all it says

quiet ice
#

Does it not show which repos it searched?

torn oyster
#

oh wait i have offline mode on

#

lol

open vapor
#

can anyone help me with spawning in a structure (such as a bastion)? I know structureblockapi exists, but it can only spawn pieces of a bastion?

torn oyster
#

im very smart

quiet ice
#

🤨

quaint mantle
#

is there an event for entities looking at players?

vital ridge
#

Hey, ive never ever used getInstance as a way to access main class from other classes so I ran into this error which im rly not sure why it happened.
Code: https://pastebin.com/qHGerSTi
https://pastebin.com/s0gsrCpL
Error:
https://pastebin.com/eG9CDGgP
So as I understood my Main instance is null, which i dont understand how since I returned the main class. I've always accessed main class with constructors or some other methods so thats pretty new.

kind coral
#

Main.main = this; is after the registration of the enchantment

#

you should put it before, it can't access something that isn't defined yet.

#

you have your enchanting instruction and then the assignment of the main instance

#

@vital ridge

vital ridge
#

yeah saw it

#

Fixed it

#

Thanks

kind coral
#

nice to hear

#

no problem

vital ridge
#

just had to move it few lines up

kind coral
#

yep

vital ridge
#

Never used this way to get the main class

#

since constructors were always my practice

kind coral
#

use dependency injection then ( using constructor yes )

quaint mantle
sage swift
#

there probably isnt an EntityMoveEvent, but i guess you could check the rotation of nearby entities and set their direction away from the player?

sharp bough
#

whats the InventoryDragEvent ? if i cancel the inventory click event you cant drag right?

#

i tried shifting, ctrl click etc

#

if i cancel the inv click event then inv drag event doesnt run

glass sparrow
#

drag itemstack over 1 or more slots

sharp bough
#

yea, but to drag you have to click?

glass sparrow
#

if you're cancelling every possible click event sure, but that's probably not the way to go

#

always safe to check for drag event too

sharp bough
#

hm aight

wraith rapids
#

there's an entity move event on purpur

#

inventory click and inventory drag event are two separate events

#

if you move your mouse pointer even 1 pixel while holding LMB down, it fires a drag event

#

if it does not move at all, it fires a click event

#

the click event is not a prerequisite for the drag event

silver shuttle
#

Ummm I am using player.performCommand() to run a command to add a marker to dynmap but it doesnt let me do it saying it can only be run as a player. But player is a player

wraith rapids
#

why are you running a command to add a marker

silver shuttle
#

because i am testing something

wraith rapids
#

you should use the dynmap api to add the marker instead

silver shuttle
#

yes i know the api exists

#

i am testing it. why does it say its not a player?

wraith rapids
#

it could be something fucked with how bukkit handles that, would need to look into what dynmap does with commands for more details though

silver shuttle
#

is there an alternative?

#

without the api

wraith rapids
#

why

silver shuttle
#

is ther an alternative to performCommand

wraith rapids
#

why are you even testing something like that

silver shuttle
#

because some plugins dont have a good api

wraith rapids
#

firing commands to do shit is literally worse than not doing anything at all

silver shuttle
#

sometimes like ClickEvents there is no alternative

#

in clickable chat messages

wraith rapids
#

the alternative and the correct choice is to not do it at all

#

or perhaps better yet go bully the author

#

or just hooking against not-api internals of the plugin

silver shuttle
#

but I am asking

#

is there a performCommand similar alternative

sharp bough
#

does inv.addItem stack items if they are the same material?

ivory sleet
#

uh iirc no

silver shuttle
#

How does one work with API's like Dynmap API?

solemn shoal
#

you mean like, web apis?

silver shuttle
#

no just the api of Dynmap

#

to create markers for example

hollow arch
#

Hey hey. I'm wondering what would be an efficient way of counting up for everyone who is currently alive on the server? Doing a runnable and looping through all the online players seems really heavy on performance

novel hornet
#

I just finished coding my plugin and for some reason it's not showing up in my plugin list in game

hollow arch
#

!logs

ivory sleet
#

Server#getOnlinePlayers#size geri?

hollow arch
#

.logs

hollow arch
hollow arch
silver shuttle
hollow arch
#

That it'd reset whenever they die

silver shuttle
#

so you mean a timer for how long they have been alive?

hollow arch
#

@novel hornet your plugin.yml is invalid, can you send that?

hollow arch
silver shuttle
hollow arch
#

I know

#

But I want to modify this score. For example if they are doing something, it wouldn't go up

sharp bough
wraith rapids
#

you import the API as a dependency

#

either via your dependency manager of choice, like Maven

#

or through your IDE

silver shuttle
hollow arch
#

Just doing random small projects?

hollow arch
novel hornet
# hollow arch <@!611552754481102849> your plugin.yml is invalid, can you send that?

name:PantsThatPoopTnt
version: 1.0
author: mrpiedot
main: me.mrpiedot.PantsThatPoopTnt.Main
description:||Cock and ball torture (CBT), penis torture or dick torture, is a sexual activity involving application of pain or constriction to the penis or testicles. This may involve directly painful activities, such as genital piercing, wax play, genital spanking, squeezing, ball-busting, genital flogging, urethral play, tickle torture, erotic electrostimulation, kneeing or kicking.[1] The recipient of such activities may receive direct physical pleasure via masochism, or emotional pleasure through erotic humiliation, or knowledge that the play is pleasing to a sadistic dominant. Many of these practices carry significant health risks||

hollow arch
#

I don't watch such

wispy fossil
hollow arch
#

what the fuck

novel hornet
wraith rapids
#

lol

wispy fossil
#

not gonna lie
every config should have that

hollow arch
#

give a space after 'name'

novel hornet
#

ohhhh

#

ok

wraith rapids
#

yeah that isn't valid yaml

novel hornet
#

im dumb

wraith rapids
#

yaml needs spaces after :

glass sparrow
#

how much for the plugin

wispy fossil
#

yaml never asked for this

solemn shoal
#

hmm

hollow arch
#

lmao

solemn shoal
#

i did a thing

wispy fossil
#

honestly yeah
survival mods tend to base around the most developed and documented parts of spigot
so making a "acid rain" or "friendly mobs are evil/evil mobs are friendly" plugin is a great first challenge

sage swift
#

a plugin where you cant log on to your server

#

ez

wispy fossil
#

i dont need a plugin for that

#

💃

solemn shoal
#

4500-4600 orbs being picked up in mere seconds

wispy fossil
#

satisfaction at 2 frames

#

the best practice is to just directly copy each of his videos and monetize 💰

solemn shoal
#

yeah pc cant handle 4k orbs lol

wispy fossil
#

yeah do that lmao

#

theyre pretty fun to make

#

especially with a group of friends to play them with

silver shuttle
#

Does anyone here know how to use the dynmap api?

wraith rapids
#

they have documentation

silver shuttle
wispy fossil
#

i started spigot some years ago and only recently am coming back 😄
in my effort to relearn what I lost I made a dozen or so just really simple plugins

so like Manhunt, acid rain, server sleeping, all sorts of challenges from way back when
Bedwars is a fun one too, so is Capture the Flag but those are a bit bigger in scope.

I used documentation to remind myself how many of the core bits and pieces of spigot work, from there it's just freerunning.
There's plenty of wiki out there to read too, stuff on commands , all the way up to world gen

wraith rapids
#

here's some shit tier resource on it i guess

#

alternatively look at the source

silver shuttle
#

as if I was in any way talented enough to get any info from that

wraith rapids
#

it's pretty straight forward

novel hornet
#

for some reason crouch events count your first crouch as a crouch and when you stand up as a crouch how do fix that

wispy fossil
wraith rapids
#

there is no "crouch event"

novel hornet
#

yes

#

that what mean

wraith rapids
#

there is only crouch toggle event

#

toggle means on/off

#

it fires if it turns on

wispy fossil
#

did you try using the #isSneaking()?

wraith rapids
#

it fires if it turns off

wispy fossil
#

from Player

wraith rapids
#

that's what toggle means

novel hornet
#

oh

opaque pendant
#

hi can anyone of you help i want a player to be charged on his death let me if any plugin can do that or u know how to

wispy fossil
#

yea so to check if the toggle is true
Try grabbing the attribute from the player

wraith rapids
#

you might have to invert the condition

wraith rapids
#

most events fire before the actual change occurs

opaque pendant
wraith rapids
#

so it's possible that the player isn't sneaking during the event yet

wispy fossil
#

oh right
is there only a toggle for sneak event?

wraith rapids
#

yeah

eternal oxide
#

Sneak event is not spigot

wraith rapids
#

use PlayerToggleSneakEvent::isSneaking

#

that has the updated sneaking state

opaque pendant
#

where it take the half

#

of your money

wispy fossil
# opaque pendant yes

I don't know how to deal with economy so I wouldn't be able to help you, but if you can hook into whatever economy plugin you use and call some removeBalance() (I've never used it so I don't know), from the PlayerDeathEvent, that would maybe do the trick?

opaque pendant
#

ok ill check the config

wraith rapids
#

economy things should be done through vault

#

look up a guide on how to hook into vault

opaque pendant
#

vault doesnt have a config

wraith rapids
#

you don't need vault to have a config

#

you need an api

#

vault is an api

wispy fossil
#

oh vault that's what its called

opaque pendant
#

yeah

wraith rapids
#

if you want to charge a player, you'll want to get the vault economy api and call the appropriate method

#

probably on player death event

opaque pendant
hollow arch
#

Hey again - theoretically this updates every 1 second but this doesn't reach right event at all. It's quite late, am I not seeing something obvious?

    @EventHandler
    public void onPlayerStatisticIncrement(PlayerStatisticIncrementEvent e){
        Bukkit.broadcastMessage("fired");
        if (e.getStatistic() != Statistic.TIME_SINCE_DEATH) return;
        Bukkit.broadcastMessage("right event");
    } 
wraith rapids
#

should update every tick

#

did you register it and whatnot? does it fire at all?

hollow arch
#

oh even cancelling the event doesn't stop it from happening

#

It does

#

That's quite unfortunate, this would have been so much easier

quaint mantle
#

im stuck on this. ive set playername to item on its displayname which prints out "in red somehow" but when using it on a playerobj its null any reason what i did wrong here ?

wraith rapids
#

are you the guy who we told to use the pdc

quaint mantle
#

yea looked into that one, did not figure out how to use it"yet"

wraith rapids
#

String uuidAsString = item.getItemMeta().getPersitentDataContainer().get(myKey, PersistentDataType.STRING);

#

UUID uuid = UUID.fromString(uuidAsString);

quaint mantle
#

Since playername is stored on its displayname i did not think it would be a bad way to get its name from that

wraith rapids
#

Player player = Bukkit.getPlayer(uuid);

#

getting players by name is kind of haram these days, what with players being able to change their names

quaint mantle
#

is there any decent info ? would like to understand prc bit better

quaint mantle
#

thanks!

sage swift
#

oh no he's using the inventoryview's name to find his inventory

wraith rapids
#

haram alert

hollow arch
#

nvm ^^

novel hornet
#

could armor work with ItemStack

eternal oxide
#

what?

novel hornet
#

is armor considered a item is what i'm asking

eternal oxide
#

Anything in your Inventory is an ItemStack

#

Armor slots are a part of the Player Inventory

wraith rapids
#

new ItemStack(Material.DIAMOND_CHESTPLATE) boom armor

dusk flicker
#

anyone have a good way to make a swear filter that blocks out the found with *'s... I cant seem to find a good efficient way to do it...

wraith rapids
#

regex and replaceall

eternal oxide
#

or StringUtils

wraith rapids
#

message.replaceall("(fuck|you|cunt)", "***")

eternal oxide
#

StringUtils.replaceEach(text, searchList, replacementList)

wraith rapids
#

if you want to make the *** have as many letters as the filtered word, you'll have to look into Matcher and either the java 9 stringbuilder helpers or just plain for loops

eternal oxide
#

StringUtils is Apache Commons and its shaded in Spigot

wraith rapids
#

and like all things shaded in spigot is probably 6 years out of date

eternal night
#

👌

final fog
#

How often are databases used when coding plugins?

wraith rapids
#

whenever necessary

#

more or less

#

a database is a tool and each tool has a job

#

some people suffer from trying to use the wrong tools for the wrong jobs

final fog
#

I've never used them

wraith rapids
#

and some stick with shit like the fucking bukkit config api where a database would be better

final fog
#

I use YamlConfiguration

eternal night
#

json files to store huge data OP kekw

final fog
#

idk databases

wraith rapids
#

yeah, you belong to the latter category

final fog
#

I'd love to learn them, pretty sure I'd need it for a JDA bot

wraith rapids
#

the main thing to keep in mind with a database is that a database might not be on the same machine and so queries to it might be slow

#

so unless you're 100% sure you're not working on like a local in-memory database, you want to take that into account

#

which means not doing queries on the main server thread

#

you don't want the server to shit bricks and crash when the control connection times out for 30 seconds

ancient plank
#

Or do I? kekwhyper

waxen plinth
#

Even if a database is on the same machine queries can be slow

wraith rapids
#

yeah, needs to be an in-memory database at minimum

waxen plinth
#

SQL isn't in-memory is it?

#

Mongo and redis are I believe

wraith rapids
#

sqlite has an option to be in-memory iirc

waxen plinth
#

👀

#

I didn't know that

#

SQLite is pretty damn performant, I know that much

#

It's about as fast as you'll get with SQL of any form

#

Still not something you wanna be querying multiple times per second on the main thread

#

But I have written plugins that use SQLite sync on servers with hundreds of players without issue, so I can vouch for it

wraith rapids
#

yeah you kind of lose a large fraction of the benefits of having a db if you restrict yourself to an in-memory db on the same system

waxen plinth
#

This is true

#

I wasn't aware that SQLite had ways of being in-memory, I've always used it as just a file

#

And that has served my purposes

#

In general I'd avoid using remote databases on game servers where you can though

eternal night
#

I mean, just always code as if you were coding against a database located in the deep jungles of brazil and allow users to just plug in an in-memory alternative to go lightspeed

wraith rapids
#

so your db facing code should still be written with the worst case scenario of it being on a fucking tape drive in china in mind

waxen plinth
#

If you have to, you're probably gonna want in-memory databases to act as caches on other game servers that are querying it

vast dome
#

is there a way to give an armorstand velocity but without gravity?

wraith rapids
#

i'm pretty sure disabling gravity completely disables all velocity on an entity

vast dome
#

i googled and 2 solutions both included using nms and overriding this function

public void g(float f, float f1) {
    if (!hasGravity()) { // hasGravity() actually means hasNoGravity(), probably a mistake in deobfuscating.
        super.g(f, f1);
    } else {
        move(motX, motY, motZ); // Give them some velocity anyways ;3
    }
}```
but i dont know how to apply this
dusty herald
#

I normally set up my SQLites to be in sync with mysql on restarts and what not DogKek probably useless tho

wraith rapids
#

i just read raw bytes from disk

#

fight me

dusty herald
south onyx
#

i have a question

@EventHandler
    public void onInteract(PlayerInteractEvent e) {
        if (e.getItem().getType() == Material.COMPASS) {
            System.out.println("hi");
        }

when i check for a compass
the if statement line returns null
but
if i check for something else
it works perfectly fine
https://pastebin.com/r4Pd3w23
thats the error

wraith rapids
#

the held item may be null

south onyx
#

no but

#

i tried clicking with a compass in my hand

#

how could it be null

wraith rapids
#

two interact events are fired for each click

#

one for the off hand

eternal oxide
#

you are not testign the item in your hand

wraith rapids
#

a second one for the main hand

south onyx
#

so i should use player.getItemInMainHand?

wraith rapids
#

you should check if the event was fired for the main hand

#

and return if not

south onyx
#

oh

#

ok

#

how do i do that?

wraith rapids
#

i don't remember

eternal oxide
#

use hasItem() before you test getItem()

south onyx
#

ok

wraith rapids
#

PlayerInteractEvent::getHand

upper vale
#

how can i force someone to sneak in order for them to go under like a 1.5 block high thing

eternal oxide
#

^ that too

wraith rapids
#

otherwise, you will notice that your logic will fire twice with each click

#

and if the player holds a compass in both hands, all of your shit runs twice

south onyx
#

ok

south onyx
wraith rapids
#

then, uh

#

there's no pretty solution

eternal oxide
#

then just test hasItem and getItem

south onyx
#

ok

eternal oxide
#

or

wraith rapids
#

you'll have to like mark the player for 1 tick

#

otherwise, if they hold a compass in both hands, your code runs twice

eternal oxide
#

set a lastFired Long. so you can check that value and only run your code if its not fired for 1 second.

south onyx
#
if (e.getHand() == EquipmentSlot.HAND) {
            
        } else if (e.getHand() == EquipmentSlot.OFF_HAND) {
            
        }
wraith rapids
#

or i guess you could check if the event was fired for the off hand, and return if the player has a compass in the main hand

#

kind of nasty as well but that's bukkit

eternal oxide
#

if you want to be able to use a compass in either hand you can;t check the Hand

south onyx
#

ok

#

ill just do the main then

#

wait

#

i have one question

#

what will e.getItem() return if a player clicks and they have something in both their main and off hands?

wraith rapids
#

it returns the item in the hand the event was fired for

#

the item in the main hand for the first event

south onyx
#

oh ok

wraith rapids
#

the item in the off hand for the second event

south onyx
#

so the event will run twice

wraith rapids
#

yes

south onyx
#

once for each hand

#

ohh ok

#

i mean thats fine for my plugin, idc

#

but whats that have to do with the compass thing

#

it returns null

eternal oxide
#
Long triggered = System.currentTimeMillis();

event {
if (e.hasItem() && e.getItem().getType() == Material.COMPASS) {
  if (System.currentTimeMillis() > triggered + 1000) {
    triggered = System.currentTimeMillis();
    //do whatever here```
wraith rapids
#

your other hand is probably empty

south onyx
#

yes

#

ohh ok

wraith rapids
#

your other hand's content is null

south onyx
#

thats why

#

ok thx

#

so ill check if e.getItem is not null

#

that way when it sees the off hand is null it wont run

dusty herald
#

check if it's air*

south onyx
#

ok

dusty herald
#

air is nasty

wraith rapids
#

and check if it's null

dusty herald
#

yes that too

wraith rapids
#

you never know which it is with bukkit

#

it could be null, or it could be air

dusty herald
#

chaos

eternal oxide
#

The code above will work for either hand and you can set how long before it will work again

upper vale
#

i dont think hand ever returns null?

wraith rapids
#

it might not

eternal oxide
#

so it will only work on the hand with a compass and then ignore the other hand

wraith rapids
#

but best practice when working with inventories and anything related is to check both

south onyx
#
if (e.getItem().getType() == Material.AIR && e.getItem() == null) {
            return;
        }
#

yes

#

ok

wraith rapids
#

even the fucking nullability annotations are wrong from time to time

#

check null first

south onyx
#

k

wraith rapids
#

the order is important

#

because if e.getItem() is null

dusty herald
#

and make it so it's not bkth

#

both, instead either

wraith rapids
#

e.getItem().getType() will explode

upper vale
#

yeah i mean this doesnt make sense lol

south onyx
#

oh ok

upper vale
#

why is set nullable

#

does it just convert to air

south onyx
#

ill use e.getmaterial

dusty herald
#

check the craftbukit source 🤷‍♂️

#

and AIR throws NPE often

#

exp when you try to do things with it

sage swift
#

and make sure you use or not and operator

merry turret
#

hi! i'm a new developer

#

if (c.getBlockInventory().getHolder() instanceof DoubleChestInventory) I'm trying to check if a clicked chest is double or not, this method doesn't seem to be working. c is a Chest.

wraith rapids
#

try the instanceof on the block inventory itself

#

getHolder is most likely an InventoryHolder

#

which is different from an Inventory; it's the thing that holds the Inventory

south onyx
#

getting an error there

#
if (Bukkit.getOnlinePlayers().toString().contains(args[i])) {
                                    stalkers.add(Bukkit.getPlayer(args[i]).getUniqueId());
                                    Main.main().tracker = new ItemStack(Material.COMPASS);
                                    Bukkit.getPlayer(args[1]).getInventory().addItem(Main.main().tracker);
                                } else {
                                    invalidPlayers.add(ChatColor.RED + args[i]);
                                }
#

line 44 is where i give the player args 1 the itemstack tracker

merry turret
wraith rapids
#

args[1] is not a valid player name

south onyx
#

its a string

wraith rapids
#

so Bukkit.getPlayer(args[1]) returns null

south onyx
#

oh

wraith rapids
#

and .getInventory throws a null pointer exception

south onyx
#

ok

wraith rapids
#

because the reference points to null

#

null check your shit

south onyx
#

but ik that args 1 is a valid player

wraith rapids
#

well

#

Bukkit.getPlayer disagrees

south onyx
#

ok

#

but

#

how come im not getting an error when im adding the players uuid to a list?

wraith rapids
#

the player reference whose uuid you're adding to a list isn't null

south onyx
#

oh ok

upper vale
#

can i force a player to crouch?

south onyx
#

@wraith rapids

#

how do i make it not null?

wraith rapids
#

you put a player in it

south onyx
#

can i cast it to a player?

upper vale
#

what

#

cast what to a player?

south onyx
#

basically

wraith rapids
#

you can cast it yes

south onyx
#

im doing Bukkit.getPlayer(args[1])

#

ok

wraith rapids
#

but it will still be null

south onyx
#

oh

south onyx
wraith rapids
#

if Bukkit.getPlayer(args[1]) returns null, that means bukkit did not find a player for that name

south onyx
#

oh

#

but i checked if it is a valid player

wraith rapids
#

well

#

Bukkit.getPlayer disagrees

south onyx
#

if (Bukkit.getOnlinePlayers().toString().contains(args[i]))

#

well

#

then this if statement has to be wrong right?

wraith rapids
#

"my player variable is null"
and
"my box is empty"
are the same

#

if you get an empty box

#

the only way to make it not empty

#

is to put something in it

#

you can't make an empty box have something in it by twisting it around or shaking it or bouncing around with it

#

you can't make a null reference have a value by casting it or renaming it or sending it to the moon

#

null is null

#

empty is empty

#

also you are checking if the list contains args[i] and not args[1]

south onyx
#

oh

#

ohhhhhh ik what i did wrong

#

im supposed to do Bukkit.getPlayer(args[i])

#

k it works now

wraith rapids
#

also that is not a good way of checking if a player name is valid

south onyx
#

how do i then

wraith rapids
#

Player player = Bukkit.getPlayer(name);
if (player == null)

#

if the player name is not valid, bukkit returns null

#

if it is valid, it returns the player

south onyx
#

oh yeah

#

that is true

merry turret
#
                        for (ItemStack slot : c.getInventory().getContents())
                        {
                            if (slot.getType() == Material.AIR)
                            {
                                spaceNeeded -= i.getMaxStackSize();
                            }
                        }```
#

This code causes weird exceptions (null pointer i think?). what do? (i = ItemStack, c = Chest)

young knoll
#

slot may be null

#

Spigot isn’t consistent with null vs Material.AIR

merry turret
#

changing it to if (slot.getType() == null) still causes null pointer exception

young knoll
#

Because slot is null

#

Not slot.getType

merry turret
#

ohh

#

thanks, I'm a doofus

lilac dagger
#

sad spigot noises

#

no default itemstack instead of null

sage swift
#

easy solution

#
Bukkit.getScheduler().runTaskTimer(plugin, () -> {
  for (Player player : Bukkit.getOnlinePlayers()) {
    for (ItemStack item : player.getInventory()) {
      if (item == null) item = new ItemStack(Material.AIR);
    }
  }
}, 0, 1);```
#

(this is a very good idea and will not hinder performance in any way)

drowsy helm
#

doesn't that default back to null

patent ice
lilac dagger
#

also

#

what happens when you right click on interact an empty slot

#

?

#

i bet it's null 🤔

quiet ice
#

Easy solution: fork spigot and solve the issue there

lilac dagger
#

it's a sad overseeing

#

i'm pretty sure 1/100 plugins will not preemptively check for null

#

and get their plugin harshly screwed

drowsy helm
#

easier solution: write your code to work with null values 🤔 🤔

lilac dagger
#

of course

#

but still

#

it'll slow you down at the start

kind coral
#

i don't understand if it will throw null if the key and value don't exist.

quiet ice
#

not entirely sure what you mean

torn oyster
#

hey

#

how would i make a plugin

#

that puts people in the lobby

#

if they get kicked from a server

#

cuz if i restart survival

#

they get kicked

#

instead of going to the lobby

#
    @EventHandler
    public void kick(ServerKickEvent e) {
        ProxiedPlayer p = e.getPlayer();
        
        if (!e.getKickedFrom().getName().equals("lobby1")) {
            p.connect(GlobalMessage.getPlugin().getProxy().getServerInfo("lobby1"));
            p.sendMessage(ChatColor.RED + "You have been kicked from " + e.getKickedFrom().getName() + " for reason: " + e.getKickReasonComponent()[0]);
        }
    }```
#

i have this so far

drowsy helm
#

do it on the on disable method

torn oyster
#

what

#

this is a bungee plugin

drowsy helm
#

ah for bungee

dusty herald
#

I suggest having something that overrides the spigot restart / stop command and sends players to lobby and then restarting the server

#

that's what I do and it works very very well

#

and this is built for spigot^

rotund pond
#

Hello !
I'm messing around with little things to pass the time, and I'm trying to make a system that allows you to choose a command in the config, but I have a problem ...
How to do ?
I tried to get a string in the config and put it in the line "getCommand ()" etc but I have a small problem: the plugin does not recognize the command if it is modified because of the plugin.yml file. ..
How do you go about fixing this?
Thank you for your time.

crude charm
dusty herald
crude charm
#

It other good stuff

lime mortar
#

Hey anyone here who has a good Update Notifier script? The one i use doesn't work.

dusty herald
#

Just use JSON output from the api..?

#

example

crude charm
#

Ok but he should probably use helper anyway

#

It’s really good

lime mortar
dusty herald
#

i am new to java too

crude charm
#

Lie

lime mortar
dusty herald
#
try (Scanner scanner = new Scanner(new URL(url).openStream())) {
                version = new gson().FromJson(scanner.nextLine(), JsonElement.class).getAsJsonObject().get("current_version").getAsDouble();
                scanner.Close();
            } catch (IOException ignored) { }```
lime mortar
crude charm