#help-development

1 messages · Page 1395 of 1

wraith rapids
#

copy the collection and add the respawning player to the collection

silver shuttle
#

thanks

quiet ice
#

But what if multiple players are dead?

wraith rapids
#

then you are fucked

#

but using a different event wouldn't help anyway

eternal oxide
wraith rapids
#

because the dead players would still be dead

#

regardless of what event you use

lost matrix
#

Kick them if they have the audacity to die when someone else is already dead.

dusk flicker
#

^

wraith rapids
#

maintain a list of dead players by listening to death and spawn events :pepega:

cold field
#

Guys does it exists an API method to retreive the plugin.yml? Or do I need to use getResource()

pure glacier
eternal oxide
#

getDescription()

novel lodge
#

I worked out how to sort this. I activated instant respawn and delayed the function by 1 tick

cold field
#

thanks

tacit drift
#

if i have
config.set("cells."+player.getName()+".level",1);
i return value with
config.getInt("cells."+player.getName()+".level")
?

eternal oxide
#

use UUID not name

tacit drift
#

i use player name for multiple things already

#

¯_(ツ)_/¯

lost matrix
#

*retrieve. Yes. But UUID > name in this case

eternal oxide
#

then stop

tacit drift
#

ok

opal juniper
#

Is yaw always negative? I am trying to work out a players rotation

lost matrix
#

User changes name -> loses everything

eternal oxide
#

names can easily be changed UUID is unique

wraith rapids
#

i've never had nitro

opal juniper
#

i seem to get from -0.0000001 to -360

wraith rapids
#

i'm not a cuck

#

i don't pay money for pixels

eternal oxide
#

and the longer you wait to change to UUID the harder it gets.

lost matrix
wraith rapids
#

towny only took half a decade or something

eternal oxide
#

Its still not converted

#

Not fully

wraith rapids
#

they're pretty close i think

#

towns and stuff at least have uuids now

quiet ice
#

Towny no longer relies on another plugin to tell when a user changed his name

dusk flicker
#

LOL

wraith rapids
#

myeah

#

had to use that addon for a few years

#

but progress is progress

north osprey
#

Hey, is there a way to detect when the player stops breaking a block? I looked through events implemented by Spigot and found nothing that seemed like it. I know it can be done by inspecting player packets but I'd like to stick to Spigot only solution.

silver shuttle
#

How would I make a ClickEvent execute multiple commands in one click?

eternal oxide
#

Dont use Dispatch use any API

wraith rapids
#

i don't think there is an API way of detecting that

silver shuttle
#

No no I'm trying to make click events on messages

wraith rapids
#

you would make it execute a command that prompts the player to execute several commands

#

beyond that, the function of the click event is simple; it forces the player to run a command

#

nothing more, nothing less

silver shuttle
#

Well that won't work because I need like a message in chat that you click on several times to alter the value in a database

wraith rapids
#

anything else you want it to do you need to cobble up and string together yourself

north osprey
#

Then, if I were to make a PR with a new event that supports that, how long would it take to get it in a new version? Would I have to wait for the next Minecraft version?

wraith rapids
#

on spigot? probably never lol

#

you wouldn't need to wait for the next minecraft version, you'd need to wait for someone to accept and merge your pr

eternal oxide
#

it all depends on its likely uptake

wraith rapids
#

which may happen quickly or take ages or may not happen at all

eternal oxide
#

and its additional load on teh server

#

I've seen questions relating to this kind of event a few times in here

north osprey
#

Well, then I guess that means I'm better off hacking my own solution... Sorry if some of my questions seem dumb but I came back to plugin development after ~5 years and I have no idea how the community has changed.

eternal oxide
#

If I were you I'd make the PR. The only way the API expands is if suggestions are made

wraith rapids
#

do both

north osprey
#

Yeah, I know but at this moment I'm really questioning which server mod should I be using. I'm having a fresh start with a new project and I'm wondering which community (Sponge or Spigot) is more active and which API do I want to go with and be less frustrated.

wraith rapids
#

there's a chance you'll die of old age if you wait for the pr

#

so make a pr and get yourself a hack and use the hack until it gets merged

thorny vector
#

Hello , so i want to make a plugin that open a gui , and you could put your item and click on the enchanting book and its will give it to you , anyway i made it work with InventoryClickEvent.getCursor() but when the player click on the book he need to click again with the book , i guess that makes sense , but what i can do to get the enchants from the book and apply them with only one click, thank you in advance
and i, tried getCurrentItem() i just replace it but its return a null exception

wraith rapids
#

what

#

if you have an exception, paste the exception

quiet ice
#

paste, not dump

thorny vector
#

i have it when i use getCurrentItem()

wraith rapids
#

then whatever you are calling getcurrentitem on is null

#

or the return value of getcurrentitem is null

#

and you're trying to call a method on it

thorny vector
#

i know this

wraith rapids
#

we know this too

quiet ice
#

Use Java 15+ it'll explain you in full detail on where the issue is with NPEs

wraith rapids
#

and that's all we know

#

because you deleted the code and didn't give us an exception

#

we're more in the dark than you are

thorny vector
#

you said post it on paste no ?

eternal oxide
#

?paste

queen dragonBOT
quiet ice
#

In relation to the exception

wraith rapids
#

yes but I was looking at it 🕋

quiet ice
#

why is that an emoji

wraith rapids
#

i don't know

#

kaaba

thorny vector
thorny vector
wraith rapids
#

and now the exception

quiet ice
wraith rapids
#

my guess is that e.getCursor returns null

thorny vector
#

no , alright you don't get it

wraith rapids
#

can you paste the exception or not

thorny vector
#

i think i found a way

#

brb

quiet ice
#

ITEMINHAND is null

thorny vector
thorny vector
quiet ice
#

I was just saying random things

thorny vector
#

lmao

quiet ice
#

now can we know what the 55th line of your class is?

wraith rapids
#

and next we need line numbers

thorny vector
#
itemtoenchant.addUnsafeEnchantments(map);
wraith rapids
#

then one of those 2 variables is null

#

presumably itemtoenchant

thorny vector
#

yup , alright

quiet ice
#

Just note that asserts are stripped at runtime unless a JVM flag is added

thorny vector
#

oh

quiet ice
#

Which is why they are usually used with unit testing

quaint mantle
#

yo

#

I realized why I was getting an error while compiling with maven so I fixed it, but uhhh I have an error which I'd like help with

