#help-development

1 messages ยท Page 1425 of 1

drowsy helm
#

and

#
if (!(event.getWhoClicked() instanceof Player)){
            return;
        }```
#

will always be false

#

only players can click inventories

fiery inlet
#

it has not been satisfied

drowsy helm
#

means the title isn't exactly that

fiery inlet
#

ahh 2 sec lemme try smth else

#

i forgot colors

drowsy helm
#

best practice is to not match just name

#

keep a cache of inventories and handle it with some sort of manager

fiery inlet
#

still doesnt work xd

drowsy helm
#

just dont match title it's bad practice

#

keep a cache and match it

fiery inlet
#

i dont know what that means

drowsy helm
#

have a manager class that keeps track of all custom inventories made

#

then if that list contains the current inventory, it means it's custom

fiery inlet
#

i started on spigot plugins about 3 hours ago

#

i know what u mean

#

but not how to do it

drowsy helm
#

new to java aswell?

fiery inlet
#

yup

drowsy helm
#

gotcha

#

yeah that might be a bit complicated

#

you can strip colours on the title and then check if its the same

#

ChatColor.stripColors(string) I believe

fiery inlet
#

ima try

#

cant i just broadcast the name of the gui

#

yeah didnt work either

#

weird

drowsy helm
#

can i see your if statement

fiery inlet
#

if (event.getInventory().getTitle().equals(ChatColor.stripColor("(GUI)"))){

#

mb it needs getWhoClicked

wraith rapids
#

god no

fiery inlet
#

ok

drowsy helm
#

They're new to java, I don't wanna overwhelm them with other stuff

wraith rapids
#

don't use inventory names to identify inventories

fiery inlet
#

men

#

then come with different way

wraith rapids
#

a player renames a chest and they can change the inventory title all they want

#

== the inventory/holder instance

fiery inlet
#

its a gui

wraith rapids
#

a gui is an inventory

fiery inlet
#

ok then say how else

drowsy helm
#

yeah players can change a chest to have the same name

#

thats why it's bad practice

wraith rapids
#

== the inventory/holder instance

#

that is how else

#

already did twice

fiery inlet
#

men that makes no sense

wraith rapids
#

== compares object identity

#

every inventory is an object

#

check that the object that is being looked at is the specific inventory you want

drowsy helm
#
String title = ChatColor.stripColor(event.getInventory().getTitle());
if (title.equals("(GUI)")){

}```
#

that would work

wraith rapids
#

private final Inventory myGui = Bukkit.constructInventory(...)