quiet ice
#

That is too much info, cannot help you with it

quaint mantle
#
            client = new MongoClients.create();

create is not resolved

quiet ice
#

Could you delete some sentences?

quaint mantle
#

but it shows up in the suggestions

#

so i'm confused

#

nvm

#

im stupid

white obsidian
#

anyone know why i get this error

    at java.sql/java.sql.DriverManager.getConnection(DriverManager.java:702)
    at java.sql/java.sql.DriverManager.getConnection(DriverManager.java:228)
    at live.freedommc.cloud.main.sql.MySQL.connect(MySQL.java:34)
    at live.freedommc.cloud.main.HostInstance.<init>(HostInstance.java:65)
    at live.freedommc.cloud.main.HostInstance.main(HostInstance.java:39)```
when i do this
```java
try {
    con = DriverManager.getConnection("jdbc:mysql://" + host + ":" + port + "/" + database, username, password);
    System.out.println("Connected to MySQL");
    return true;
} catch (SQLException ex) {
    ex.printStackTrace();
    return false;
}
lost matrix
white obsidian
#

yeah I know lmao but what really confuses me is that i use it twice in the same project, using the same sql server and even the same MySQL class but one time it works and the other time it gives me this

lost matrix
#

Are you creating the instance in your onEnable?

#

Also make sure to mock the driver class first so it is forced to register itself.

white obsidian
#

well the instance where it doesnt work and gives me this error is in a class that is started from a public static void main(String[] args). The time it works is when I do it using onEnable on my bungee plugin

white obsidian
lost matrix
#

Class.forName("com.mysql.cj.jdbc.Driver");

white obsidian
#

oh yeah i tried that but it gives me ClassNotFoundException

hybrid spoke
lost matrix
#

If its not a spigot application then you need to provide the mysql driver yourself

white obsidian
#

yeah i did

#

idk if i did it correctly though

#

i have a lib folder and the jar file for the driver inside it

#

i tried maven dependency as well but it gave me a NoClassDefFoundError

eternal oxide
#

using maven, shade it

lost matrix
quaint mantle
#

i have question lemme write it

#

i have this

#

and i have this

#

why does this happen?

#

what can i do to prevent this

eternal oxide
#

You using maven?

dusk flicker
#

Needs to be in the resources folder

quaint mantle
#

Okay, thanks

#
        <resources>
            <resource>
                <directory>/src/main/java/plugin.yml</directory>
            </resource>
        </resources>
#

Like such?

tacit drift
#

i got around to setting values in config, but how can i create new values?

#

for example the path example.path with value int 1

quiet ice
#

src/main/resources exists

tacit drift
#

i tried config.addDefault("cells."+player.getName()+".level",1);
plugin.getInstance().saveConfig();
plugin.getInstance().reloadConfig();

quaint mantle
#

I just put it there?

silver shuttle
#

does this still exist? Because I cant find it nor use it

quiet ice
#

yes

dusk flicker
#

should be working

silver shuttle
#

oh im dumb

#

forgot smth

#

ty

spare mason
#

package me.TheWood.org;

import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.plugin.java.JavaPlugin;
import org.jetbrains.annotations.NotNull;

public class Main extends JavaPlugin {

@Override
public void onEnable () {

}

@Override
public void onDisable() {

}

public void EntityDamageByEntityEvent​(@NotNull EntityDamageEvent.DamageCause cause,
double damage) {

}

}

dusk flicker
#

?paste

queen dragonBOT
dusk flicker
#

please ^

spare mason
#

How I can make what only reference to one entity

eternal oxide
#

Try not to use performCommand unless you have no other option

spare mason
cold field
#

If i register a command on the SimpleCommandMap when the plugin is already loaded, will it works?

spare mason
#

What i need to change

#

to only reference to the zombie for double damage

white obsidian
eternal oxide
quaint mantle
#

I put the plugin.yml and it still doesnt work

#

in resources^^

#

No I am not

eternal oxide
#

Did I just get auto bot?

wraith rapids
#

rip @brave glen

eternal oxide
#

sod @brave glen silly choice of name

quaint mantle
#

ok stop pinging him

wraith rapids
#

never

eternal oxide
#

I'm guessing he has notifications muted by now 🙂

#

He's been getting pinged for many months

quaint mantle
#

Lol

cold field
#

Guys?

quaint mantle
#

sup

ivory sleet
#

Yes empee

quaint mantle
#

dont ask to ask

eternal oxide
ivory sleet
lost matrix
cold field
#

ah, it was the answer

#

XD

rigid hazel
#

I'm using the adventure api now and did this:

#
Component message = Component.text("Hallo "+this.getPlayerName(id)+",\n"
                    + "Du wurdest zur Gilde "+this.getMailSender(id)+" eingeladen. Möchtest du beitreten?");

            Component accept = Component.text("Annehmen ");
            Style acceptStyle = Style.style().build();
            acceptStyle.decorate(TextDecoration.BOLD);
            acceptStyle.color(TextColor.color(255, 180, 0));
            acceptStyle.clickEvent(ClickEvent.clickEvent(ClickEvent.Action.RUN_COMMAND, "/invite "+this.plugin.getGuildAPI().getGuildInviteCode(this.getMailSender(id))));
            acceptStyle.hoverEvent(Component.text("Einladung annehmen"));
            accept.style(acceptStyle);

            Component refuse = Component.text(" Ablehnen");
            Style refuseStyle = Style.style().build();
            refuseStyle.decorate(TextDecoration.BOLD);
            refuseStyle.color(TextColor.color(255, 180, 0));
            refuseStyle.clickEvent(ClickEvent.clickEvent(ClickEvent.Action.RUN_COMMAND, "/mailbox delete "+ id));
            refuseStyle.hoverEvent(Component.text("Einladung ablehnen"));

            message.append(accept);
            message.append(Component.text("|"));
            message.append(refuse);

            bookMeta.addPages(message);```
eternal oxide
#

Wrong Server for Adventure

rigid hazel
#

Oh

#

Sorry.

tacit mica
#

Does anyone know a possibility for this? Creating a new file with just file.createNewFile() gives me java.io.IOException: No such file or directory

woeful crescent
#

Does anyone know how I can perform an operation more than 20 times per second?

quaint mantle
#

My plugin has the plugin.yml in the resources folder but this pops up, do I have o add it to the pom.xml

tacit mica
woeful crescent
#

Like send particles for an arrow trail, more specifically

#

How do I do that, I'm not too familiar with threads

tacit mica
#

You shouldn't need to be sending particles more than 20 times a second

#

But for threads

woeful crescent
#

How do I make an arrow trail then?

tacit mica
#

Just a scheduler works fine

#

For every tick create a particle at each arrows position

woeful crescent
#

Yep

#

Doesn't work

#

Arrow moves too fast

tacit mica
#

Could call the method twice or 3 times and use some randomness

#

Or summon the particles a few times

lost matrix
tacit mica
#

Add to it's motion

woeful crescent
lost matrix
quaint mantle
eternal oxide
quaint mantle
#

okay but I'm still getting the error

wraith rapids
#

interpolate the points where arrow is at each tick and draw a line along them

eternal oxide
#

Then you are either building using Artifacts and not lifecycles or your plugin.yml is not in your resources folder of your project.

silver shuttle
#

How do I add multiple TextComponent to spigot().sendMessage() as in
sender.spigot().sendMessage(base + t_10_ + t_10_ + t_1_ + current + t_1 + t_10 + t_100);?

quaint mantle
#

and also it is in the resource folder

eternal oxide
#

?paste your pom

queen dragonBOT
quaint mantle
wraith rapids
#

you merge them into a single component

#

you can't + them together; they're not numbers, they're not strings

silver shuttle
wraith rapids
#

that's fine

silver shuttle
#

it is? okay

#

thanks

wraith rapids
#

shove them into the extra of a text component or something

#

iirc there's a method that takes a BaseComponent[] and gives you a textcomponent with all of the given components in its extra, or something

eternal oxide
silver shuttle
#

I put them all into a seperate TextComponent and then into the sendMessage

quaint mantle
#

Okay it's fixed but I have another error

tacit mica
#

I have no idea why this doesn't work, it worked fine a while ago, changed nothing, and now is being utterly stupid, I have this simple code:

FileManager.writeFile(new File("SpartanSkyblock/Players/" + uuid.toString() + ".json"), toPut);

The writeFile function is this

    public static void writeFile(File fileName, String toWrite) {
        try {
            fileName.createNewFile();
        } catch (Exception e) {
            e.printStackTrace();
        }
        MagmaCore.getInstance().getLogger().info(String.valueOf(fileName));
        try {
            FileWriter fileWriter = new FileWriter(fileName);
            for(int i = 0; i < toWrite.length(); i++) {
                fileWriter.write(toWrite.charAt(i));
            }
            fileWriter.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

Now I do not understand, the directory existed so I made a check for fileName.mkDirs() before creating a new file, AND NOW IT DECIDED TO MAKE ANOTHER FOLDER WITH THE EXACT SAME name

eternal oxide
tacit mica
quaint mantle
silver shuttle
quaint mantle
#

I have this thing

lost matrix
#

?paste

queen dragonBOT
lost matrix
#

Why cant i embed a video?

wraith rapids
#

noob

lost matrix
wraith rapids
#

i don't know

#

you are verified right

lost matrix
#

Is there a limitation on the resolution?

wraith rapids
#

i don't think so

woeful crescent
#

@lost matrix This will work on 1.8, right?

#

Don't worry about the particles, I have an API

paper viper
#

why are you using

#

an outdated api

#

lol

quaint mantle
lost matrix
eternal oxide
#

I don;t use Mongo

wraith rapids
#

mongo bongo web scale reeeee

lost matrix
#

sharding is the secret ingredient

woeful crescent
# paper viper why are you using

I'm working on a project that was started in 1.8, and it wouldn't be worth it to switch the version all the way up to the latest

lost matrix
wraith rapids
#

dev null is web scale

paper viper
#

lol

#

its not like java versions

lost matrix
#

pipe everything into dev null. Its really fast

paper viper
#

where you start early

woeful crescent
#

What do you mean?

idle pike
#

Do bukkit runnables cause lag

paper viper
#

depends

idle pike
#

When run asynchronously

paper viper
#

well what is being ran async

idle pike
#

Sprint detection

lost matrix
paper viper
#

^

idle pike
#

I calculate the position every 2 ticks

paper viper
#

PlayerMoveEvent

idle pike
#

And find the distance

wraith rapids
#

anything can cause lag if done excessively or wrong

#

asynchronous or not

paper viper
#

every 2 ticks?

wraith rapids
#

don't slap async on shit just for the sake of making things async

paper viper
#

you know thats 10 times per second for each player

#

lol

idle pike
#

Yeah

paper viper
#

you sure you want to do that..?

wraith rapids
#

calculating the position is like 3 double subtracts and 3 powers and 1 sqrt operation

#

literally free

idle pike
#

I need to know if the player is sprinting

dusk flicker
#

use the event

wraith rapids
#

jumping to a separate thread is going to take 100x the time

idle pike
#

.is sprinting always returns false

paper viper
#

sqrt is not free at all lmao

#

thats why the squared method exists

wraith rapids
#

literally free in comparison to swapping threads

silver shuttle
#

Ok I still avent figured this out. How do I combine multiple TextComponents into one?

lost matrix
silver shuttle
paper viper
#

are you using the one built into bungeecord?

idle pike
#

With the sprint event will I know when a player is sprinting?

paper viper
#

or the one in adventure?

dusk flicker
#

... thats literally what the sprint event is for

#

... its in the name

idle pike
#

It only calls when the player starts sprinting am I right

dusk flicker
#

store it

wraith rapids
#

it's fired whenever a player toggles their sprint state

tacit drift
#

does any1 have a guide for using custom config files? (to create new paths in the config etc)

silver shuttle
paper viper
#

Are you using any component library

wraith rapids
#

store the present state in a map and you can access it reliably at nanosecond costs

silver shuttle
lost matrix
silver shuttle
paper viper
#

oh

#

yeah uh. im only familier with adventure rn sry

idle pike
#

Does player toggle sprint event also fire when the player stops sprinting

wraith rapids
#

gee i wonder

silver shuttle
idle pike
#

K

tacit drift
wraith rapids
#

does a light switch only work when toggling it on?

lost matrix
tacit drift
#

like create a path for when a player joins the server for ex

silver shuttle
#

ah ok

paper viper
#

or adventure 😄

silver shuttle
#

I have multple TextComponents each with a ClickEvent and want them to be displayed in one line

eternal oxide
#

then look at teh second link. It has examples

silver shuttle
#

oh there it is

#

i see it now

#

thanks

#

ayyy it works now

#

thanks a lot

woeful crescent
glossy scroll
#

is there a way to send the red world border vingette to a player?

lost matrix
glossy scroll
#

yea i saw that

#

just wasnt sure which one caused the red vingette

quiet ice
#

I think you can set the warning blocks to a very high number

lost matrix
#

Or set the border wall 200 blocks away so its not visible and the warning size to something like 400

woeful crescent
#

@lost matrix Do you know where I should run the code you sent me?

young knoll
#

You could probably leave the border alone and just set the warning size to Integer.MAX_VALUE

lost matrix
paper viper
#

the higher the blocks the redder it is

woeful crescent
#

Yeah, I know. I'm wondering about how exactly the marchRay() method functions. If it's called every tick, will it display properly? How often is it called normally? Will the entire arrow trail display before the arrow has run its course? @lost matrix

lost matrix
young knoll
#

Anyone know much about what makes spiders climb walls, I’ve tried messing with the AI goals and navigation controller of mobs, but haven’t had any luck

silver shuttle
#

Dont they always climb walls if they touch them?

ivory sleet
#

no I dont think so

wraith rapids
#

another word for that is interpolation

#

you are interpolating the position of the arrow between the two ticks

silver shuttle
#

Small question how do I prevent a command from showing up in autocomplete when you enter the beginning letters?

woeful crescent
#

Also, is there any way to make a custom name ALWAYS visible on non-armor stand entities?

tame wolf
#

how would i set the owner of a bed?

woeful crescent
#

And when an arrow hits a player, does it die?

wraith rapids
#

it's not a living entity, it can't die

young knoll
#

Arrows from a crossbow with piercing will continue

#

You can look at that

tame wolf
ivory sleet
#

quite frankly, can players even own a bed?

wraith rapids
#

i don't remember beds storing ownership information

young knoll
#

No

#

Villagers might be able to

wraith rapids
#

players do store the last bed they slept at, though

#

and villagers store their bed as a record in their brain iirc

tame wolf
#

well how would i just make

#

some link

#

so that they respawn in thebed

wraith rapids
#

the player class has a method for getting their last bed iirc

tame wolf
#

well what im looking fort is the function that happens when you sleep in a bed

#

it sets your spawn point

#

so i wanna call

#

that function

young knoll
#

I just sent you it

tame wolf
#

thx

wide galleon
#

How can I set a players health to a config value?

ivory sleet
#

uh

#

wdym

#

can u rephrase the question?

wide galleon
#

I want to make a command, that sets the players health to a value, that is specified in the config

ivory sleet
#

ah

#

What do you got as of now?

wide galleon
#

well i have this, but this kills the player for some reason player.setHealth(Main.getInstance().getConfig().getInt("health"));

tacit drift
#

how do i remove path from config?

wide galleon
#

and i have this in the onLoad java getConfig().set("health", "20"); saveConfig();

tacit drift
#

you need to

#

setInt("health",20);

#

not set it a string

wide galleon
#

that doesnt work

wraith rapids
#

use set("health", 20)

quiet ice
#

Because you want to do that as a default

glossy scroll
wraith rapids
#

there is only one set method; the type of entry added depends on the type of the parameter

glossy scroll
wraith rapids
#

if you give it a string "20", it will write it as a string

glossy scroll
quiet ice
#

Also, don't bother setting it programatically, do it manually

wraith rapids
#

if you give it an int 20, it will write it as an int

glossy scroll
#

those ordinals go from 0 to 5, not 1 to 6... right?

wraith rapids
#

yes

#

java is zero indexed

quiet ice
#

This is the switch table though

wraith rapids
#

wait what am i looking at

quiet ice
#

Switch tables behave a bit different and the result of the switch table != the enum ordinal

wide galleon
wraith rapids
#

you are passing the ordinal of the enum constant to the switch block

glossy scroll
#

yea nvm its just decompiler bug

#

well not bug

wraith rapids
#

so you want a zero in there

quiet ice
#

It's not a bug, it's a feature

glossy scroll
#

but its correct in craftbukkit

wraith rapids
#

as the first enum constant has an ordinal of 0

quiet ice
#

All switch on enum code does this

glossy scroll
#

i just was confused about this whole switch table thing

wraith rapids
#

ripcord can't zoom on images so I can't really see shit

glossy scroll
#

protocol lib also says that the packet is sending with the correct amount of warning blocks

#

ACTUALLY ignore that it was just an optifine issue

young knoll
#

Optifine, breaking rendering since whenever optifine came out

white obsidian
#

is there a way I can get a spigot server's name from bungeecord? I searched it up and there was this whole thing about 'channels' that I couldn't understand...

quiet ice
#

Plugin channels? They are pretty much the only option for this

white obsidian
#

yeah that

#

i'll try and figure it out i guess

paper viper
#

you have to either use protocallib or nms

graceful magnet
paper viper
#

i worked with channels before

wide current
#

Sb knows how to build the artefact of the plugin and force replace the oldest one with maven ? (because Windows doesn't like to replace running java stuff

paper viper
#

I beleive the NMS packet is called PacketPlayOutCustomPayload

white obsidian
#

all the things i can find about channels have like player.sendPluginMessage but is there a way i can do it without a player?

paper viper
#

what?

#

thats not how plugin messages work

#

you have to send them to players

white obsidian
#

ok sorry if im dumb i do not get this at all lol

paper viper
#

what are you trying to accomplish here first

#

tell me that

white obsidian
#

i just want to get a spigot server's name from bungeecord

paper viper
#

let me find it

#

correction, you dont always need player. but a lot of the channels do use it

silver shuttle
#

Ok so I have an opinion question

#

I have made a plugin which dynamically adjusts prices of an item based on the items in stock

#

selling and adding increases and decreases the stock

#

now I want to add a command to sell all items

#

But I do not want all items to be sold on the current price

#

but adjust every time an item is sold

#

whats the best way of doing that?

quaint mantle
#

can someone help me?

#

my config isnt working

#

i keep trying to set nerf mob spawners false

silver shuttle
tame wolf
#

how would i change the args for a command to make it so its /(command) [playername]

silver shuttle
#

just define args[0] as playername

tame wolf
#

where would i set that

#

i just wanna make a command that takes the args /(command) [playername]

marble verge
#

how can i do it when i hold an item it gives the player a potion effect

tame wolf
#

so is that how?

#

well thanks

silver shuttle
#

make sure you check that its a valid player

tame wolf
#

how would i do that

silver shuttle
#

umm

marble verge
#

if(sender instanceof Player){

silver shuttle
#

Player t = p.getServer().getPlayer(args[0]);

silver shuttle
marble verge
#

does anyone know how i can get item held event for custom item

eternal oxide
#

getOfflinePlayer(args[0]).isOnline()

tame wolf
#

is this really that complicated?

#

i just want to be able to have a player in the command that i can then use

wraith rapids
#

what am i reading

tame wolf
#

idfk

wraith rapids
#

get the argument the command sender gives you

#

then call getOfflinePlayer with that argument

silver shuttle
tame wolf
#

k

wraith rapids
#

literally 2 methods

tame wolf
silver shuttle
#

sec ill show you

wraith rapids
#

it gets an offlineplayer that corresponds to the given playername

#

and then checks if they are online

silver shuttle
tame wolf
#

why would i want that when i dont care if they are offline nor offline

tame wolf
#

kk

eternal oxide
#

if you get a player who doesn;t exist or is offline you will get a null.

silver shuttle
#

that puts a guaranteed player into playername

wraith rapids
#

getOfflineplayer will always return an offlineplayer

eternal oxide
#

if you use offlinePlayer you will always get an object

tame wolf
#

online works then

wraith rapids
#

again, only works for online players

tame wolf
eternal oxide
#

if the returned offlinePlayer name == null then its an invalid player

wraith rapids
#

there is no way to check if a given username corresponds to an existing player if you want to also include offline players in the search

#

because players are able to change their names

eternal oxide
#

if the name is not null an disOnline() then they are logged in

wraith rapids
#

so however you go about it, it'll only be true for online players

tame wolf
#

ok thanks

silver shuttle
wraith rapids
#

i suppose

#

you'd need to query mojang api with the name, get the uuid, and see if that uuid has played on the server

silver shuttle
wraith rapids
#

about wut

silver shuttle
eternal oxide
#

or Bukkit.getOfflinePlayers() returns every player who has ever joined your server. You can search in there

wraith rapids
#

querying mojang?

#

probably a bit excessive

silver shuttle
sleek pond
wraith rapids
#

yeah, but the names of the offlineplayers as returned by that method are not necessarily up to date

silver shuttle
#

about this

sleek pond
wraith rapids
#

pretty much yes

sleek pond
eternal oxide
#

As he is only interested in online players the offline will be upto date

silver shuttle
#

oh

wraith rapids
#

myeah, assuming he only wants online players

sleek pond
#

you don't

#

need to spam

#

every single line

#

to talk

wraith rapids
#

he did seem a bit confused about it though

quaint mantle
#

ok i really need help im not getting any help in the server section

earnest junco
# silver shuttle about this

you loop over the inventory anyways, so just sell the item one stack at a time and have the price adjustment happen everytime an item is being sold?

silver shuttle
earnest junco
#

well then do it one at a time xd

silver shuttle
#

whats the best method im asking

#

the fastest and most resource efficient

earnest junco
#

Loop or have a method that approximates the price based on the items sold. Like, you probably have a function somewhere with which you adjust the price, so just apply that on a larger scale

silver shuttle
#

yeah the function atm is rlly simple

#

i could use an integral i just realized

#

#mathkicks

#

omg that makes so much sense, just do an integral for x amount of items in their inventory

crisp iron
#

You could create an event for selling the items? And update the value every time the amt decrease

silver shuttle
#

do you know what integrals are?

#

They are literally exactly what I need in this situation, making me able to sell all items at once for the price itll be if you sold them one by one @crisp iron

crisp iron
#

So was that helpful? 😂😂I got a missed impression from that message

wide current
#

Sb knows how to build the artefact of the plugin and force maven to replace the oldest one ? (because Windows doesn't like to replace running java stuff

quiet ice
#

mvn clean install

#

If you mean hotswapping, don't do that

eternal oxide
#

Do not replace jars that are currently running on the server.

quiet ice
#

I mean, it does work, but you should not do that without a proper environment that is prepared for this

eternal oxide
#

you can put jars in an update folder and they will be copied to the plugin folder on server start

paper viper
#

dont hotswap with plugman tho lmao

#

devcm, however, is fine

#

read Piggy's guide

eternal oxide
#

My only other concern is that you mentioned building Artifacts with maven

paper viper
#

you dont need to manually rebuild it

#

you can just recompile the current class?

#

i think thats how it works

#

with devcm

#

but not sure

wide current
paper viper
#

let me pull it up

#

he has a site for it

wide current
#

Thx 🙂

paper viper
#

np

#

Yeah it doesnt rebuild the whole artifact

#

It just recompiles the current class

young knoll
#

I hotswap with /reload a lot in dev >:D

paper viper
#

you cant do that in windows tho lmao

young knoll
#

You can

paper viper
#

cause you cant delete or replace the jar

#

how

young knoll
#

Don't know, windows just lets me replace it

paper viper
#

maybe you can replace but not delete

young knoll
#

Let me check

#

That would indeed appear to be the case

paper viper
#

that is

#

quite weird

#

lmao

#

i dont get why windows has the stupid

#

"you cant delete"

#

so dumb

young knoll
#

I try to design anything I make to handle reloads, or at least make it obvious when it doesn't

silver shuttle
#

How do I convert CommandSender to Player?

eternal oxide
#

if (sender instanceof Player) player = (Player) sender;

paper viper
#

use instanceof to check if it's a Player then perform a cast

#

🥲

silver shuttle
#

tyyyy

wraith rapids
#

note that you aren't converting anything

#

the CommandSender is already a Player

#

you're just casting it

silver shuttle
#

I need to get item in main hand of commandsender

#

so I need that

wraith rapids
#

myes

#

but remember, the object is already a Player

#

casting it doesn't change the object

#

it only changes how you are interacting with it

sinful python
#

Trying to use the Bukkit.getScheduler().runTaskLater() method, what do I put as the first input? It just asks for a Plugin but I'm not sure how to get my plugin, how do I do that?

silver shuttle
#

yea

quiet ice
#

Just note that is could also be the console sender

#

If you are using Java 16 there is an easier syntax, idk it though

wraith rapids
#

or literally any of the dozens classes that implement the interface

paper viper
#

so you can either use di or a singleton

wraith rapids
#

not your main class; an instance of your main class

sinful python
#

So I'd just say 'Main' if my main class is called that?

paper viper
#

no

wraith rapids
#

no

quiet ice
#

nonono

paper viper
#

an instance

#

correction

sinful python
#

Okay

paper viper
#

i guess i wasnt noob talking enough lol

quiet ice
#

Your instance of your JavaPlugin class

wraith rapids
#

if you are in your plugin's onEnable or something, it will be this

sinful python
#

But yeah I'm a noob

wraith rapids
#

because onEnable is a method declared by the main class of your plugin, and is not static

#

therefore this refers to the current instance of this class

sinful python
#

I can't use 'this' sadly bc it's in my listener class

wraith rapids
#

then you need to pass the this to your listener

paper viper
#

pass your main instance class into your listener class using di

wraith rapids
#

usually in its constructor

#

so you can store it in the listener and give it to the method later

paper viper
#

or you can use a static singleton, but we will hate you

#

so use the constructor method

#

(di)

silver shuttle
#

does this work?

wraith rapids
#

probably not

silver shuttle
#

oh wait

#

i need getType

sinful python
#
        return this;
    }

like this?

wraith rapids
#

that's going to give you like an ItemStack{STONE x 23} or something

#

no, not quite

#
class MyPlugin extends JavaPlugin {
    onEnable() {
        new MyListener(this);
    }
}

class MyListener implements Listener { 
    MyListener(MyPlugin plugin) {
        Bukkit.getScheduler().runTaskLater(plugin, );
    }
}

like this

paper viper
silver shuttle
paper viper
#

What?

wraith rapids
#

you pass your MyPlugin instance to the MyListener

#

which then passes it to the scheduler method

silver shuttle
paper viper
#

no

#

Player#getInventory to get the player's inventory

silver shuttle
#

oh .getMainHand

paper viper
#

then getItemInMainHand()

sinful python
#

It shouldn't have taken me this long to understand

#

noob moment

wraith rapids
#

this is object oriented programming 101 so make sure to commit it to memory

sinful python
#

ik I just haven't had much practice with actual coding yet

wraith rapids
#

just remember that everything is always an object

sinful python
#

Yep

#

Is it normal to have like 20 imports for one small class or is there a better way to do it?

#

I'm using all of them*

deft geode
#

This is the right way to reset a bossbar if it's value is over the max? I'm having this repeat every second and I want it to reset if the bossbar (10 segments) reaches it's max amount:

if(myBar.getProgress() == 1) {
  myBar.setProgress(0);
}
myBar.setProgress(oliviaBar.getProgress() + 0.1);
lost matrix
cinder thistle
#

if it's unused imports chuck em

lost matrix
cinder thistle
#

but i've seen hundreds of imports before

deft geode
lost matrix
#

Solves all the problems: import java.*; import com.*; import org.*; import net.*;

cinder thistle
#

granted that doesn't mean you should aim for a shit tonne of imports

#

dear god I hate wildcard imports

lost matrix
#

btw pls dont

paper viper
#

no pls do

#

its very good

#

/s

deft geode
paper viper
#

does java.* even work tho?

#

lol

#

i dont think it does

cinder thistle
#

probs not

lost matrix
young knoll
#

import *

quiet ice
#

Luckily that is not how java works

young knoll
#

Not with that attitude

fading palm
#

anyone know a way to give a player spectator mob effects? like the ones you get when left clicking them in spectator mode

#

it'll probably be quite hacky but idm

lost matrix
quiet ice
#

You mean applying a shader?

fading palm
#

yeah well i need to remove the mob and make the player keep it ig

lost matrix
#

Oh you mean the visuals only?

fading palm
#

ya

quiet ice
fading palm
#

thanks, i'll look into that

quiet ice
#

You'd likely make the player spectate the mob, but that will cause a few other issues

fading palm
#

ig ill have to use protocollib?

quiet ice
#

Or NMS

fading palm
#

ah ye

lost matrix
#

Create a dummy player, delegate all packets to the dummy instead of the player. Set the actual player in spectator mode and let him spectate/control the dummy.

quiet ice
#

Reflections also does the trick

fading palm
#

I'm not very familiar with this part of plugin development so i'll have to do some research 😓

quiet ice
#

However you'd need to make the client assume that they are controlling a creeper/enderman/etc

lost matrix
fading palm
#

:/

cinder thistle
#

well he's not wrong lol

minor garnet
#
    public Entity getClosestLoot(Location l, double r) {
        Entity e = null;
        for(Entity entity : l.getChunk().getEntities()) {
            if(entity instanceof ArmorStand && l.distanceSquared(entity.getLocation()) < r) {
                e = entity;
            }
        }
        return e;
    }```