and then if (e.getClickedInventory() == myGui) {

fiery inlet
#

to see output

drowsy helm
#

if you want yeah

#

Bukkit.broadcastMessage(string);

#

i just use System.out.println() to debug though

#

quick n dirty

fiery inlet
#

dahell

#

its the event

#

its wrong event or some shit

#

public void onClick(InventoryClickEvent event)

drowsy helm
#

why do you think that

#

has it been registered

fiery inlet
#

cuz i put the broadcast right after

#

and nothing happened

wraith rapids
#

did you register the event listener

drowsy helm
#

oh

#

you have no @EventHandler

#

annotation

fiery inlet
#

in plugin.yml?

#

oh

#

2sec

#

ima do that

drowsy helm
#
@EventHandler
public void onClick(InventoryClickEvent event){
//stuff
}```
fiery inlet
#

yeah ik

wraith rapids
#

Bukkit.getPluginManager().registerEvents(listener, plugin)

#

or plugin, listener, idr

fiery inlet
#

so thats why nothings been working

drowsy helm
#

lmao

fiery inlet
#

anah

#

it works

#

xdf

#

fuck

drowsy helm
#

dw i do the same shit all the time lmao

fiery inlet
fiery inlet
#
ItemStack item = new ItemStack(Material.STAINED_GLASS_PANE, 1, DyeColor.WHITE);

Error: no suitable constructor found for itemstack

ivory sleet
#

(byte)0

fiery inlet
#

wat

fiery inlet
sand vector
#
factions:
  names:
    tester:
      leader: TheRifty
    tester1:
      leader: TheRifty
    
#

Is there any way of getting rid of tester rather than setting it to null?

ivory sleet
#

Setting it to null should get rid of it?

wraith rapids
#

it does

#

bukkit config api doesn't write null values for dictionaries

#

i'm actually not sure how it deals with null values in the backing yaml file

#

as in whether keys with null values would show up in getKeys and whatnot

ivory sleet
#

Yeah it lacks of certain things clearly

sand vector
#

setting it to null give me this ```

factions:
  names:
    tester:
    tester1:
      leader: TheRifty
    
wraith rapids
#

it doesn't

#

that isn't even valid yaml

quaint scarab
#

Hello, i want to create a AirDrop plugin and i have some pb for create my Class DropManager

sand vector
#

oh, I was messing with wrong code :/ Sorry for the inconvenience

quaint scarab
#

It's betetr to put my code in a throwbin or i can put here ?

wraith rapids
#

on some paste site ideally

#

discord code formatting is cancer

quaint scarab
#

Ok ok i write my code and i put ^^

#

My Object Drop

#

My manager

#

Idk if it's correct

#

And i want to spawn a chest at the Drop location

#

I have already write a "code" for spawn a chest at a random Loc but i didn't used the OOP

subtle vector
#

why doesnt this if statment work even though i am holding that item if(whoHit.getInventory().getItemInMainHand().equals(item.item)

hexed orbit
#

Hello guys, does anyone know if there is a possibility to add durability to an item that is not breakable, for example: Stick

wraith rapids
#

i don't remember if that's supported

#

you're probably gonna get a missing texture if nothing else

hexed orbit
wraith rapids
#

no

opal juniper
#

No

wraith rapids
#

best case scenario is that the item is going to become a purple/black square to indicate a missing texture

#

the other scenario is that nothing happens

quaint scarab
#

ItemStack itemStack = new ItemStack(YOUR.ITEM);
ItemMeta itemMeta = itemStack.getItemMeta();
itemMeta.spigot().setUnbreakable(true);
itemStack.setItemMeta(itemMeta);

#

"spigot()" i think u can removed this

#

But the best way is the itemBuilder

subtle vector
#

is there a correct way to see if an item is an certain item like comparing the item in ur hang is an custom made item

quaint scarab
wraith rapids
#

yes

#

insert a tag into the PDC of the item

#

and check the tag to see whether it's your custom item

gaunt eagle
#

When the player wins the game, they need to be teleported to the lobby, but that doesn't happen. Can anybody help me?

#

I could not see any mistake

wraith rapids
#

first guess is that players is empty

#

stick it into a debugger or add some sysouts

gaunt eagle
wraith rapids
#

the world is null

#

the world of your location is null

#

nullcheck your Bukkit.getWorld result

#

you are reading the String at lobby-spawn instead of lobby-spawn.world

hexed orbit
wraith rapids
#

it is not

#

Location is ConfigurationSerializable; you can just set(path, location) and getSerializable(path, Location.class)

#

no need to serialize and deserialize it by hand

gaunt eagle
#

sorry -_- problem fixed xD

quaint scarab
wraith rapids
#

does not mention adding durability bars to non-damageable items by half a word

cobalt blaze
#

You can't

#

You can use resource packs with metadata to simulate it

#

But you can't add a durability bar to an item that's unbreakable

fiery inlet
#
Bukkit.broadcastMessage(event.getCurrentItem());

Why doesn't this work? Any way to broadcast clicked item?

java: incompatible types: org.bukkit.inventory.ItemStack cannot be converted to java.lang.String

wraith rapids
#

ItemStack is not a string

fiery inlet
#

yeah i know that

#

but is there a workaround

wraith rapids
#

the method expects a string

#

you can try calling toString on the itemstack

#

but it may or may not give you human readable text

fiery inlet
#

no errors

#

lemme try

#

lol thats weird

#
if (title.equals("(GUI)")){
            player.sendMessage("Works!");
            event.setCancelled(true);
            Bukkit.broadcastMessage(event.getCurrentItem().toString());
            if (event.getCurrentItem().equals(Material.RED_ROSE)){
                Bukkit.broadcastMessage("Healed");
                player.setHealth(12.0);
            }
            return;```
#

so checking if its a rose

#

doesnt work

wraith rapids
#

an ItemStack will never be equals to a Material

cobalt blaze
#

You aren't checking the material

wraith rapids
#

get the getType of the ItemStack

#

that will return a Material

#

which you can then compare to the other Material

fiery inlet
#

gotcha

#

works

#

legend

gaunt eagle
#

These two work exactly the same right?

cobalt blaze
#

Yeah

gaunt eagle
#

thx xd

wraith rapids
#

not the right channel

heavy pasture
wraith rapids
#

yes

heavy pasture
#

thanks

pearl hollow
#

How do I get the blocks that are next to each other (like veins or logs of a tree)

wraith rapids
#

check the neighboring blocks, add them to a queue if they are of the same type, and then do the same for the next block in the queue

#

rinse and repeat until the queue is empty

pearl hollow
#

how do i check the neighboring blocks

wraith rapids
#

add +-1 to the coordinates of the block

#

or Block::getRelative

hexed orbit
#

Hello guys, do you know any way to increase the speed of breaking a block, without using Haste? for example: I would like to break a stone faster using a stick.

sage swift
#

any idea why setting block type to concrete powder with water next to it does not update the powder? is there any way to apply physics?
getState#update does not work, nor does Block#setType(Material, true)

wraith rapids
#

spawn some fallingsand there manually :fingerguns:

wispy monolith
#

Why does my server give me an exception when I try to run a plugin that I made, the error is:

Could not pass event <EventName> to <MainClassName/PluginName> v1.0
#

or when I kill someone on the server

wraith rapids
#

because an exception arose while trying to pass eventname to your plugin

#

as for what happened or why, literally impossible to tell without the actual exception

wispy monolith
#

So what should I do?

wraith rapids
#

when talking about exceptions, 100% of the information is in the stack trace

#

if you don't include the full stack trace of an exception, no-one can help you

#

the stack trace details the exact position in the execution of your code where the exception was thrown, the type of exception thrown, and usually an exception message

wispy monolith
#

!paste

#

?paste

queen dragonBOT
wraith rapids
#

IllegalArgumentException: bound must be positive

#

(FunnyDeathMessagesEvents.java:26)

wispy monolith
#

yeah

wraith rapids
#

Random.nextInt

wispy monolith
#

this like is

wraith rapids
#

you are trying to call random.nextInt on line 26 of that class

wispy monolith
#

String random = list.get(randomizer.nextInt(list.size()));

wraith rapids
#

but one of the bounds is negative

#

or zero

sage swift
#

the size is 0

wispy monolith
#

sorry I just forgot to add a space after the - in config file list

#

I feel stupid af

wispy fossil
#

lol all g

wraith rapids
#

reading the error usually helps

#

they don't lie

wispy monolith
#

Can u all pls forget about What I asked

#

I feel shame

weary summit
#

Help! I'm stuck!
I'm getting this errors on my server

Could not load 'plugins/SCFAlogin.jar' in folder 'plugins'
 org.bukkit.plugin.InvalidDescriptionException: Invalid plugin.yml

But the plugin.yml is valid and included(i looked into the jar file). The jar works on my test server but not on my real one

wispy monolith
#

show ur plugin.yml

weary summit
#

main: me.SCFA.login.SCFAlogin
name: SCFAlogin
version: 2.1
author: SoicBR
api-version: 1.12

commands:
forcelogin:
register:
registrar:
login:
logar:
changepassword:
mudarsenha:

wispy monolith
wraith rapids
#

that isn't valid yaml

#

yaml requires every key to be associated with a value

#

forcelogin: is a key without a value

#

so are the other commands

wispy monolith
quaint mantle
#

i do it

wraith rapids
#

still not valid yaml

sullen marlin
#

@wraith rapids no it doesnt

wispy monolith
sullen marlin
#

@weary summit you need to post the whole error

wispy monolith
weary summit
wispy monolith
weary summit
#

ik

#

08.05 20:52:34 [Server] ERROR Could not load 'plugins/SCFAlogin.jar' in folder 'plugins'
08.05 20:52:34 [Server] INFO org.bukkit.plugin.InvalidDescriptionException: Invalid plugin.yml
08.05 20:52:34 [Server] INFO at org.bukkit.plugin.java.JavaPluginLoader.getPluginDescription(JavaPluginLoader.java:158) ~[patched_1.12.2.jar:git-Paper-1618]
08.05 20:52:34 [Server] INFO at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:136) ~[patched_1.12.2.jar:git-Paper-1618]
08.05 20:52:34 [Server] INFO at org.bukkit.craftbukkit.v1_12_R1.CraftServer.loadPlugins(CraftServer.java:318) ~[patched_1.12.2.jar:git-Paper-1618]
08.05 20:52:34 [Server] INFO at net.minecraft.server.v1_12_R1.DedicatedServer.init(DedicatedServer.java:222) ~[patched_1.12.2.jar:git-Paper-1618]
08.05 20:52:34 [Server] INFO at net.minecraft.server.v1_12_R1.MinecraftServer.run(MinecraftServer.java:616) ~[patched_1.12.2.jar:git-Paper-1618]
08.05 20:52:34 [Server] INFO at java.lang.Thread.run(Thread.java:748) [?:1.8.0_282]
08.05 20:52:34 [Server] INFO Caused by: java.util.zip.ZipException: invalid END header (bad central directory offset)
08.05 20:52:34 [Server] INFO at java.util.zip.ZipFile.open(Native Method) ~[?:1.8.0_282]
08.05 20:52:34 [Server] INFO at java.util.zip.ZipFile.<init>(ZipFile.java:225) ~[?:1.8.0_282]
08.05 20:52:34 [Server] INFO at java.util.zip.ZipFile.<init>(ZipFile.java:155) ~[?:1.8.0_282]
08.05 20:52:34 [Server] INFO at java.util.jar.JarFile.<init>(JarFile.java:166) ~[?:1.8.0_282]
08.05 20:52:34 [Server] INFO at java.util.jar.JarFile.<init>(JarFile.java:130) ~[?:1.8.0_282]
08.05 20:52:34 [Server] INFO at org.bukkit.plugin.java.JavaPluginLoader.getPluginDescription(JavaPluginLoader.java:146) ~[patched_1.12.2.jar:git-Paper-1618]
08.05 20:52:34 [Server] INFO ... 5 more

wraith rapids
#

i vaguely remember the exception about missing dependencies being very vague

sullen marlin
#

youre not running spigot

wraith rapids
#

barely anyone is

#

sounds like the jar is borked

wispy monolith
#

he is running Paper

quaint mantle
#

go ask in paper

wispy monolith
wraith rapids
#

the plugin jar is borked; make sure you are transferring it properly

#

if you're using FTP make sure to use the binary transfer type instead of ascii

weary summit
#

not the plugin jar, it works on local server

wraith rapids
#

yes, but that is a different jar

#

the jar on the not-local server is a jar you tried to copy over and apparently the transfer failed

weary summit
#

@wraith rapidsThank you! It was ASCII mode

#

Changed to binary and it works

#

Also, my yml wasn't invalid, this worked

wraith rapids
#

add ~'s

cobalt blaze
#

It's fine

wraith rapids
#

not everything is willing to parse that

cobalt blaze
#

Then its a bad parser

wraith rapids
#

you're a bad parser

weary summit
#

this made me LoL

sullen marlin
#

no its valid yaml

novel zodiac
#

Would any of you see what the problem with this is?

#

I get these errors:

org.bukkit.plugin.InvalidDescriptionException: Invalid plugin.yml
        at org.bukkit.plugin.java.JavaPluginLoader.getPluginDescription(JavaPluginLoader.java:162) ~[patched_1.16.5.jar:git-Paper-601]
        at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:148) ~[patched_1.16.5.jar:git-Paper-601]
        at org.bukkit.craftbukkit.v1_16_R3.CraftServer.loadPlugins(CraftServer.java:389) ~[patched_1.16.5.jar:git-Paper-601]
        at net.minecraft.server.v1_16_R3.DedicatedServer.init(DedicatedServer.java:251) ~[patched_1.16.5.jar:git-Paper-601]
        at net.minecraft.server.v1_16_R3.MinecraftServer.w(MinecraftServer.java:1065) ~[patched_1.16.5.jar:git-Paper-601]
        at net.minecraft.server.v1_16_R3.MinecraftServer.lambda$a$0(MinecraftServer.java:289) ~[patched_1.16.5.jar:git-Paper-601]
        at java.lang.Thread.run(Thread.java:834) [?:?]
Caused by: java.io.FileNotFoundException: Jar does not contain plugin.yml
        ... 7 more```
cobalt blaze
#

Your plugin.yml doesnt get put in your jar

novel zodiac
#

oh

#

where would i put it then?

cobalt blaze
#

You could put it in your src folder directly

novel zodiac
#

ok

wraith rapids
#

you could open your jar with winrar and put it in manually

#

that's what real men do

novel zodiac
#

oh

#

ill try that

#

actually nah is there another way?

cobalt blaze
#

I also tested it with creating a resource folder and right click -> mark as... -> Resource map and it would add the yml

novel zodiac
#

when i press mark as, it only says "excluded"

cobalt blaze
#

Have the resources folder in your base folder, not src

lofty mulch
#

Intellij?

novel zodiac
#

yes intellij

lofty mulch
#

Build -> Build artifacts

cobalt blaze
lofty mulch
#

well

#

I follow Spigotmc

novel zodiac
#

done diz

lofty mulch
#

but I use gradle ๐Ÿ˜„

novel zodiac
#

it's resource root

cobalt blaze
#

If you build the artifact now it should clone the files in there into the jar

novel zodiac
#

ohh

cobalt blaze
novel zodiac
#

im trying it

lofty mulch
#

๐Ÿ˜„

novel zodiac
#
        at org.bukkit.plugin.java.JavaPluginLoader.getPluginDescription(JavaPluginLoader.java:162) ~[patched_1.16.5.jar:git-Paper-601]
        at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:148) ~[patched_1.16.5.jar:git-Paper-601]
        at org.bukkit.craftbukkit.v1_16_R3.CraftServer.loadPlugins(CraftServer.java:389) ~[patched_1.16.5.jar:git-Paper-601]
        at net.minecraft.server.v1_16_R3.DedicatedServer.init(DedicatedServer.java:251) ~[patched_1.16.5.jar:git-Paper-601]
        at net.minecraft.server.v1_16_R3.MinecraftServer.w(MinecraftServer.java:1065) ~[patched_1.16.5.jar:git-Paper-601]
        at net.minecraft.server.v1_16_R3.MinecraftServer.lambda$a$0(MinecraftServer.java:289) ~[patched_1.16.5.jar:git-Paper-601]
        at java.lang.Thread.run(Thread.java:834) [?:?]
Caused by: java.io.FileNotFoundException: Jar does not contain plugin.yml
        ... 7 more```
lofty mulch
#

so try this

#

Ctrl + Alt +Shift + S

novel zodiac
cobalt blaze
#

Yes

lofty mulch
#

you should see the plugin.yml inside their

#

if not, click the "+" button and choose file

novel zodiac
#

wdym?

#

oh ok

lofty mulch
#

I meant follow this dude

novel zodiac
#

added

lofty mulch
#

add your source too

#

from spigotmc

novel zodiac
#

ok!

#

like this?

lofty mulch
#

put this

#

remove this

novel zodiac
#

so like this?

lofty mulch
novel zodiac
#

so like this?

#

i moved it

cobalt blaze
#

That should be it

novel zodiac
#

nice

cobalt blaze
#

And then build -> Build Artifact

novel zodiac
#

ok!!

cold tartan
#

im very new to plugins, is there a way to detect player movement without detecting head movement

novel zodiac
#

yes!

cobalt blaze
novel zodiac
#

it's something like "PlayerMovementEvent"

cold tartan
novel zodiac
cold tartan
novel zodiac
lofty mulch
#

you compiled source double time

#

not sure why

#

WorldGuard has API for movement checking

lofty mulch
cobalt blaze
# cold tartan how do you do that?

Something like

@EventHandler
public void onMove(final PlayerMoveEvent event) {
    if (event.getFrom().getX() == event.getTo().getX() && /* getY() & getZ() checks here */) {
        return;
    }
}
novel zodiac
lofty mulch
#

you ran server with java 11

#

but developing plugin with java 8

novel zodiac
#

oh

#

i gotta change the ide?

#

sdk*

cobalt blaze
#

Other way around btw but yes you should change IDE JDK to Java 1.8

lofty mulch
novel zodiac
#

ok

lofty mulch
#

wait

#

no

cobalt blaze
#

No the problem is that the plugin is written in 11 and the server runs on 8

novel zodiac
#

there's no 11

lofty mulch
#

yes that's right

novel zodiac
#

no it's using 1.8

#

the sdk

wispy monolith
queen dragonBOT
wispy monolith
#

use this

novel zodiac
#

wait me?

#

Is this right?

cobalt blaze
novel zodiac
#

oh!!

#

ok ill try that

cobalt blaze
#

That's likely Java 15, use 8 or 11

lofty mulch
#

11

novel zodiac
#

im usign 8

lofty mulch
#

use 11 instead

novel zodiac
#

ok

lofty mulch
#

I'd already removed java 8 xd

novel zodiac
#

oh lol

cobalt blaze
#

With how many servers still run 1.8 I still need it

wispy fossil
#

8%

#

drop em if ya can

novel zodiac
#

wait 1.8 works, should i still use 11?

cobalt blaze
#

It's absolutely not 8%

lofty mulch
#

2020 stats

cobalt blaze
#

๐Ÿ˜”

#

At least we can use streams now

lofty mulch
#

dude

#

just switch to 11

wispy fossil
#

smh my brain

novel zodiac
lofty mulch
#

there is no reason why we should use 8

wraith rapids
#

just wait till 1.17

lofty mulch
#

but this made my sad

wispy fossil
#

I meant Minecraft 1.8

lofty mulch
#

not even 8%

wispy fossil
#

still same principle

lofty mulch
#

much more

#

may be 30-40%

wispy fossil
#

bstats says 8.8% runs 1.8.8
and 1.8% run 'other'

lofty mulch
#

player will use 1.8.9, 1.12.2, latest

#

1% will be the snapshot players like me

cold tartan
#

does PlayerToggleSneakEvent detect when a player starts/stops sneaking?

lofty mulch
#

yes

wispy fossil
#

it detects both

cold tartan
#

k

cobalt blaze
#

There's probably a lot of small servers that just run 1.16 as a survival

cold tartan
#

how do you get the item in a players hand?

#

it says that:
player.getItemInHand()
is depreceated

cobalt blaze
#

in 1.16 it's player.getInventory().getItemInMainHand()

lofty mulch
#

snapshot is cool tho

cobalt blaze
#

I love the new additions MC adds

#

It just sucks that PVP has gotten so bad

#

Because that's the sole reason people are stuck on 1.8

lofty mulch
#

bstats

lofty mulch
#

mojang never ever wants pvp things

#

but not really people still use 1.8

compact haven
#

oh

#

u already sent that

lofty mulch
#

๐Ÿคช yes

cobalt blaze
#

The problem with bStats is that it doesn't show how many players themselves use a version (also because it only does a simple check to see which spigot you run). Their average playercount on a server is 0.6, with ~60k servers empty.

Hypixel's playercount is what the more active minigame player uses, and that is still incredibly skewed towards 1.8

#

It sucks for devs and it's why the Hive shut down their Java server

lofty mulch
#

checkout viaversion bstats

#

i think it is

wraith rapids
#

minigames are cancer anyway

lofty mulch
#

ah shit

wraith rapids
#

it's unsurprising that the people who have been just fine spam clicking in their stale minigames that were old 5 years ago aren't seeking the new content

lofty mulch
#

skyblock is good tho

#

i was kinda enjoy it

cobalt blaze
#

Hypixel is doing just fine lmao

wraith rapids
#

skyblock isn't as much a minigame as it's a gamemode

cobalt blaze
#

They are hitting new records every week

lofty mulch
cold tartan
#

how would u get the type of a dropped item?

lofty mulch
#

.getType()

wraith rapids
#

get the stack and get the type

cold tartan
cold tartan
#

do u guys know why this doesnt work?

@EventHandler
    public static void onPlayerChangedMainHandEvent(PlayerChangedMainHandEvent event) {
        Player player = event.getPlayer();
        Material itemType = player.getInventory().getItemInMainHand().getType();
        if (itemType == Material.NETHER_STAR) {
            player.setAllowFlight(true);
            player.sendMessage(ChatColor.AQUA + "Flight enabled!");
        } else {
            player.setAllowFlight(false);
            player.sendMessage(ChatColor.AQUA + "Flight disabled!");
        }
    }
cobalt blaze
#

Have you registered the listener in your onEnable()?

cold tartan
#

yep

dusk flicker
#

Make it not static

cold tartan
#

why?

cobalt blaze
#

Oh right missed that

cold tartan
#

so this?

public void onPlayerChangedMainHandEvent(PlayerChangedMainHandEvent event) {
cobalt blaze
#

Yes

young knoll
#

You should read what that event does

wraith rapids
#

lol

young knoll
#

Because I donโ€™t think itโ€™s what youโ€™re thinking

wraith rapids
#

iirc bukkit lets you make event handlers static

#

not totally sure though

cold tartan
#

if i want to detect when a player switches their selected item how would i do that?

young knoll
#

PlayerItemHeldEvent iirc?

cold tartan
#

what?

wraith rapids
#

myes

cold tartan
#

ohhhhh

#

i see

#

ill try it

wraith rapids
#

i don't remember if that fires for when the player manually moves items around their inventory into and out of the highlighted hotbar slot

cold tartan
#

hmmmmmm, now it does the opposite of what i want

#
@EventHandler
    public void onPlayerChangedMainHandEvent(PlayerItemHeldEvent event) {
        Player player = event.getPlayer();
        Material itemType = player.getInventory().getItemInMainHand().getType();
        if (itemType == Material.NETHER_STAR) {
            player.setAllowFlight(true);
            player.sendMessage(ChatColor.AQUA + "Flight enabled!");
        } else {
            player.setAllowFlight(false);
            player.sendMessage(ChatColor.AQUA + "Flight disabled!");
        }
    }
wraith rapids
#

it definitely fires when the player scrolls around their hotbar though

cold tartan
#

but now it sets flight to true if they are not holding the nether star

wraith rapids
#

try getting the item from the event

#

the event probably happens before the item is actually held

#

as is the case with most events

cobalt blaze
#

I believe you have to use player.getInventory().getItem(event.getnewItemSlot())

#

Not sure what the exact function name is

#

Something with newslot

wraith rapids
#

and then pray that the slot layout of the methods is the same

#

exactly fucking half of bukkit methods use raw slots and the rest use inventory slots and it's never documented which is which

cobalt blaze
#

Also it might be fired when you change it while dropping the item or clicking around manually

cold tartan
#

hmmmmmm got a nullpointerexception

cobalt blaze
#

on the getType()?

#

You likely need to check if the item in his hand is an actual item

wraith rapids
#

bukkit also returns air on exactly half of the getItem methods, and the rest return null

#

consistency is great

cold tartan
#

do you know if this would work?

Material itemType = player.getInventory().getItem(event.getNewSlot()).getType();
        if (itemType == null) {
            itemType = Material.AIR;
        }
wraith rapids
#

itemtype is never null

#

but getItem might be

cold tartan
#

ok, if so how would i set item to air?

cobalt blaze
#
ItemStack itemInHand = //Here your getInventory().getItem(...) code.
Material itemType;
if (itemInHand == null) {
    itemType = Material.AIR;
} else {
    itemType = itemInHand.getType();
}

More fun way

ItemStack itemInHand = //Here your getInventory().getItem(...) code.
Material itemType = (itemInHand == null) ? Material.AIR : itemInHand.getType();
cold tartan
#

YAY it works!!!!!!

#

TYSM!!!!

crude charm
cobalt blaze
#

How is it messy

crude charm
#

umm what lmfao

cobalt blaze
#

No tell me

#

How is it messy

crude charm
#

ok

#

nesting

#

lines you dont need

cobalt blaze
#

I don't see any major nesting

crude charm
#

wdym

@EventHandler
    public void onPlayerChangedMainHandEvent(PlayerItemHeldEvent event) {
        Player player = event.getPlayer();
        Material itemType = player.getInventory().getItemInMainHand().getType();
        if (itemType == Material.NETHER_STAR) {
            player.setAllowFlight(true);
            player.sendMessage(ChatColor.AQUA + "Flight enabled!");
        } else {
            player.setAllowFlight(false);
            player.sendMessage(ChatColor.AQUA + "Flight disabled!");
        }
    }
cobalt blaze
#

There's 1 thing you could do which is

@EventHandler
    public void onPlayerChangedMainHandEvent(PlayerItemHeldEvent event) {
        Player player = event.getPlayer();
        Material itemType = player.getInventory().getItemInMainHand().getType();
        boolean isNetherStar = itemType == Material.NETHER_STAR;
        player.setAllowFlight(isNetherStar);
        player.sendMessage(ChatColor.AQUA + "Flight "+ ((isNetherStar) ? "enabled" : "disabled") + "!");
    }

but that's literally it

quaint mantle
#

messier

#

i prefer the first

crude charm
#

bruh

#

how...

#

so much nesting

#

like 10 lines you dont need

cobalt blaze
#

There are literally 12 lines

crude charm
#

still adds up

quaint mantle
#

?paste

queen dragonBOT
young knoll
#

What

crude charm
#

I think he wants the link

young knoll
#

There isnโ€™t even a nested if in there

crude charm
#

bruh

#

yes

cobalt blaze
#

Are you looking at the same code as us

#

There is 1 if statement

crude charm
#

no

#

because im not talking about your problem

#

talking about @cold tartan

cobalt blaze
#

You replied to that code

#

Yes

crude charm
#

idk idc

#

just saying what I think and how I would do it

cobalt blaze
#

You haven't even said how you would do it

#

You just said nesting when there isn't even nesting

crude charm
#

because you already said

#
@EventHandler
    public void onPlayerChangedMainHandEvent(PlayerItemHeldEvent event) {
        Player player = event.getPlayer();
        Material itemType = player.getInventory().getItemInMainHand().getType();
        boolean isNetherStar = itemType == Material.NETHER_STAR;
        player.setAllowFlight(isNetherStar);
        player.sendMessage(ChatColor.AQUA + "Flight "+ ((isNetherStar) ? "enabled" : "disabled") + "!");
    }
cobalt blaze
#

You would actually do that?

#

That's ugly af

crude charm
#

not really

#

its readable

#

its preference if you like it like that then its fine

wraith rapids
#

that looks like shit

#

and isn't even the minimum number of lines to achieve that

crude charm
#

ik

#

it doesent matter forget about it

cobalt blaze
#

Wait I can shrink it more

crude charm
#

ye

young knoll
#

I mean

#

If you really want to cut lines you can do that in 2

crude charm
#

^

cobalt blaze
#
    public void onPlayerChangedMainHandEvent(PlayerItemHeldEvent event) {
        boolean isNetherStar = (event.getPlayer().getItemInHand() == null) ? false : 
                                    event.getPlayer().getItemInHand().getType() == Material.NETHER_STAR;
        player.setAllowFlight(isNetherStar);
        player.sendMessage(ChatColor.AQUA + "Flight "+ ((isNetherStar) ? "enabled" : "disabled") + "!");
    }
crude charm
#

if we are talking about least lines in the method then you can define the boolean outside the method but then its actually messy

young knoll
#

Alright let me see here

#
    public void onPlayerChangedMainHandEvent(PlayerItemHeldEvent event) {
    event.getPlayer().setAllowFlight(event.getPlayer().getItemInMainHand() != null && event.getPlayer().getItemInMainHand().getType() == Material.NETHER_STAR);

    event.getPlayer().sendMessage(ChatColor.AQUA + event.getPlayer().getItemInMainHand() != null && event.getPlayer().getItemInMainHand().getType() == Material.NETHER_STAR ? โ€œenabledโ€ : โ€œdisabledโ€);
}
crude charm
#

2 lines

young knoll
#

2 lines, and the worst thing ever to read, enjoy

crude charm
crude charm
compact haven
#

thats far from the worst code

#

its ugly though

crude charm
#

^

compact haven
#

and what if they just swap main hands

#

it'll disable admin flight

young knoll
#

I remember writing some terrible C# code once

#

Lets see if I can find it

compact haven
#

havent we all wrote terrible code before

#

sometimes its too much work to make it look good, or we are too lazy to fix after writing messy code to see why somthing is broken

#

or simply u just started coding and u made bad code, eveyrone has

young knoll
#

I am sorry for this but only a little bit

 int xOffset = dir == 3 ? 7 + level * 4 : dir == 1 ? -1 : 2 + level;

 int width = (dir == 0 || dir == 2) ? 5 + (level * 2) : 7 + (level * 4);
 int height = (dir == 1 || dir == 3) ? 5 + (level * 2) : 7 + (level * 4);```
wispy fossil
#

ternary
the ancient texts

quaint mantle
#

hello, how can I deal damage to player but not true damage

#

affact armor

young knoll
#

player.damage accounts for armor iirc

quaint mantle
#

it deals true dmg

#

oh nvm

#

it deals not true dmg

#

ty

quaint mantle
#

how do i check if the world isnt loaded but exists? ex. if (getServer().getWorld(worldName) != null)?

sullen marlin
#

I suppose you could do new File(new File(Bukkit.getWorldContainer(), worldName), "level.dat").isFile())

quaint mantle
#

okay ty

sage swift
#

&& !"session.lock".isFile() >:)