is there a simpler way?
lost matrix
#

r, l, e ...

minor garnet
#

yes i k

#

r = radius l = location e = entity

lost matrix
#

then name it like that 😄

minor garnet
#

later

#

which way would you create this method

young knoll
#

That won't work if the entity is across a chunk border

lost matrix
#

the chunk thing is not really viable as a location can be on the corner of a chunk.

minor garnet
#

thanks for that statement, then i need get all entities in world

#

something that makes me agonized

lost matrix
#
  public Optional<Entity> getClosestTo(final Location location, final double radius, final Predicate<Entity> filter) {
    return location.getWorld().getNearbyEntities(location, radius, radius, radius, filter).
        stream()
        .min((e1, e2) -> (int) (e1.getLocation().distanceSquared(location) - e2.getLocation().distanceSquared(location)));
  }
#

might need to swap e1 and e2. Im not 100% sure if this returns the farthest or closest one.

lost matrix
# minor garnet

Or in simpler terms:

  public Entity getClosestTo(final Location location, final double radius, final Predicate<Entity> filter) {
    Entity closest = null;
    double shortest = Long.MAX_VALUE;
    for (final Entity entity : location.getWorld().getNearbyEntities(location, radius, radius, radius, filter)) {
      final double distSq = entity.getLocation().distanceSquared(location);
      if (distSq < shortest) {
        shortest = distSq;
        closest = entity;
      }
    }
    return closest;
  }