quaint mantle
#

if (new File(new File(instance.getServer().getWorldContainer(), worldName), "level.dat").isFile() && new File(new File(instance.getServer().getWorldContainer(), worldName), "session.lock").isFile()) ?

sage swift
#

!isFile

#

but your first suggestion would work to see that the world isnt loaded

#

probably

quaint mantle
#

oh yea that could

#

ill try ig

noble cedar
#

is there an event that checks every time the player gets a message from anywhere?, like from broadcast or send or more the important thing is that the player gets chat

quaint mantle
#

i dont think so

tepid willow
#

How do I make it so that an item can be enchanted in the enchantment table? Made an "emerald" sword using the Diamond Sword ItemStack, Meta, etc. How do I make it so that the emerald sword also inherits the ability to be enchanted?

quaint mantle
#

i think smth like InventoryClickEvent then check the inventory type if its enchant table

#

[NMS] How to set mob's follow range?

#

I'm talking about attacking the player when he's in the n block.

chrome beacon
#

Since you're using NMS you might have to find that yourself

#

Minidiggers mapping viewer is a good start

sullen marlin
#

Attribute.GENERIC_FOLLOW_RANGE

#

no NMS required

quaint mantle
#

ty, but uhh it seems doesn't work

LivingEntity livingEntity = (LivingEntity) this.getBukkitEntity();
        AttributeInstance followRange = livingEntity.getAttribute(Attribute.GENERIC_FOLLOW_RANGE);
        followRange.setBaseValue(10000);
sullen marlin
#

its not gonna follow past either activation range or chunk loaded range

#

cant all swords be enchanted?

tepid willow
#

ill try to rephrase my question. how do i make an item enchantable?

#

No, it's odd

#

let me do a test hold on

sullen marlin
#

I dont see why it wouldnt be enchantable

tepid willow
#

....yeah never mind. some big user error on my part lmao

plain quest
#

do you know any mojang api wrapper for maven cause i'm too lazy to do it on my own?

quiet ice
#

mojang API wrapper?

plain quest
#

yes instead of having to create a connection and type the url and all that stuff having an api to do it

#

i can do it own my own but i'm lazy so if there's something like that it would save me a lot of time

#

i need to get skin data of players by the way

quiet ice
#

NMS's game profile should do that but idk

plain quest
#

i know it does that i just wanna grab the skin data from the mojang servers

outer sorrel
#

Im making an anticheat and for some reason when i get kicked and rejoin I cant see flags in chat until someone else is kicked, I can see flags after that again

plain quest
#

@outer sorrel show us ur code maybe?

outer sorrel
#

also it still flags because you still get kicked so idk whats wrong, just doesnt send the message

chrome beacon
#

Don't return in that loop

#

Use continue

#

Or it will only alert one player max

#

(Line 60)

outer sorrel
#