wraith rapids
#

streams 👀

wide current
#

Sb knows the way to set daylight detector on/off ?

quaint mantle
wraith rapids
#

i'd try looking into Powerable but idk

#

or AnaloguePowerable i guess would be more appropriate

#

i was taking a break while I spawned in a horde of alts to hide in paper

#

i've been to the paper serbur occasionally but spigget gives me pimples so I've been avoiding it

golden musk
#

not to be a total noob or anything, but the tutorial I'm following has this I assume to import the spigot API but it won't work for me. Note is I'm pretty sure he's using 1.15.2 or something and I

#

'm using 1.16.4

#

sent message early lol

quiet ice
#

Are you using maven or gradle?

quaint mantle
#

paper discord is shit

wraith rapids
#

you're probably not depending on it properly

golden musk
quiet ice
#

If maven, send you pom.xml, if gradle send your build.gradle

wraith rapids
#

paper discord is alright if you can get past the horde of noobs that ask dumb questions

quiet ice
#

Do you have a pom.xml or build.gradle?

wide current
wraith rapids
#

get the block state

#

or block data? idk tbh

#

one or the other

quiet ice
golden musk
#

i dont have intellij idea i'm using eclipse

wraith rapids
#

get fucked then i guess

quiet ice
golden musk
#

alright ty

quiet ice
#

It is severely outdated though

wraith rapids
#

most eclipse related things are

#

like nobody uses eclipse these days, except the old beards

quiet ice
#

First of all use Java 11 or 15, Java 7 is outdated af

wraith rapids
#

or at the very least 8

cinder thistle
#

eclipse is great

quiet ice
#

Then, use org.spigotmc as the groupId and spigot-api as the artifactId; bukkit is no longer published since 1.16

cinder thistle
quiet ice
#

I also use it lel

golden musk
wraith rapids
#

there are like 4 people that I know that use eclipse

quiet ice
#

Then use Java 15

golden musk
quiet ice
#

Just note that you have to specify it in your maven config

golden musk
#

i just said i think im using java 15

quiet ice
#

Read the guide first

#

Then follow all the changes I proposed

#

I also will edit that guide soon (TM) once I find out what my credentials are (and hopefully I have edit perms there) to update it to 2021

cinder thistle
golden musk
quiet ice
#

I already did the Screenshots (surprisingly there are absolutely no changes outside of look&feel despite the screenshots being over 6 1/2 years old)

#

Eclipse has maven built-in

golden musk
#

oh

cinder thistle
#

eclipse gradle support is ass tho

#

barely works

quiet ice
#

It works greatly!

#

Never had any issues where I blamed eclipse instead of gradle