๐Ÿคฆ

#

idk why i did that

#

thanks lol

chrome beacon
#

eh we all make mistakes

fading lake
#

you know when people shout about "dAtaBAsE cALLs shOUlD bE asYNCHroNouS", is calling them on a different thread from the main one synchronously enough? (having trouble figuring out how to run concurrent callable asynchronously)

sullen marlin
#

yes

fading lake
#

okay thank you โค๏ธ

ivory sleet
#

๐Ÿฅฒ

twilit agate
#

@chrome beacon is the best helper tbh

compact haven
#

@fading lake honestly didnt expect to see u get into MC dev all those years ago lol

fading lake
#

neither did I honestly, pretty sure back then I was just getting into roblox lua lmfao

quaint scarab
#

We have expert on OOP ? (yes pls)

quiet ice
#

No

#

You provided too much information so I cannot help you

#

And I guess that also applies to the rest of the peeps on here

wispy fossil
#

BiteDick

silver cove
#

I am trying to get a string from a yaml file, but it returns null, and when i check if the file contains that value, it says it doesnt. but it does work with integers, doubles, longs and booleans?

switch (dataType) {
                                        case STRING:
                                            if(!config.contains(dataKey)) Bukkit.getLogger().info("wtf");
                                            String test = config.getString(dataKey);
                                            Bukkit.getLogger().info(test);
                                            break;
                                        case INT:
                                            Bukkit.getLogger().info(String.valueOf(config.getInt(dataKey)));
                                            break;
                                        case DOUBLE:
                                            Bukkit.getLogger().info(String.valueOf(config.getDouble(dataKey)));
                                            break;
                                        case LONG:
                                            Bukkit.getLogger().info(String.valueOf(config.getLong(dataKey)));
                                            break;
                                        case BOOLEAN:
                                            Bukkit.getLogger().info(String.valueOf(config.getBoolean(dataKey)));
                                            break;
                                    }```

```yaml
sql:
  host: 127.0.0.1
  port: 3306
  database: minecraft
  username: "%plugin"
  password: ""
  useSSL: false
someotherthing:
  inttest: 0
  doubletest: 0.0
  longtest: 0
  stringtest: "heya"
#

and my output is this:

[12:18:32] [Server thread/INFO]: [CM] Enabling ConfigManager v1.0.0
[12:18:32] [Server thread/INFO]: wtf
[12:18:32] [Server thread/INFO]: null
[12:18:32] [Server thread/INFO]: wtf
[12:18:32] [Server thread/INFO]: null
[12:18:32] [Server thread/INFO]: wtf
[12:18:32] [Server thread/INFO]: null
[12:18:32] [Server thread/INFO]: wtf
[12:18:32] [Server thread/INFO]: null
[12:18:32] [Server thread/INFO]: wtf
[12:18:32] [Server thread/INFO]: null
[12:18:32] [Server thread/INFO]: false
[12:18:32] [Server thread/INFO]: 0
[12:18:32] [Server thread/INFO]: 0.0
[12:18:32] [Server thread/INFO]: 0
[12:18:32] [Server thread/INFO]: wtf
[12:18:32] [Server thread/INFO]: null
quiet ice
#

What is "dataKey"?

silver cove
#

the key from the config, so for example sql.database

quiet ice
#

Sure? Otherwise config is invalid

silver cove
#

i mean it works with everything other than the string

quiet ice
#

That is because 0/false are default

#

They cannot return null due to the way primitives work in java

silver cove
#

ahhh

#

i think ive found my problem

#

thanks for your help!

solemn shoal
#

"configmanager"

#

wh

silver cove
#

yes

solemn shoal
#

anyways turning decimal numbers into hex

#

fun stuff

#

jk thats where python comes in

glossy barn
#