cinder thistle
#

it's trash

#

had so many issues with eclipse

quiet ice
#

So far I always blamed gradle since it does not want to run newer versions of java

crystal cliff
#

Eclipse is trash in general

cinder thistle
#

nah

crystal cliff
#

IDEA for the win

cinder thistle
#

eclipse is objectively just fine

quiet ice
#

Eclipse is not trash

eternal oxide
#

Eclipse is great. Its all personal choice but to state one is better is very subjective.

quiet ice
#

IDEA also has issues (very poor performance) that could render it unusable for a few people

wraith rapids
#

i personally prefer eclipse over ij by a large margin

#

ij just has more features and is less clunky so i'm forced to use it over eclipse

#

which is a travesty

#

ij is too heavy and too full of eyecandy and useless shit

eternal oxide
#

If i was programming for a living I'd be using IDE. As a pass time its Eclipse all teh way

cinder thistle
#

I can't even test plugins anymore because of intellij

wraith rapids
#

in conclusion everything fucking sucks

cinder thistle
#

u right

#

jfx fucking eats through my ram

quiet ice
#

Ah, it's JFX that causes this?

young knoll
cinder thistle
#

javafx eats through ram, yes

#

compared to swing that is

quiet ice
#

Good to know

cinder thistle
#

looks nicer tho

main dew
#

How update light use ChunkSection?

eternal oxide
#

You should word your question better...
I've replaced a bunch of blocks using NMS but the lighting needs to be recalculated. How would I do that for a specified area?

wraith rapids
#

how update light use chonbk section!!!

gaunt eagle
#

wut... why?

eternal oxide
#

You know there is a slightly slower method that does update the lighting?

wraith rapids
#

maybe depend on worldedit and let their api worry about it for you 👀

main dew
#

I use 3 metod with this link but this metod don't update light

gaunt eagle
#

isvalidenum is removed?

eternal oxide
#

Why not use the slower method and not have the lighting issues?

main dew
#

I use chunkPacketEditor and better use PacketMultiBlockChange

eternal oxide
#

Method 2 is still a LOT faster than vanilla but it handles lighting

main dew
#

realy?

eternal oxide
#

vanilla 60k. method 2 2.19 million.

marble verge
#

how do i damage entities in a radious?

#

I got nearby entities

#

but now i want to damage them

cinder thistle
#

loop through them

wraith rapids
#

spawn a tnt at their feet

main dew
wraith rapids
#

or an anvil above them

eternal oxide
main dew
#

give me moment I must check this xD

#

@eternal oxide but problem I use 1.12.2 and this metod don't work on 1.12.2 maybe you have metod to update light with ChunkSection?

wide current
# wraith rapids get the block state

There is an issue :

if (!(b.getState() instanceof DaylightDetector))
  return;

When I'm clicking on the daysensor, it returns (I've printed things for each step to make sure it's here that function returns)

eternal oxide
wraith rapids
#

did you try it with block data instead

deft geode
#

Floating point math 🙃

wraith rapids
#

are you sure you're importing the correct DaylightDetector class

marble verge
#

Wait so e.damage(20) works?

wide current
#

One where I can set power : import org.bukkit.block.data.type.DaylightDetector;

wraith rapids
#

that is not a block state

#

that is block data

marble verge
#

idk it says cannot resolve damage in entity

wraith rapids
#

org.bukkit.block.DaylightDetector is the state one

#

use getBlockData or whatever it was instead of getState

eternal oxide
wraith rapids
#

note that not every entity is damageable

#

i think 🤔 been a while

eternal oxide
#

correct

#

has to be instanceof

wraith rapids
#

there are some weird instance relations in bukkit

#

like all ItemMetas being damageable despite damageable being a different interface

main dew
#

@eternal oxide I used the chunkSection method and I have now in so many place no global cord (264, 50, 50) I have local cord in section (14, 2, 2)

marble verge
#

so like this?

#
((Damageable) entity).damage(20);
main dew
#

yea I know my Enlish is terrible ;/