I mean Integer.toHexString(int n) is quite handy

solemn shoal
#

java can do that?

glossy barn
#

yes..

quaint scarab
solemn shoal
#

aside like "%x".format(int)

#

eh i just threw it in a python array and used its hex function

glossy barn
#

no, so it would be
this.put(Integer.toHexString(16755200), "GOLD");

solemn shoal
#

oh..

glossy barn
#

that works too

solemn shoal
#

just make it make more sense in my code

#

if only i knew ij could do this before i grabbed python lol

#

this makes more sense lol

#

now to make everything uppercase

#

perfect

glossy barn
#

String#toUpperCase()

solemn shoal
#

i missed a few F's lol

glossy barn
#

There's another way to do it using a function if you want:

public int toHex(int n) {
  int remainder;
  String result = "";
  char hex[] = {'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'};

  while (n > 0) {
    remainder = n % 16;
    result = hex[remainder]+result;
    n /= 16;
  }

  return Integer.parseInt(result);
}```
#

not tested but it should work

solemn shoal
#

"%X".format(int)

#

anyways all i needed was hex in my code to represent colors instead of numbers

urban trout
#

how would i update a zombies health to its health everytime it takes damage

solemn shoal
#

how do you mean?

#

just use the EntityDamageEvent?

#

?jd

urban trout
#

ok thanks

solemn shoal
urban trout
#

ty

#

i think i've done something wrong

#

nvm i got it

indigo fern
#

does anyone know how to get all the files (from a Folder) to a inventory?

sage dock
#

can I make a system of friends on the server so that the commands are on the spigot plugin and the data is sent to the bungeecord?
using Bukkit & BungeeCord Plugin Messaging Channel

quaint mantle
#

why wouldnt u just do bungee plugin?

#

but yea u can do that just use ToProxy channel

solemn shoal
#

mmm colors

quaint mantle
#

rgb = more fps

sage dock
#

yes

solemn shoal
#

yes

naive spindle
sage dock
quaint mantle
#

yes

#

do you know what it means

outer sorrel
#

for some reason when a value in the config is set to nothing it gets it from the default config, can i stop this somehow?

solemn shoal
#

maybe not the best idea to println in a loop lol

opal juniper
#

Can you make a COMPLETELY Custom mob? So instead of extending, for example EntityZombie it would extend the base class?

naive spindle
outer sorrel
solemn shoal
#

and i dont think the game even supports specifying entity type sthat dont exist

indigo fern
#

does anyone know how to get all the files (from a Folder) to a inventory?

solemn shoal
#

so you'd still have to represent it as SOMETHING

solemn shoal
#

like, a file browser in an Inventory?

indigo fern
#

I got a folder with a lods of report files, i want to get all the files in a inventory

opal juniper
opal juniper
#

ill find my code

indigo fern
#

k

opal juniper
#

im gonna add code bit by bit

#

i will say when i am done

indigo fern
#

ok

opal juniper
#

looking back on it, it is bad code

indigo fern
#

ty <3!

opal juniper
#

not quite finished

#

?paste

queen dragonBOT
opal juniper
#

ok, so don't take this code and use it

#

cause it is bad

#

take the idea, and make it better

#

basically, the format for the file

indigo fern
#

ok ty man!

opal juniper
#

was the player's uuid+".yml" as the name

#

and then some other lines

#

inside the yaml file

indigo fern
#

k

opal juniper
#

and then it added the piece of paper with lore lines to an inventory

#

and showed the player it

#

pls dm me if you need more help

indigo fern
#

ok

opal juniper
#

also, that inventory shoudn't be static

solemn shoal
#

hey md_5, how does spigot get working 24bit color in console?

#

im using jansi but its only outputting in 8/16 colors or so

#

im wondering if im missing something (i have AnsiConsole.systemInstall(); in the beginning of my code)

#

WSL for reference:

#

under spigot:

#

according to the craftbukkit source its using the same code as i am

urban trout
#

would it be possible to make something that makes a small wall when i place my barricade block

solemn shoal
#

unsupported java check on craftbukkit, begone

urban trout
#

ooo okay

#

do you know where i should look for help on how to do things like that

solemn shoal
#

the best patch

opal juniper
urban trout
#

how would i make the structure?

wraith rapids
#

by placing blocks

urban trout
#

hhhhhhm

quaint mantle
#

Hi i need help in making a custom Play time recorder plugin

#

i need to know how to do it

quiet ice
#

numerous ways

#

But did you consider using the play time statistic?

quaint mantle
#

i want to make a bungeecord plugin which keeps track of how much time a player plays

#

in the whole of server and other servers

#

also, I am very new to plugin development

#

and i am learning

cold tartan
#

it may be hard to read, but i understand what goes on behind it so Ill use that

plain quest
#

why is maven creating two jars the one with "original" prefix and the other without it and how can i prevent this from happening?

paper viper
#

thats from the shading plugin

plain quest
#

and what is it's use?

quiet ice
#

one is with all the dependencies one without

plain quest
#

which do i need to keep?

paper viper
#

i always use the non-original one

quiet ice
#

The original is not really relevant for you

plain quest
#

how do i prevent original from generating then

quiet ice
#

Cannot do that

paper viper
#

^

plain quest
#

๐Ÿ˜ข

paper viper
#

Why do you want to prevent it too?

quiet ice
#

The shaded requires the original to exist

paper viper
#

its not a big deal

plain quest
#

i just don't wanna have both inside my plugins folder

#

i want the jar to be built there

paper viper
#

uh you're doing something wrong

plain quest
#

i just don't want to have to move it every time i want to debug or test

#

to my plugins folder

paper viper
#

dont you just specify outputFile?

#

did that not work

#

<outputFile>path-to-server/plugins/${project.artifactId}.jar</outputFile>

plain quest
#

<directory>C:\Users\Dennis Gyftakis\Desktop\1.16 SMP\plugins</directory> i added this to the <build> ... <build\>

paper viper
#

well.. thats why

#

you don't specify directory

#

cause that will just put the target folder and all the compiled shit in the plugins folder

#

including the original jar

plain quest
#

ok so i just have to add the above?

paper viper
#

add the outputFile thing to the maven shading plugin and remove the directory

#

idk why you would want to use <directory> anyways

plain quest
#

ok thanks

chrome beacon
#

Save timestamp on join and then calculate time when they leave

#

Add that to some storage and your plugin is done

quaint mantle
#

to save timestamp?

chrome beacon
#

System.currentTimeMillis()

quaint mantle
fiery inlet
cold tartan
#

do you guys know why this doesn't work?

@Override
        public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
            if (!(sender instanceof Player)) {
                sender.sendMessage(ChatColor.RED + "Only players can use that command!");
                return true;
            }

            Player player = (Player) sender;
            player.setFlySpeed(Float.parseFloat(args[0]));

            return true;
        }
#

it gives an error

upper vale
#

you never check args length

#

you also never check if the argument is actually a float

cold tartan
#

but [0] should always be the first argument right?

upper vale
#

Yes

#

but it will error if there are no arguments

wraith rapids
#

/label args[0] args[1] ...

cold tartan
#

yes, even if I send /flyspeed 20 it still gives an error

wraith rapids
#

what is the error

quaint mantle
#

send it

cold tartan
#

lemme get it

quaint mantle
#

isnt btw flyspeed max 10?

upper vale
#

i dont think flyspeed can be creater than 1

wraith rapids
#

when asking "why doesn't x work" and you have an error, start with the error

upper vale
#

no im pretty sure the max is 1

wraith rapids
#

the error contains 90% of the information we need

quaint mantle
#

oh yeah maybe yes

upper vale
#

0.1 to 1

wraith rapids
#

reading the error yourself can also help

cold tartan
#
org.bukkit.command.CommandException: Unhandled exception executing command 'flyspeed' in plugin tutorial v1.0
        at org.bukkit.command.PluginCommand.execute(PluginCommand.java:47) ~[patched_1.16.5.jar:git-Paper-651]
        at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:159) ~[patched_1.16.5.jar:git-Paper-651]
        at org.bukkit.craftbukkit.v1_16_R3.CraftServer.dispatchCommand(CraftServer.java:810) ~[patched_1.16.5.jar:git-Paper-651]
        at net.minecraft.server.v1_16_R3.PlayerConnection.handleCommand(PlayerConnection.java:2176) ~[patched_1.16.5.jar:git-Paper-651]
        at net.minecraft.server.v1_16_R3.PlayerConnection.c(PlayerConnection.java:1991) ~[patched_1.16.5.jar:git-Paper-651]
        at net.minecraft.server.v1_16_R3.PlayerConnection.a(PlayerConnection.java:1944) ~[patched_1.16.5.jar:git-Paper-651]
        at net.minecraft.server.v1_16_R3.PacketPlayInChat.a(PacketPlayInChat.java:50) ~[patched_1.16.5.jar:git-Paper-651]
        at net.minecraft.server.v1_16_R3.PacketPlayInChat.a(PacketPlayInChat.java:8) ~[patched_1.16.5.jar:git-Paper-651]
        at net.minecraft.server.v1_16_R3.PlayerConnectionUtils.lambda$ensureMainThread$1(PlayerConnectionUtils.java:35) ~[patched_1.16.5.jar:git-Paper-651]
        at net.minecraft.server.v1_16_R3.TickTask.run(SourceFile:18) ~[patched_1.16.5.jar:git-Paper-651]
        at net.minecraft.server.v1_16_R3.IAsyncTaskHandler.executeTask(IAsyncTaskHandler.java:136) ~[patched_1.16.5.jar:git-Paper-651]
        at net.minecraft.server.v1_16_R3.IAsyncTaskHandlerReentrant.executeTask(SourceFile:23) ~[patched_1.16.5.jar:git-Paper-651]
        at net.minecraft.server.v1_16_R3.IAsyncTaskHandler.executeNext(IAsyncTaskHandler.java:109) ~[patched_1.16.5.jar:git-Paper-651]
        at 
#
        at net.minecraft.server.v1_16_R3.MinecraftServer.executeNext(MinecraftServer.java:1255) ~[patched_1.16.5.jar:git-Paper-651]
        at net.minecraft.server.v1_16_R3.IAsyncTaskHandler.executeAll(IAsyncTaskHandler.java:95) ~[patched_1.16.5.jar:git-Paper-651]
        at net.minecraft.server.v1_16_R3.MinecraftServer.a(MinecraftServer.java:1391) ~[patched_1.16.5.jar:git-Paper-651]
        at net.minecraft.server.v1_16_R3.MinecraftServer.w(MinecraftServer.java:1126) ~[patched_1.16.5.jar:git-Paper-651]
        at net.minecraft.server.v1_16_R3.MinecraftServer.lambda$a$0(MinecraftServer.java:289) ~[patched_1.16.5.jar:git-Paper-651]
        at java.lang.Thread.run(Unknown Source) [?:1.8.0_291]
Caused by: java.lang.IllegalArgumentException: 2.0 is too high
        at org.bukkit.craftbukkit.v1_16_R3.entity.CraftPlayer.validateSpeed(CraftPlayer.java:1786) ~[patched_1.16.5.jar:git-Paper-651]
        at org.bukkit.craftbukkit.v1_16_R3.entity.CraftPlayer.setFlySpeed(CraftPlayer.java:1753) ~[patched_1.16.5.jar:git-Paper-651]
        at com.defiantburger.tutorial.commands.flyspeed.onCommand(flyspeed.java:18) ~[?:?]
        at org.bukkit.command.PluginCommand.execute(PluginCommand.java:45) ~[patched_1.16.5.jar:git-Paper-651]
        ... 19 more
#

thats the error

quaint mantle
#

yep

#

try /flyspeed 10

upper vale
#

IllegalArgumentException - If new speed is less than -1 or greater than 1

wraith rapids
#

IllegalArgumentException

#

2.0 is too high

#

literally read

cold tartan
#

ohhhhhhhhhhh

upper vale
#

World#rayTraceEntities doesn't go through walls right?

wraith rapids
#

it can be made to, but i don't think that is the default no

quaint mantle
#

@cold tartan

@Override
        public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
            if (!(sender instanceof Player)) {
                sender.sendMessage(ChatColor.RED + "Only players can use that command!");
                return true;
            }

            Player player = (Player) sender;
            Float flySpeed;

            try {
                flySpeed = Float.parseFloat(args[0]);
                
                if (!(flySpeed >= 0.1 && flyspeed <= 1.0)) {
                     player.sendMessage("Fly speed must be from 0.1 to 1.0!");
                    return;
                }

                player.setFlySpeed(flySpeed);
                
                
                
            } catch (NumberFormatException ex) {
                player.sendMessage("You need to enter number");
            }

            return true;
        }
#
    private void setNameTag(Player player, String name) {
        try {
            for (Player onlinePlayer : Bukkit.getOnlinePlayers()) {
                onlinePlayer.hidePlayer(player);
            }
            GameProfile profile = ((CraftPlayer) player).getProfile();
            
            Field ff = profile.getClass().getDeclaredField("name");
            ff.setAccessible(true);
            ff.set(profile, name);
            
            Field ffu = profile.getClass().getDeclaredField("id");
            ffu.setAccessible(true);
            ffu.set(profile, UUID.randomUUID());

            for (Player onlinePlayer : Bukkit.getOnlinePlayers()) {
                onlinePlayer.showPlayer(player);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }```  This is my method for setting someone's name, it works well however their old name is still part of the tablist as shown here
https://i.theblitzbot.com/KYsFH.png
#

try hideplayer and then showplayer

wraith rapids
#

nice variable names

quaint mantle
#

yeah xd

#

yeah

#

i dont think they're bad except the Fields

#

Yeah they're only used in the directly associated lines so it's fine

#

By the way I'm already hiding the player before the gameprofile is modifed & also showing the player after it's done

#

oh yeah sry didnt notice

wraith rapids
#

it may be the case that their displayName still retains the old username

quaint mantle
#

it's just added onto the tablist

wraith rapids
#

you are changing the username of a player

#

displayname is stored separately from the username

#

and it may retain the old value from before you changed the username

#

and is used as the default for the playerlist name

#

try calling player.getDisplayName and see what it returns

quaint mantle
#

nah

#

shouldnt he send packets?

wraith rapids
#

i'm not talking about what he should do

#

i'm talking about what is probably the cause

quaint mantle
#

even if the displayname remains the same it shouldn't just add more of the same ones onto tab right

graceful turret
#
   p.updateInventory();``` guys will it set the item in current opened inventory?
quaint mantle
#
void changeNameForTest(Player player, String name, List<Player> viewers) {
        GameProfile gp = ((CraftPlayer)player).getProfile();
        try {
            Field nameField = GameProfile.class.getDeclaredField("name");
            nameField.setAccessible(true);
            nameField.set(gp, name);
        } catch (IllegalAccessException | NoSuchFieldException ex) {
            throw new IllegalStateException(ex);
        }
            ((CraftPlayer)player).getHandle().playerConnection.sendPacket(new PacketPlayOutEntityDestroy(player.getEntityId()));
            ((CraftPlayer)player).getHandle().playerConnection.sendPacket(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.REMOVE_PLAYER, ((CraftPlayer)player).getHandle()));
            ((CraftPlayer)player).getHandle().playerConnection.sendPacket(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER, ((CraftPlayer)player).getHandle()));
        for (Player pl : viewers) {
            if (pl == player) continue;
            ((CraftPlayer)pl).getHandle().playerConnection.sendPacket(new PacketPlayOutNamedEntitySpawn(((CraftPlayer)player).getHandle()));
        }
    }

found this on forum try the sending packets

wraith rapids
#

the issue is that that doesn't actually change the name of the player

#

anything else that sends a tablist update for that player will revert the value to the old name

#

see where the incorrect tablist name is coming from; get the player's tablist name and trace that value to its source, then replace the value at the source with the new one

#

just throwing packets at the client isn't reliable

quaint mantle
#

hmm ill try smth with it

#

Perhaps the hiding + showing thing might be a solution for this

wraith rapids
#

hello

quaint mantle
#

hello

#

hello

#

oh you're correct NNY

#

I currently already have code to change the skins of the players that works flawlessly but changing the nametag seems to be a whole different animal

plain quest
#

i'm making a plugin to change skins and i need to perform a dimension change. would it be better to teleport the player to another world and then back to where they were before or just kill them and instantly re-spawn them?

upper vale
#

If I wanted to get a player another player is looking at, would it be more efficient to raytrace or use a nearby entities + line of sight?

upper vale
#

from 2011 though ๐Ÿ˜„

wraith rapids
#

raytrace is basically a slightly optimized version of getting nearby entities and line of sight

quaint mantle
#

still can work

wraith rapids
#

like getNearbyEntities, it only checks the chunk slices that overlap with the ray

paper viper
#

is the getNearbyEntities fast tho

#

just wondering

wraith rapids
#

it's about as fast as searching for nearby entities can get

upper vale
#

im doing this like 1000+ times a minute lol

wraith rapids
#

but it looks in every direction, not just along a single ray like the raytrace call

upper vale
#

yeah i think it makes sense for raytrace to be faster

wraith rapids
#

its performance characteristics are similar to the collision checks the server does every tick for every entity

#

of course if you're doing a batshit insane number of those calls, you could hack into the chunk slices yourself and iterate over their contents asynchronously

#

you might get some stale data now and then because no synchronization, but it comes at basically zero main thread time cost

upper vale
#

is there a way to visualize the raytrace with particles

wraith rapids
#

not with the raytrace call itself no

#

but drawing a line of particles is very trivial and cheap so you can do it yourself just fine

tame iron
#

hi, I need to check whether there is another block of a certain type around the block, how can I do this without getting each side through getRelative since this is too many variables and calculations

sleek pond
#

you can do a for loop

wraith rapids
#
for (BlockFace face : BlockFace.values()) { 
    Block neighbor = block.getRelative(face); 
}
sleek pond
#

yea

#

that

quaint mantle
#

could smbdy help me?

[17:12:28 ERROR]: Encountered an unexpected exception
java.lang.NullPointerException: null
        at org.spigotmc.SpigotConfig.stats(SpigotConfig.java:260) ~[server.jar:git-Spigot-79a30d7-acbc348]
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_252]
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_252]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_252]
        at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_252]
        at org.spigotmc.SpigotConfig.readConfig(SpigotConfig.java:110) ~[server.jar:git-Spigot-79a30d7-acbc348]
        at org.spigotmc.SpigotConfig.init(SpigotConfig.java:76) ~[server.jar:git-Spigot-79a30d7-acbc348]
        at net.minecraft.server.v1_12_R1.DedicatedServer.init(DedicatedServer.java:184) ~[server.jar:git-Spigot-79a30d7-acbc348]
        at net.minecraft.server.v1_12_R1.MinecraftServer.run(MinecraftServer.java:545) [server.jar:git-Spigot-79a30d7-acbc348]
        at java.lang.Thread.run(Thread.java:748) [?:1.8.0_252]
[17:12:28 ERROR]: This crash report has been saved to: /home/container/./crash-reports/crash-2021-05-09_17.12.28-server.txt

my spigot.yml: https://paste.md-5.net/wayucahiku.bash

tame iron
#

thx

sleek pond
#

what is your plugin name

quaint mantle
#

its spigot.yml

sleek pond
#

is it called SpigotConfig?

quaint mantle
#

no its like a spigot.yml file

sleek pond
#

no your plugin

#

what is it's name

quaint mantle
#

its not a plugin

sleek pond
#

?

wraith rapids
#

SpigotConfig is the class that backs spigot.yml

quaint mantle
#

its a spigot.yml file in the server root where are worlds eula

eternal oxide
sleek pond
quaint mantle
#

i dont know i changed everything except world-settings

eternal oxide
#

That English doesn't make sense. Try again

sleek pond
#

lmao

#

0/3 stars

#

level failed

quaint mantle
#

better?

wraith rapids
#

look at the sauce and see what it's trying to parse i guess

eternal oxide
#

Not really

quaint mantle
#

i just changed every line that there is except the world-settings column

coarse badger
#

Hey, does anyone know if it's possible or how to edit a chat message. So for example for displaying a timer like 10 seconds till borders drop, then instead of sending a new message 9 seconds till borders drop, then kinda edit the first message and update it with 9 seconds and so on?

wraith rapids
#

kind of

#

you can't modify already sent messages, no

#

but what you can do is re-send the entire chat history to a player with that particular message changed

#

which involves keeping track of all the chat packets each player receives, then modifying the contents of the message you want to change, and then resending them in bulk

coarse badger
#

seems like a bit of a hack.
i think i would rather send bossbars

wraith rapids
#

it also is kind of laggy for the client and takes shit tons of bandwidth

eternal oxide
quaint mantle
#

yea

#

fixed it

#

ty

plain quest
#

i'm using the packetplayoutgamestatechange to show respawn the player as if they've bitten the ender dragon but the client gets stacked at the loading terrain part until the player dies

#

what causes this?

wraith rapids
#

ender dragons taste bad

plain quest
#

i couldn't care less

wraith rapids
#

i do hate it when the clients are stacked

plain quest
#

me too that's why i'm asking

wraith rapids
#

did you write this with speech to text

plain quest
#

no

quaint mantle
#

how can i disable players that are connecting with versions under 1.12.2 on bungeecord?

plain quest
#

are you working with a bungee or spigot plugin?

quaint mantle
#

with nothing

plain quest
#

then obviously make one

quaint mantle
#

just wanted to ask bcz there's a outdated_client in messages.properties in bungee

plain quest
#

not sure let me check

wraith rapids
#

the protocol version of the client is probably exposed somewhere

quaint mantle
#

okay

tame iron
#

how do I get the number of players online? something I can't find in the api

dusk flicker
#

get the count of Bukkit.getOnlinePlayers

pearl glade
#

I would like to know if it is possible to update only one section of a chunk ?

quaint mantle
mortal hare
plain quest
#

[Server thread/FATAL]: Error executing task on Server
java.lang.NullPointerException: null
at net.minecraft.server.v1_16_R3.ChunkMapDistance.b(ChunkMapDistance.java:244) ~[server.jar:2991-Spigot-018b9a0-f3f3094] when entering the portal to go back to the overworld after killing dragon

#

Please help

#

0_0

eternal oxide
#

?paste full error

queen dragonBOT
plain quest
#

ok : D

tame iron
#

thx

plain quest
#

better now?

eternal oxide
#

theres more to that error

plain quest
#

no it ends at the [?:?]

#

and the client gets stacked

eternal oxide
#

If thats the case you have a serious issue as there is only Minecraft packages in that stacktrace

#

No plugin

plain quest
#

yes it's not caused by a plugin

eternal oxide
paper viper
#

i suspect it's probably the values that are being set to initialize like the packet

#

or smthing

plain quest
paper viper
#

you know when you use reflection to set the values

#

could you show your code

plain quest
#

sendGameState(p, PacketPlayOutGameStateChange.e, 0);

#

public void sendGameState(Player player, PacketPlayOutGameStateChange.a type, float state) { PacketPlayOutGameStateChange packet = new PacketPlayOutGameStateChange(type, state); ((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet); }

#

that's supposed to send the credit screen after beating minecraft

#

but even in vanilla if i kill the dragon and get into the portal it crashes

#

and prints that error

sharp bough
#

is there a better way of saving the lore of an item to a location than this?

                Double.parseDouble(clickedItem.getItemMeta().getLore().get(1)),
                Double.parseDouble(clickedItem.getItemMeta().getLore().get(2)),
                Double.parseDouble(clickedItem.getItemMeta().getLore().get(3)));
#

the lore is
world
X
Y
Z

paper viper
#

why are you using the meta to store information

#

you know if you used pdc it would be much easier

quaint mantle
#

what is pdc

sharp bough
#

im googling it rn

#

lol

paper viper
#

persistent data container

quaint mantle
#

ty

sharp bough
#

Persistent data containers

#

?

#

yea

#

but im using 1.12

#

atm

wraith rapids
#

yeah well

eternal night
#

ooof

wraith rapids
#

don't shoot yourself in the foot

#

if you don't want to be a cripple