eternal oxide
#

Yeah, I have no idea what you were saying 😦

marble verge
#

Huh it says cannot resolve symbol entity

main dew
#

in all place (x&15 , y&15 , z&15)

#

will change it for a long time; /

marble verge
#

Wait Nevermind.

#

Solved it I hope.

quaint mantle
#

is this allowed? @EventHandler public void onPlayerHit(EntityDamageByEntityEvent && EntityDamageEvent e)

main dew
#

I can check if the lighting works with this method and latter copy this

#

you register this?

quaint mantle
#

alr thought so

#

is there a delay thing? like delay an event

ivory sleet
#

Uh no

#

Or like for what

quaint mantle
#

like if I wanted to delay an event for 20 ticks

#

for example if I hit something, 20 ticks later the hit event would happen

main dew
#

moment what? (EntityDamageByEntityEvent && EntityDamageEvent e) it is posible? xD

ivory sleet
#

You mean your code would run 20 ticks later?

quaint mantle
#

yes

ivory sleet
#

Use the BukkitScheduler

quaint mantle
#

ok ty

ivory sleet
#

Bukkit.getScheduler().runTaskLater(plugin, () -> {

}, 20L);

quaint mantle
#

ok ty

gaunt eagle
#

i cant understand this, can anybody help?

#

Main:

eternal oxide
#

You tried to create a new instance of your plugin

merry kindle
#

instead of making new

#

just make it this

#

so like dasymaManager = this;

#

wait

#

no

#

im dumb

gaunt eagle
#

it says Main line 10

merry kindle
#

its cause i named it main

eternal oxide
#

In either your listener or your command you use new Main

gaunt eagle
#

oh

#

[23:19:58] [Server thread/WARN]: [RutbeSistemi] Loaded class net.turkgamerz.main.Main from BossBar v1.0-SNAPSHOT which is not a depend, softdepend or loadbefore of this plugin.

#

it about BossBar v1.0-SNAPSHOT?

quaint mantle
gaunt eagle
#

yeah

#

i fix it xD

eternal oxide
#

or, you have two jars of the same plugin in your plugins folder

quaint mantle
#

Are there any built in placeholders?

eternal oxide
quaint mantle
#

oh so can I use plugin then

#

or

#

hm

eternal oxide
#

your plugin instance

quaint mantle
#

this?

eternal oxide
#

yes if its in yoru JavaPlugin class

quaint mantle
#

kk

#

ty

#

Would I put the event that I'm delaying into these brackets? Bukkit.getScheduler().runTaskLater(this, () -> {/*event go here?*/ }, /* Int goes here*/

eternal oxide
#

not an event, code goes in there

#

whatever you want to happen after the delay

quaint mantle
#

ok ill try

silver shuttle
#

how can this happen when spigot page says it can be used with material?

quaint mantle
#

what is your api version?

silver shuttle
#

sorry, Im new to coding plugins, is that the version of my spigotmc library?

eternal oxide
silver shuttle
eternal oxide
#

all you are doing there is getting teh Material of the item in hand

ornate heart
#

Would I have to make a bungeecord plugin if I wanted cross-server teleportation?

eternal oxide
#

are you trying to remove teh item in hand?

silver shuttle
eternal oxide
#

with the same type as that in hand?

silver shuttle
#

yes

#

and .remove(Material) should work

quaint mantle
#

Bukkit.getScheduler().runTaskLater(this, () -> { p.setVelocity(e.getDamager().getLocation().getDirection().multiply(getConfig().getInt("knockback-of-players")))/*/It expects a ";" here*/}, Knockback.getInstance().getConfig().getInt("delay-of-kb-players")); what do i do it expects a ;

eternal oxide
silver shuttle
eternal oxide
#

else use remove(new ItemStack(sellitem_material));

silver shuttle
eternal oxide
#

or remove(itemInHand)

#

teh remove method removes all

wide current
#

is there method to update things (each tick) during all period server is online ? Or I need to use Bukkit runnables ?

silver shuttle
#

but since its an itemstack its only gonna remove the stacks in the inventory that are exactly the same, including name and stack size

#

wouldnt it?

eternal oxide
#

runnables/scheduler

wide current
eternal oxide
silver shuttle
eternal oxide
#

then remove material is the one you want

silver shuttle
eternal oxide
#

actually no, you can use material or ItemStack. It only matches on Material for both

wide current
eternal oxide
silver shuttle
#

1.16.5-R0.1-SNAPSHOT

sage swift
#

no, he's trying to do Material#remove

eternal oxide
#

then remove material shoudl be good

sage swift
#

need to do Inventory#remove

#

player.getInventory()

eternal oxide
#

lol, you need to do Inventory remove

silver shuttle
#

oh lol

#

yeah now it works

#

thanks

eternal oxide
#

I can;t see his code too well. He uses screenshots that I can;t read

main dew
#

How get chunk with chunkSection?

eternal oxide
#

nmsWorld.getChunk()

main dew
#

but with chunkSection?

eternal oxide
#

What is chunkSection

main dew
#

chunk with chunkSection

#

posible?

eternal oxide
#

I have no idea what you are calling chunkSection

main dew
#

class ChunkSection xD

quaint mantle
# wide current Could u show all ur lambda function ?

Bukkit.getScheduler().runTaskLater(this, () -> { p.setVelocity(e.getDamager().getLocation().getDirection().multiply(getConfig().getInt("knockback-of-players")))}, Knockback.getInstance().getConfig().getInt("delay-of-kb-players"));

eternal oxide
#

whats the nms path?

quaint mantle
#

?paste

queen dragonBOT
main dew
#

then I have to change the constructor

wide current
quaint mantle
#

oh ok so

golden turret
#

lambda methods with 1 line dont need {} and ;

#

but lambda methods with 2+ lines needs

wide current
quaint mantle
quiet ice
wide current
#
Bukkit.getScheduler().runTaskLater(this,
  () -> { p.setVelocity(e.getDamager().getLocation().getDirection().multiply(getConfig().getInt("knockback-of-players")));
});
silver shuttle
#

how do I easily get the total amount of items matching a Material in the inventory of player?

wide current
quiet ice
#

that's true

quaint mantle
wide current
#

Yes, too much )
Put only 1

deft geode
#

Is it normal for the onEntityInteract event to double fire?

#

Because it looks like it's double firing

eternal oxide
quaint mantle
#

I am confusion