#help-development

1 messages · Page 2296 of 1

proven ocean
#

it's a vanilly-only name I bellieve

#

it's smth like "item.minecraft.potion.effect.night_vision" that

#

/give @s stone{display:{Name:'{"translate":"item.minecraft.potion.effect.night_vision"}'}} this command works just fine

#

I believe I forgot "display:{Name:'{"

#

bruH

#

Yeah idk, i don't get it :(

#

but I have to go now. If I find a solution imma update you

twilit roost
#

how can I make this work using velocity?
when I tried setting velocity, it launched me way too far from the ship

Location tpTo = p.getLocation().clone();
            tpTo.setPitch(p.getLocation().getPitch());
            tpTo.setYaw(p.getLocation().getYaw());
            Vector direction = prevLocation.clone().subtract(newPos).getDirection().multiply(-1);

            double movedBy = prevLocation.clone().distance(newPos);

            tpTo.add(direction.multiply(movedBy));


            Gizmo.createSphereGizmo(tpTo,5,Color.RED);
            p.teleport(tpTo);

prevLocation - ship's previous location
newPos - ship's new position

tardy delta
#

damn its a ship ladies and gentlemen

#

i dont think a real pirate would see a difference

lost matrix
twilit roost
#

soo I just made so player rides together with ship
but I just teleport him and it doesn't look smooth at all, also can't look around

but if I would setVelocity,it would be smooth and nothing would be blocked for player
but when I tried setting players velocity to tpTo.getDirection().multiply(somethings idk)
I just got launched away

lost matrix
twilit roost
#

yes
im using world edit api for that

noble forge
#

oh my

#

thats why its not smooth

twilit roost
#

by not smooth I mean seeing teleportation

noble forge
#

yeah

#

youre ship is moving by 1 block

#

without interpolation or anything

#

thats what is causing the sudden movement

lost matrix
#

I think i would try lerping the distance of the player.

noble forge
#

that wont solve the issue

noble forge
#

the root of the issue is the ship not moving smoothly whereas the player is

lost matrix
#

So if the ship moves one block in 5 ticks you simply teleport the player 5 times while the ship only moves once.

twilit roost
#

oooh

noble forge
#

but then youre not always in the same spot on the ship?

twilit roost
#

you can move
and it works fine
just not interpolated

lost matrix
noble forge
#

and that will also cause the sudden movement to appear

#

the reason its looking weird is because youre frame of reference (the ship) is not moving at the same rate you are

#

lerping the player position wont solve the issue since youre frame of reference is still going to change relative to you

twilit roost
#

well player moves while ship moves

#

*when

noble forge
#

just try it

#

whatever

twilit roost
#

smhw

lost matrix
#

asVector(target - base) * C
Where C is some constant which is directly proportional to the speed of the ship

twilit roost
#

maybe
sNewLoc - sOldLoc .distance?

lost matrix
twilit roost
twilit roost
#

nvm

solid cargo
#

any way i can send a player to another server on spigot?

#

not bungee

eternal oxide
#

no

solid cargo
#

brah

#

ayo how can i get this boolean?

#

config.get().getBoolean?

tardy delta
#

config.getBoolean("Power_Button.cool")

solid cargo
#

ohhh

#

thanks

tardy delta
worldly ingot
#

But if you're wanting to send a player from your server to, say for example, Hypixel, no that's not possible

tardy delta
#

if the other server is on the same proxy, you can use plugin messages right?

round eagle
#

idk if it still is. havent played

worldly ingot
#

This is Java edition ;p

golden kelp
#

how can I get data from one server to other one

basically I have one server which is kinda like the hub, now I want to show the player count of a DIFFERENT server (which is the minigame server)

worldly ingot
#

Generally you’d use something like Redis

#

You can use an SQL database but Redis is probably faster for that sort of stuff, especially given that you can make use of pub/sub

quaint mantle
#

Cannot resolve method 'size()'

#

halp

pliant plover
#

Send the entire line pls

frosty tinsel
noble lantern
#

This so desperately pisses me off and no matter what I do I cant fix this shit:

Theirs: https://paste.md-5.net/moqejabotu.xml
Mine: https://paste.md-5.net/qazimulewo.xml

(Do note ive upgraded maven special source and re-ran build tools)

I am trying to import a module from CitizensAPI (Theirs) but for some FUCKING reason, even when compiling the source LOCALLY on MY OWN OBFUSCATION JARS, Objects from "Theirs" gets remapped differently to mine

In the screenshot, I have CitizensNPC's src code open, and its ServerPlayer but when i import it through maven (Wether its repo, the mapped jar, unmapped jar, etc) The ServerPlayer (And many other objects) of the imported module go to shit (See screenshot)

zenith gate
#

is using

Bukkit.getServer().getPluginManager().getPlugin("Wired");

a viable way of getting my other plugin to use it's methods?
if so is it the same way of registering events? just from another plugin

noble lantern
#

and here is src code, on my machine perfectly fine as ServerPlayer, yet when imported via maven no matter what the mappings are fucked

quaint mantle
#
 new BukkitRunnable() {
            @Override
            public void run() {
                for (Player player : Bukkit.getOnlinePlayers()) {

                    ItemStack item = player.getInventory().getHelmet();

                    if(item == null) {return;}
                    if(item.getItemMeta() == null) {return;}
                    if(item.getItemMeta().getDisplayName() == null) {return;}
                    ItemMeta meta = item.getItemMeta();
                    String ItemName = item.getItemMeta().getDisplayName();
                    if (ItemName.equals(ChatColor.RED + "Dctr's Space Helmet")) {
                        Random r = new Random();
                        int color = r.nextInt(colors.size());
                        Material material = colors.get(color);
                        item.setType(material);
                        item.setItemMeta(meta);
                    }
                }
            }
        }.runTaskTimer(this, 20, 20);```
#

the .size and .get is showing an error

frosty tinsel
quaint mantle
#
@Override
    public void onEnable() {

        getCommand("spacehelm").setExecutor(new SpaceHelmetCmd());
        getServer().getPluginManager().registerEvents(new SpaceHelmetListener(), this);

        byte[] colors = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
        ItemStack item = new ItemStack(Material.STAINED_GLASS, 1, (byte) 0);
        ItemStack item1 = new ItemStack(Material.STAINED_GLASS, 1, (byte) 1);
        ItemStack item2 = new ItemStack(Material.STAINED_GLASS, 1, (byte) 2);
        ItemStack item3 = new ItemStack(Material.STAINED_GLASS, 1, (byte) 3);
        ItemStack item4 = new ItemStack(Material.STAINED_GLASS, 1, (byte) 4);
        ItemStack item5 = new ItemStack(Material.STAINED_GLASS, 1, (byte) 5);
        ItemStack item6 = new ItemStack(Material.STAINED_GLASS, 1, (byte) 6);


        new BukkitRunnable() {
            @Override
            public void run() {
                for (Player player : Bukkit.getOnlinePlayers()) {

                    ItemStack item = player.getInventory().getHelmet();

                    if(item == null) {return;}
                    if(item.getItemMeta() == null) {return;}
                    if(item.getItemMeta().getDisplayName() == null) {return;}
                    ItemMeta meta = item.getItemMeta();
                    String ItemName = item.getItemMeta().getDisplayName();
                    if (ItemName.equals(ChatColor.RED + "Dctr's Space Helmet")) {
                        Random r = new Random();
                        int color = r.nextInt(colors.size());
                        Material material = colors.get(color);
                        item.setType(material);
                        item.setItemMeta(meta);
                    }
                }
            }
        }.runTaskTimer(this, 20, 20);
    }
}```
frosty tinsel
quaint mantle
#

so what I do

frosty tinsel
#

You have to use colors.length

quaint mantle
#

do I do dis or what tomasan told

frosty tinsel
#

Both

quaint mantle
#

so colors.length?

#

but what about the colors.get(color); eerror

frosty tinsel
#

Use colors.length to get the size and colors[int] to get Xth element

quaint mantle
#

also which line was da return thing

#

thanks guys

#

contniue

#

alr

quaint mantle
ornate patio
#

General design question:
So I've implemented a kind of design that loads and unloads player data into memory, similar to this: https://www.spigotmc.org/threads/working-with-data.562421/

But my question is how would I create a command to paginate through all player data? I can't just query the database because it won't be up to date all the time.

#

yes but I want to paginate through all player data

#

loaded and unloaded

frosty tinsel
#

Load all

tardy delta
#

dont think you want to create a new random for each player

ornate patio
frosty tinsel
#

And then paginate

frosty tinsel
frosty tinsel
#

Or query the database for three pages ahead

ornate patio
#

my bad

frosty tinsel
#

And query the next on the go

ornate patio
#

hmm

#

okay I'll try to see if I can do that

#

i just feel like i'm gonna run into a logic issue

#

i'll see

pliant plover
#

public void onPlayerRespawn(PlayerRespawnEvent event) <- why doesn't this code fire when someone respawns?

naive bolt
#
  public static void AsyncChatHookEvent(AsyncChatHookEvent e){
    plugin.getLogger().info("Got event");
    Player p = e.getPlayer();
    String s = e.getChannel().toString();
    p.sendMessage("You spoke in: "+s);
  }
``` can anyone see why this wouldnt work
its using the `import com.palmergames.bukkit.TownyChat.events.AsyncChatHookEvent;`
drowsy harness
#

Best way to check if an ArmorStands block on head is colliding with something?

pliant plover
#

I have put the Eventhandler

#

I have also implemented the listener

eternal oxide
#

implement & register?

pliant plover
#

Its in my Main class

#

oh

#

ok, thanks for helping

#

ListenerClass can't be resolved in a type

#

do I have to put Listener in there?

#

so that I have only one this?

quaint mantle
#

da thing you told colors[color] didnt work

#

D:

undone axleBOT
#

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

quaint mantle
#

oh

pliant plover
#

"this" doesn't work

tardy delta
#

provide your plugins instance

pliant plover
#

but it is my main class

#

Bukkit.getPluginManager().registerEvents(new Main(), this); but this does work

delicate lynx
#

well that explains it

eternal oxide
#

god no. NEVER new Main()

#

yep

pliant plover
#

why does it work now ._ .

delicate lynx
#

?main

pliant plover
#

Bukkit.getPluginManager().registerEvents(this, this); like this it works

delicate lynx
#

yeah because you properly registered the event that way

solid cargo
#

how can i redirect to another bungee server within my network using spigot api?

quaint mantle
#

Material material = colors.get[color];
I kept code as this
Cannot resolve symbol 'get'

tardy delta
#

learnjava moment

#

use ThreadLocalRandom.current() instead of new Random()

ornate patio
#

another question

ornate patio
#

is it proper to load the data and then unload it later on a certain interval when it all gets flushed

quaint mantle
#

but wont that break the use of the plugin?

#

like

#

AH

#

well then wont it break the plugin? like the glass needs to be an armor

#

a helmet

#

I did

#

sooo

#

wat I do for the lasrt part

#

last

eternal oxide
#

I think in 1.8 its somethign like setTypeandData

#

or setType(Material, data)

#

I forget, its years ago

#

teh data being a byte

noble lantern
#

when can special source be for gradle

#

im tired of this

eternal oxide
#

Maven love 😄

noble lantern
#

hell no

#

not after today and its bs i put up with

#

hoever i did learn maven modules

#

so something good came out of it

eternal oxide
#

Go on... You know you want too... Just a little Maven

noble lantern
#

gradle z_aCRYYY

#

3 hours for this

#

not bad

eternal oxide
#

It OK, its not addictive, honest... Just one little taste.

river oracle
#

use maven come on do it just use it just once

noble lantern
#

why yall love maven so much z_aCRYYY

eternal oxide
#

It not really love. We just don;t need Gradle. Its not because we are addicted twitch honest.

river oracle
#

I just don't need gradlew Maven has everything I need I can stop any time and convert anyways

eternal oxide
#

Yep, we can stop any time we want

river oracle
#

yea

noble lantern
#

bro its literally server player

#

ffs

eternal oxide
#

yes

river oracle
#

I'm sure this would be easier with maven

noble lantern
#

Wtf even is EntityPlayer remappings from???

noble lantern
eternal oxide
#

strokes his maven

noble lantern
#

wai

#

this shit just compiled

#

somethings not right

solid cargo
#

is there a way i can bukkit.dispatchcommand as an opped player. not consolesender, but opped player

flint coyote
#

you would have to check if the player is op yourself. Otherwise he will simply get a "no permission" result

solid cargo
#

why does this...

#

produce this

#

and yes, i have bungee

frosty tinsel
solid cargo
#

yes

#

doing it manually works perfectly

frosty tinsel
#

It's probably not gonna work, because it can't communicate with bungee

solid cargo
#

a l t e r n a t i v e s ?

frosty tinsel
#

You know it simulates executing the command on the Spigot server, but on on bungee

#

You'll have to use plugin messaging

#

And send a message to the bungee, to move the player to different server

frosty tinsel
solid cargo
#

thanks

charred blaze
#

what can i do on this static things?

#

32 bit

frosty tinsel
#

?learnjava

undone axleBOT
charred blaze
tardy delta
#

no

#

thats not the point of static

frosty tinsel
frosty tinsel
charred blaze
#

is there any way with i can use getDataFolder() in static context whithout setting plugin to static?

tardy delta
#

?di

undone axleBOT
tardy delta
#

have a plugin field

#

and initialize it with the constructor

charred blaze
tardy delta
#

whats the problem?

worldly ingot
#

Yeah. Bungee = proxy events. Bukkit = server events (like block breaking)

charred blaze
#

my problem is: i want to make String url static but i cant use getDataFolder() then

lost matrix
#

All bukkit events are handled server side already...

lost matrix
lost matrix
#

Bungee doesnt know about events or spigot... it doesnt know what kind of server is on the other side.

lost matrix
carmine hatch
#

is it recommended to update loot tables with spigot or should I just make a datapack instead?

charred blaze
charred blaze
ripe urchin
#

Hi there, I was interested in getting into minecraft development. Have been trying out a few random things just to see how it works etc. Already know my ways around java a bit, but never touched spigot plugins. Would anyone have a guide for complete beginners, or at least point to one where i can get started on how this all works?

charred blaze
carmine hatch
ripe urchin
#

i know how to code just how the basics of getting started work. What people would consider a good place to get started in spigot development

#

i know minecraft itself plenty enough too lol

river oracle
lost matrix
charred blaze
carmine hatch
#

as someone who doesn't know the very basics of java, I can confirm that isn't enough information for me

#

do you mean that making a custom recipe just stores it in memory when you start the server up?

noble lantern
#

i set my static plugin instance after i initalize all my main class variables

charred blaze
#

im trying to know that now

#

by asking you

carmine hatch
#

yeah I'll play around with it just wasn't sure if it was going to be the best course of action, but it looks like there is this LootGenerateEvent I can use so that's a good start

#

thanks 😄

ripe urchin
#

was mostly looking for some guide on how to set up your environment, get your basic package structure etc. Can't find this on the spigot website itself (unless i'm completely overlooking it)

#

already found the api docs themselves

charred blaze
#

getting instance

ripe urchin
#

ah yeah nah i use IDEA

worldly ingot
#

You can have a bungee plugin and a spigot plugin in the same .jar, if that's what you mean. Though if your plugin is installed on Bungee, no, you're not able to handle anything Bukkit-related because it doesn't exist on the proxy. It has no concept of worlds.

hot wolf
#

How can I use functions of other classes (from another plugin of mine) in my new plugin? Because when I just add the Economy plugin as a dependency and use DatabaseUtil.getBalance(String uuid);, Maven wants to stab me

placid birch
#

I've just started making plugins, but a lot of people say I should learn Java before even trying. Is MOOC Helsinki a good guide (if anyone else here has experience with it).

ripe urchin
#

ah there's a plugin for it i see

#

that helps

hot wolf
#

Same but people tend to be unwilling to help you. In my case it was fine ig, because I already had experience with a lot of other languages tho

ripe urchin
#

already had java classes in uni so that's not the order i can take haha

hot wolf
#

I honestly think that learning by doing is a great method to learn programming languages

#

true

hot wolf
placid birch
hot wolf
#

Hashmaps are awesome

#

Even though Java isn't (personal opinion)

carmine hatch
#

Arraylist is super easy to learn and super powerful too 😄

delicate lynx
#

store the inventory somewhere

hot wolf
#

HashMap, for runtime ig

#

Not sure the HashMap works

carmine hatch
#

are you saying you can store an entire inventory with its' exact contents as a value on the hashmap?

hot wolf
#

sure

hot wolf
delicate lynx
#

save the inventory somewhere else

#

if you add contents and close it, the items are there still

carmine hatch
#

true

carmine hatch
#

I think my buddy said hashmaps are only stored in memory so you would have to redefine the inventory on startup every time too

hot wolf
#

ArrayList or HashMap should do the job. Regarding resources and efficiency, idk

carmine hatch
#

that's crazy I didn't know you could use such complex values

#

the only examples I've seen were like UUID's and strings lol

hot wolf
#

Not sure it's smart to store such complex Objects in a hash map though. But idk

#

I'm not familiar with the Space complexity of Hash Maps

#

wdym

#

ofc, i think storing the whole inv does that though.

carmine hatch
#

is there not just an already defined vanilla minecraft grindstone inventory you can access without all this hashmap work, or are you making your own new version of a grindstone?

hot wolf
#

Because it's basically an ItemStack[]

#

May I ask what you're trying to do? Cause it's hard to follow rn

#

InventoryCloseEvent

eternal oxide
#

close event

hot wolf
#

ye

hot wolf
# eternal oxide close event

ElgarL, do you have any idea why Maven tries to kill me when I access a function of Class from a dependency (Economy plugin of mine). package ..... does not exist

eternal oxide
#

Maven? you mean on the server?

#

Your eco plugin has to be installed

hot wolf
#

Nope, when trying to compiling

#

*trying to compile

eternal oxide
#

what scope did you add yoru eco plugin as?

hot wolf
eternal oxide
#

I'm betting you manually added teh jar to your project

hot wolf
#

yess

#

xD

eternal oxide
#

one sec, you need to install it as a 3rd party jar to maven

charred blaze
#

im still stuck on this. can anyone.....

hot wolf
#

I thought it's gonna be a problem but I didn't think it was going to be this early

eternal oxide
#

oh, are you building yoru eco with maven too?

eternal oxide
#

if you are building it with Maven just run install

#

that will add it to your local maven

#

you can then add it to your other projects pom

hot wolf
#

if I want to deploy it on the server, will it work or will I have to configure anything so that it works?

eternal oxide
#

you just have to have both jars on your server

hot wolf
#

*noice

#

Appreciate it

charred blaze
#

Cannot make a static reference to the non-static field plugin

#

you mean this? private final Main plugin;

#

still red

#

class is public?

#

wdym

#

i can move plugin instance to static

#

i actually cant

#

😄

#

exatly

#

im not doing configuration

#

i just need db

#

to use db

#

i need this string

#

shared in other classes

#

so i need static

#

but it goes red

hot wolf
eternal oxide
#

yes

hot wolf
#

Oh, makes sense lol

eternal oxide
#

you add it as you would any other dependency

hot wolf
#

group id and stuff, alright

#

Thanks

charred blaze
#

how?

hot wolf
charred blaze
crisp steeple
hot wolf
#

lol

charred blaze
#

i need this string static

crisp steeple
#

you most likely don’t

#

if you follow proper dependency injection structures

charred blaze
#

im not doing config file

charred blaze
hot wolf
crisp steeple
noble lantern
#

DI follows through all java programs ._.

#

you can do it on a basic helloworld program without spigot if you so please xD

charred blaze
#

this think me

tardy delta
noble lantern
#

i got an idea

#

how about we learn about method values

tardy delta
#

Make a method for it

noble lantern
#

since DI is not an option for some reason

charred blaze
charred blaze
#

ill try DI

tardy delta
#

Then init it in the constructot

noble lantern
lost matrix
charred blaze
charred blaze
lost matrix
charred blaze
#

tutorial?

placid birch
#

after trying to add github to intellij, a all files have a red name. i then disconnected github but the changes are still there

lost matrix
charred blaze
#

will this work? i heard someone saying variables are initialized first

noble lantern
#

ayyy

#

well

#

set url value inside the constructor

#

then ayyyy

lost matrix
charred blaze
#

i cant use public in it

noble lantern
#

only static variables are initialized first really, as you noticed with your previous error, unless its in the constructor

placid birch
charred blaze
#

a

charred blaze
lost matrix
lost matrix
noble lantern
#

perhaps

charred blaze
lost matrix
# charred blaze what

So first url is initialized. This will call getDataFolder() on your plugin variable.
Then the constructor is called. The constuctor initializes the plugin variable.
Spot the problem.

charred blaze
#

i dont know english good so if i say something that sounds like a troll dont see it as troll

#

why would constructor call?

#

plugin is already plugin

lost matrix
#

Its like:

  1. Get in the car and drive away
  2. Build the car
#

Like..

charred blaze
#

yes

#

you will get errors driving empty car 😄

lost matrix
#

A non-existing car

charred blaze
#

ye

lost matrix
#

And the same occurs to you.

  1. initializing url calls plugin.getDataFolder()
  2. plugin is initialized by the constructor
#

To fix this:
Learn the very basics of Java
It does not take long

charred blaze
#

i was on some java basics urls several times

#

are you sure i will find fix of that thing?

charred blaze
lost matrix
charred blaze
#

oh god

#

JUST

#

tell me how to fix it

#

i promise i will learn java

#

after

#

making this plugin

lost matrix
charred blaze
#

i already know i have to initialize variables on right order

#

BUT HOW

ripe urchin
#

hm this is interesting. Whilst setting up my environment to get going with plugin dev, i was doing the buildtools thing to get the spigot.jar, but apparently the git part of it doesn't work?

Rebuilding Forked projects....
Resetting Spigot-API to Bukkit...
HEAD is now at 6a039faf #745: Expose more information about advancements
  Applying patches to Spigot-API...

*** Please tell me who you are.

Run

  git config --global user.email "you@example.com"
  git config --global user.name "Your Name"

to set your account's default identity.
Omit --global to set the identity only in this repository.

fatal: unable to auto-detect email address (got 'MYNAME@DESKTOP-68O5DT1.(none)')
  Something did not apply cleanly to Spigot-API.
  Please review above details and finish the apply then
  save the changes with rebuildPatches.sh
Error compiling Spigot. Please check the wiki for FAQs.
If this does not resolve your issue then please pastebin the entire BuildTools.log.txt file when seeking support.
java.lang.RuntimeException: Error running command, return status !=0: [sh, applyPatches.sh]
        at org.spigotmc.builder.Builder.runProcess0(Builder.java:973)
        at org.spigotmc.builder.Builder.runProcess(Builder.java:904)
        at org.spigotmc.builder.Builder.main(Builder.java:703)
        at org.spigotmc.builder.Bootstrap.main(Bootstrap.java:27)

Even after doing the git config commands to set email it refuses to work with the same error

lost matrix
# charred blaze BUT HOW

We are not going to literally write the plugin for you.
This is not a spigot related question. Its purely a matter of basic java knowledge.
The constructor is called before the variable initializers.

charred blaze
charred blaze
noble lantern
#

to be fair

#

it looks like your doing sqlite

charred blaze
#

yes

noble lantern
#

and if your struggling just with this

#

your gonna REALLY struggle once you start on that

charred blaze
#

thank you for telling useless thing

noble lantern
#

of course

lost matrix
ripe urchin
ripe urchin
#

have used it for quite some time with no issues

lost matrix
ripe urchin
#

already tried

ripe urchin
ornate patio
#

I ran into a logic error trying to the method mentioned

charred blaze
ripe urchin
#

apparently that did the trick. Seems like something is wrong with cmd's git config

#

git config --list returns correct user.name and user.email but the applyPatches uses the wrong one anyways so idk. Ah well it works now

ornate patio
# ornate patio bump

sorry for the ping @lost matrix but I am using the data scoping thing you showed me so i need some clarification on this

ornate patio
#

lmfao

ornate patio
#

this

charred blaze
ornate patio
#

why cant i use custom emojis i would really like to use one now

noble lantern
#

need boost

ornate patio
#

bruh

noble lantern
#

i can give you a gif instead if you like

ornate patio
#

no i will not be treated like a peasant

ornate patio
#

that works

ripe urchin
#

i call pay2win

noble lantern
#

@lost matrix rn in that gif

charred blaze
ornate patio
#

i wonder

kindred valley
#

hello how can i directly input main method in intellij

reef lagoon
#

Main

kindred valley
quaint mantle
#

I was having the same issue

#

What did u do

#

I just said fuck it and downloaded paper

ripe urchin
#

use git bash and not cmd

quaint mantle
#

To run the buildtools?

ripe urchin
#

for some reason cmd screwed up on the git credentials when running the applyPatches

#

git bash just worked fine

#

yeah buildtools

charred blaze
ripe urchin
# quaint mantle I was having the same issue

if you look in the error you see fatal: unable to auto-detect email address (got 'MYNAME@DESKTOP-68O5DT1.(none)'), and i very much know that i have user.email set correctly in git config (so nothing auto-generated/detected from some registry values). Even verified with git config --list

charred blaze
#

this part didnt had error before

#

i added this in listener

#

no no no

#

im making discord bot

charred blaze
noble lantern
#

why are you sprinting before learning to run

#

SQLlite, discord bot

#

all in a mc plugin

#

for your first time ever learning java

charred blaze
#

so its not first time

noble lantern
#

sorry simple truth

true shuttle
#

hey how do I teleport a player to a different dimension? I've tried googleing it but cant find anything

noble lantern
#

it is

true shuttle
#

oh ok i think i know what u mean

#

lemme check the docs

noble lantern
#

Bukkit.getWorld(someWorld).getSpawnLocation();

true shuttle
#

thx

noble lantern
#

and just tp them to that Location

true shuttle
#

oh gotcha, ty

charred blaze
noble lantern
#

this is the same thing smile was telling you

#

what code is giving the error

ornate patio
#

Good evening I would like to know how to block the bungeecord command (server) because I am creating a login plugin for my minecraft server. Players can connect without registering or logging in because of the command. Can you please tell me what to do please?

charred blaze
noble lantern
#

eg new ThatClassName(AnyParamter, GoInHere, AndHere);

charred blaze
noble lantern
charred blaze
#

in main?

noble lantern
#

it depends

#

Thats something you should really know, its your code after all

Does it need to get initialized on the plugin enabled? If so it likely goes in onEnable

#

mike the bungeecord ninja

vocal cloud
#

Sounds like cracked MC stuff to me 🤮

noble lantern
#

maybe?

#

oh yeah likely is

true shuttle
charred blaze
#

or not maybe?

noble lantern
ornate patio
noble lantern
#

the new keyword initializes the given constructor for said class

true shuttle
noble lantern
charred blaze
#

what to put in here?

noble lantern
#

sigh

#

its your constructor

#

so whatever your constructor is, you pass the needed variables to the class constructor

true shuttle
noble lantern
#

and what are you doing with that variable

#

you should be passing it to Player#teleport(Location);

true shuttle
#

player.teleport(worldSpawn);

#

yep

noble lantern
#

and it does nothing?

true shuttle
#

yea

noble lantern
#

sec

true shuttle
#

ive done some basic troubleshooting and the code is running, its just that part that isnt working

noble lantern
#

it returns a boolean

#

log it if you can, should be false if its failing

charred blaze
#

can i use constructor as a variable?

noble lantern
#

no, your constructor is a constructor

#

@true shuttle i got an idea if its false so lmk

noble lantern
charred blaze
noble lantern
#

Yes you do if your constructor requires it

charred blaze
#

wdym

noble lantern
#

sorry typo

#
class Something
    public Something(String str) {
    }
}

new Something("A String");

An example of passing arguments to a class constructor

charred blaze
#

a

true shuttle
# noble lantern <@704122974277468310> i got an idea if its false so lmk

ok so i figured it out:
it was in a listener for portal teleport, so basically when u enter a nether portal it teleports you to a different dimension. However, cuz it was doing the teleport code when they were being tp'd to the nether, the nether tp code took priority or something. I fixed it by running the tp on a slight delay

ornate patio
#

General design question:
So I've implemented a kind of design that loads and unloads "families" to and from memory, similar to this: https://www.spigotmc.org/threads/working-with-data.562421/

But my question is how would I create a command to select a family at random (either loaded or unloaded)? I can't just query the database because it is not always up to date.

true shuttle
#

thx for the help tho

noble lantern
charred blaze
true shuttle
noble lantern
#

Sounds like some type of design flaw

noble lantern
charred blaze
noble lantern
#

dependency injection, or if your in your main class already, the this keyword

#

You should really go learn some java basics

#

its gonna help you so much

charred blaze
#

so

#

it will run constructor now?

charred blaze
ornate patio
#

its intended

#

I need to rapidly access certain parts of data

#

hold on brb

charred blaze
#

umm

#

why does this returns me a nothing? System.getProperty("user.dir"))

#

when im trying to print this System.out.println(url + " " + System.getProperty("user.dir")); it prints

ornate patio
#

i need to rapidly access the data

#

so I'm basically storing whatever is in use in ram

#

and then every 10 or so minutes I'm flushing it, saving the current state to the database

summer sapphire
#

hmmmmmmmmmmmmmmmmmmmmmmmmm

#

forgive me, as im not very familiar with JVM languages

#

but

#

whats the best way to check if a Player stored in a variable is equal to CommandSender sender?

noble lantern
#

your memory should act like a buffer between your server and your database engine

ornate patio
#

such as players that aren't online anymore

noble lantern
#

You should only read and set from in store memory values (Unless say a player joins, then you call a get to the database)

Then every 5 minutes in a async task timer save all the data thats currently in the map

noble lantern
ornate patio
noble lantern
#

unload and async save

ornate patio
#

but if I want to access the data of an offline player (which is not too common)

#

I'll load the data for it to be unloaded later during the flush

noble lantern
#

or just dont store it if its not too common

#

get it use it forget about it

#

only cache things that you want to stay in memory long term eg your player data thats active

#

for offline players 100% you can use async calls, youll have 0 lag if you do it right, and you can call your database multiple times for the players

ornate patio
#

can I use async calls for a command?

noble lantern
#

yes

#

just

#

when you access anything on bukkit

#

eg sendming messages, getting blocks, whatever

#

throw it un a runTask/runTaskLater BukkitRunnable

ornate patio
#

but like what if the message I'm trying to send relies on the results of the database query

noble lantern
#

itll throw it back to main through for you that way

#

create a callback function on completion

#

or a CompletableFuture

ornate patio
#

sorry im lost lmfao

#

Im not too familiar with multithreading on java, i come from other languages

noble lantern
#

since your not gonna be storing the OfflinePlayer when you get them you save yourself loads by not having to deal with persistance between threads

#

I would look into CompletableFuture its a really nice class

#

and has exactly what you need, runAsync then back onto main thread

#

Youll have to google guides about those or ping conclure, im abt to take a nap haha

#

maybe hyper knows

ornate patio
#

wait so heres the thing

#

so what you're saying is that I need to make a seperate method to retrieve unloaded data and not store it right

#

i think?

noble lantern
#

yes and make sure the call is always async (Just the database call)

#

when you get the result, you can supply is synchronus with CompletableFuture

#

if no one shows you how to do it while im gone i will

#

i rly gtg now tho

ornate patio
#

alright thats fine

#

I'll just ask something else for someone else to answer

noble lantern
#

ask Conclure when they have time

#

taught me lots

ornate patio
ornate patio
#

I just don't see how this whole structure works

#

let me draw something rq

noble lantern
#

at least i hope your datas stores in a hashmap

ornate patio
#

yeah it does

#

in a ConcurrentHashMap

noble lantern
#

its logic

noble lantern
ornate patio
#

idk how to explain this ima just draw something lmao

#

you can nap if you want im not gonna hold u hostage here

noble lantern
#

even with the multithreading at hand

You're not interacting asynchronously with your cache so concurrency won't matter as it's not across threads

#

even then

#

HashMap is decently safe on its own accross threads

#

(iirc)

wet breach
#

no its not

wet breach
#

only for a few minutes, have to get ready to go do more things with tires 😛

noble lantern
#

what happened to your tires?

#

Did someone harm them?

wet breach
#

yeah, they are harmed everyday where I work

ornate patio
#

ffs i dont even know how to draw what im trying to say

noble lantern
#

IMO

wet breach
#

Anyways, hashmap is fine across threads so as long as you are not writing to it while reading especially from multiple threads. If all you are doing is just reading then yes it will be fine. Otherwise use ConcurrentHashMap

noble lantern
#

bukkit ban api is shit

#

use your own with uuids

#

not for uuids

wet breach
#

that was mojangs doing

noble lantern
#

api wise tho, you can ban via UUID and it sucks

ripe urchin
#

What's the event when a player right clicks an entity (in this case a zombie)?

noble lantern
#

since hes gonna load data in AsyncJoinEvent then shove it to cache

noble lantern
#

iirc

#

might have scuffed the name a lil

#

There is no Methods for it

#

Its just name and IP

young knoll
#

I think you pass a uuid as a string to the name one

noble lantern
young knoll
#

But I could be wrong

noble lantern
#

maybe

#

never tried, but i saw that api and i was like hell naw

wet breach
noble lantern
#

this is literally the spigot discord

ripe urchin
noble lantern
#

thats the same thing

#

BanList has 2 types

#

names and IPs

wet breach
#

always has

noble lantern
#

but idk if uuid is handled in names

wet breach
#

for like years

noble lantern
#

so i always avoid that api

#

true, but ide prefer a ban directly by uuid

#

and when checking if the player names changed it wont show in banlist

wet breach
#

if you use a player name the server will lookup their UUID

noble lantern
#

not sure if the ban list automatically syncs it

#

i wish the docs gave more info

#

like target of the ban is generic asf

#

when you have 2 list types

wet breach
#

instead of guessing from the method, should look at how it is implemented instead to get a better idea what it does o.O

noble lantern
#

but grrr javadocs >:((

#

god that sounds sketchy to me haha

wet breach
#

the ban api is pretty basic, but you don't need it to be anything super advanced either lol

noble lantern
#

i just make my own list, i dont trust that entire section of bukkit xD

#

dont you have to kick the player one tick later

#

or was that finally fixed

#

and can just call it directly

wet breach
#

think that was fixed

#

but you will have to test first to see

noble lantern
#

have you tested?

#

I did the exact same plugin in like uhmm

#

1.12ish

#

i got an exception with banning then kicking without a runnable

#

lemme see if i still have that project

#

doubt it tho

#

sadness i lost that src

#

yep thats true

#

and when they leave/rejoin they cant do it

obsidian roost
#

is net.minecraft.world the same as net.minecraft.server? I'm trying to learn NMS stuff but all my imports end in .world instead of .server

ocean lion
#

would I use the PlayerInteractEvent if I want something to happen when you R-click another player?

eternal oxide
obsidian roost
#

ah i see, how would i use NMS imports then with spigot?

eternal oxide
#

You don;t unless you have a very specific need for NMS

eternal oxide
#

Always use teh Spigot API first. Only use NMS if there is no API for it

obsidian roost
#

unless there is a way for an entity like a zombie to target a skeleton in the spigot API, i believe i need NMS

ornate patio
# ornate patio here

my question is, what if the data method 2 is trying to retrieve is cached? if it instantly updates the database, it'll get overriden

obsidian roost
#

setTarget is only for players though (or atleast ive been told)

eternal oxide
#

any LivingEntity

#

includes Mobs

sharp token
#

I'm wondering if it's possible to save the contents of a chest to a gson file

#

even if the items inside are custom items

eternal oxide
#

Yes, all ItemStacks are serializable

obsidian roost
#

yes, I was told here that it was pretty much only possible with NMS

#

yeah I've got to that part. I've tried setTarget in the past with problems but I guess I used Entities instead of LivingEntities

ivory sleet
sharp token
# eternal oxide Yes, all ItemStacks are serializable

i want to basically have a admin shop area where i can sell stuff that you can't find in vanilla like spawners, etc. And have enchanted stuff for sale, etc. My idea was to have a command to create a chest and if you're the owner you can edit the contents of the chest, and when a player clicks an item inside, they buy it but it doesn't move from the chest itself

ornate patio
#

kinda but in a horrible way

sharp token
#

do you think this is the best way to go with this

ornate patio
#

im having trouble explaining it

young knoll
ornate patio
crisp steeple
young knoll
#

No

ornate patio
#

But there are some cases where I need to access offline player data, but I'm not sure how to go about that

young knoll
#

Actually wait PlayerInteractEvent is also wrong

#

PlayerInteractEntityEvent

eternal oxide
#

Yes but you may have issues with gson as I believe it will have issues with enchantments as you can;t instance ItemMeta

ornate patio
#

Right now I just have it so that whenever I access a player or family, it stays in the cache until the 10 minute interval happens when its removed

eternal oxide
#

yaml works fine though

crisp steeple
#

oops yeah forgot it was playerinteractentity

ivory sleet
#

ah okay okay

#

so you have an expiring in memory cache

ornate patio
#

sorta

ivory sleet
#

and you're asking about the accessibility of offline users?

ornate patio
#

yes

ivory sleet
#

well one thing first

#

you should not let your online players be invalidated our timed out from the cache

ornate patio
#

I'm storing a bunch of PlayerData and Family objects in the cache. I can retreive these objects and modify them, so that when the next interval happens, it'll update the database

ivory sleet
#

think about it rationally

#

if x amount of players are playing on the server

#

there is ever little reason to remove a dto that represents the data of a player

#

however

#

for offline players

#

you might wanna load a dto for them with an expiration

#

since else you might run into a memory leak

midnight patrol
#

with the block break event how do you see if player broke it using favorable tool
(i know ive seen it somewhere i just cant seem to find the method)

ripe urchin
#

What would be the code to make a spawned zombie entity not catch on fire? it is invunerable and no AI, but it still burns in sunlight/lava

ornate patio
eternal oxide
ornate patio
#

i'm just simply updating the database

#

and removing any players that still aren't online

sharp token
ornate patio
#

i think

#

there's also setVisualFire but I've never used it

ripe urchin
ornate patio
#

create a loop then

ripe urchin
eternal oxide
#

just put a helmet on it

ornate patio
eternal oxide
#

it won;t catch fire then

ripe urchin
#

yeah i'll give it a skelly helmet

umbral bear
#

Hi y'all, i need help, i was trying to recreate the Mjolnir (Marvel Thor's Hammer) in minecraft just for fun, and i wanted to an ability where you could hit the ground and launch the mob in the air (as if they where hit by a punch bow), i managed to do the particle animation but now i have no clue on how to 1) check if the mob is inside or not the shockwawe and 2) launch the actual mob, any ideas?

umbral bear
#

i mean technically i could check the location of the mob by the location of the particle as they are spawned

sharp token
#

what do you tyhink about using this library to serialize enchanted items

grim ice
#

man im bored

sharp token
eternal oxide
#

yes

sharp token
#

thank you so much

#

you're the best

ornate patio
#

im so lost idk what to do

#

Can I just post all my data management classes for someone to review

main dew
#

Hi I have problem I try update my plugin to java 17 but I have problem java public static void addDependency(File file) throws NoSuchMethodException, MalformedURLException, InvocationTargetException, IllegalAccessException { Method addURL = URLClassLoader.class.getDeclaredMethod("addURL", URL.class); addURL.setAccessible(true); addURL.invoke(URLClassLoader.getSystemClassLoader(), file.toURI().toURL()); } old method to load libraries from external jar stop working and I don't have any idea how fix it 😅

eternal oxide
#

if your library is on maven central you can use the libraries entry in the plugin.yml

ornate patio
#

Data management pain

sharp token
#

@eternal oxide this is using paper which uses a different method to serialize and deserialize

#

upon converting to the alternative method that works with spigot, it's asking for a map

eternal oxide
young knoll
#

You can fairly easily copy the paper method into your plugin

#

But it does require NMS

eternal oxide
#

I don't do Paper

young knoll
#

It just uses NBT to serialize to a byte array

sharp token
#

oh nvm sorry

eternal oxide
#

You don't, it wasn't to you

sharp token
#

so what's your idea for the hashmap its asking for

ornate patio
eternal night
#

what are you doing there xD

#

with paper and item to byte[]

quaint mantle
#

I'm having trouble getting the contents of a barrel

lost matrix
quaint mantle
#

That's what I did

#

I'm getting AIR through all slots

lost matrix
#

Show your code

quaint mantle
lost matrix
#

Using a stream just to pipe it into a forEach is really bad

quaint mantle
#

It's just for testing

lost matrix
#

In which context is this code run?

#

More code pls

quaint mantle
#

I'm also having trouble clearing Container's inventory contents

#

I tried using Containter#getInventory#clear but nothing

lost matrix
#

This loop is really inefficient

quaint mantle
#

I did Container#update afterwards aswell

lost matrix
#

Get the TileStates for the chunks

young knoll
#

Don’t update after changing inventory

quaint mantle
#

Thank you, it seems to work now

young knoll
#

With packets you could

native gale
#

Anyone knows why would this happen?

north mural
eternal oxide
#

softdepend does not control load order

ornate patio
native gale
eternal oxide
#

depend affects load order.softdepend just says load me anytime but I'd like this other plugin to be around

#

if you are not full depend you need to setup your access of any other softdepend after it has loaded

#

delayed from your onEnable

native gale
eternal oxide
#

pretty much. but at least you don;t get any warnign messages about accessing a plugin you are not depend or softdepend on 😦

native gale
#

Mkay, whatever, thanks anyway

eternal night
#

Can you show more of the log

native gale
#

Are you talking to me?

dusk flicker
#

just show a different item to different players?
more context would be good

#

just listen for the pick up event, check a boolean, boom change it

#

Can use PDC to guarantee its the right item, etc

#

?pdc

young knoll
#

You could do that too

#

Let me check which packets

dusk flicker
#

Would you even needs to use packets for that Coll?

#

Woulden't using the event of the item leaving the inventory (one of the inventory events, cba to remember what one) be enough to do it?

young knoll
#

PacketType.Play.Server.WINDOW_ITEMS, PacketType.Play.Server.SET_SLOT

#

You don’t need to use packets, no

#

But it does make it easier

dusk flicker
#

For having the same item in one chest viewable by two people and them looking different you'd prob need to use packets

eternal oxide
#

Why not lock items to a team on pickup and never change them? Much simpler

young knoll
#

Yep

#

The lore only exists on the client

dusk flicker
#

Yeah so you would want to use the packets Coll sent as far as I am aware; I'm not a person that messes with packets lol

carmine nacelle
#

Is there an easy way to set a tile block's PDC to a PDC object?

#

like, I have a container, set some values on it

#

then gotta update the block

#

basically a for loop to loop through the keys of one pdc and set the other ones keys

golden turret
#

How can I check that a BoundingBox will fit in somewhere?

#

Lets say I have a 3x3x3 BoundingBox and I want to check if it can pass the door, how can I do that?

sharp token
#

It's reading the last line from the textfile as "null", how do I fix it? @eternal oxide

subtle folio
#

Can I get the slot of an itemstack in p.getInventory().getContents()?

sharp token
#

or whoever is available

golden turret
subtle folio
golden turret
#

the getContents returns an ItemStack[]

ripe urchin
#

You’re constantly alternating between reading a line for not null and reading a line for appending

sharp token
ripe urchin
#

Yes

sharp token
#

I ended up using .ready() like this

#

it's a good method

#

thank you though @ripe urchin !

carmine nacelle
#

Anyone know if its possible to make bees work at night and in rain with remaps?

quaint mantle
#

?nohello

undone axleBOT
buoyant viper
#

ur reading 2 lines at once in ur code

#

u were also losing half of ur lines

ornate patio
ornate patio
#

pls my brain hurts lmao

buoyant viper
#

or at least it does for me

quaint mantle
#

Not for older versions

fleet comet
#

How would I add combat tag to my plugin?

limber wolf
#

Trying to add a spigot build to a architectury project:

> Configure project :
Architect Plugin: 3.4.138
Architectury Loom: 0.11.0.275

> Configure project :common
architectury's common() is deprecated, use common(String... platforms) instead

> Configure project :spigot
fabric-installer.json not found in classpath!

> Task :spigot:compileJava FAILED
warning: Supported source version 'RELEASE_8' from annotation processor 'org.gradle.api.internal.tasks.compile.processing.TimeTrackingProcessor' less than -source '17'
1 warning

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':spigot:compileJava'.
> java.lang.NoClassDefFoundError: org/objectweb/asm/tree/MethodNode

the only documented case of this error was using some weird forge bukkit hybrid which I suppose has a bad mixed classpath but it probaly should be different in this case

waxen plinth
fleet comet
#

oh

waxen plinth
#

Fake news

#

Your question is pretty vague

#

If you're asking how to implement a combat tag feature, you can use a map to track the last time each player was damaged

#

Every time they are damaged, associate their UUID with the current time in a Map<UUID, Long>

#

Then when they log off you check it that timestamp in the map is <30 seconds ago (or whatever your combat tag duration is)

#

If it is, you kill them

sharp token
fleet comet
#

oh, its that simple?

willow widget
#

how could I get a material object from a string? 🙂

waxen plinth
#

Material.valueOf

noble lantern
#

Material.getMaterial(String);

willow widget
noble lantern
#

use getMaterial valueOf is a build in java method

willow widget
#

oh

noble lantern
#

and you need to catch an exception to detect it was invalid

willow widget
#

alr thanks for that info too

#

okie okie ty

fleet comet
#

@waxen plinthwhat if they get damaged again?

willow widget
#

is there a command here to see docs? xd

noble lantern
#

also for combat tag you may wanna do packet listening for certain player actions

willow widget
#

like ?docs something ?

noble lantern
#

?jd-s

undone axleBOT
willow widget
#

ty

willow widget
#

I thought it would xd

noble lantern
#

valueOf does

#

getMaterial returns null

#

valueOf wont interrupt your program tho

waxen plinth
#

It throws NoSuchElementException if it's invalid

noble lantern
#

Thought it was IllegalArgumentException

#

my ide tweakin

willow widget
noble lantern
#

getMaterial also has a legacy option if needed but

#

shouldnt rly need it

willow widget
#

how would you get a list of materials from config?

#

I have it set up as a list

waxen plinth
#

You can get it as a string list

willow widget
#

so I did

        this.crafteables = new ArrayList<Material>();
        for(String s: (List<String>) plugin.mainConfig.getList("Crafteables")) {
            Material m = Material.getMaterial(s);
            if(m != null)    this.crafteables.add(m);
        }
waxen plinth
#

Then do this

noble lantern
#

you would getStringList on your config then forEach((line) -> Material.getMaterial(line));

noble lantern
willow widget
#

I'm still messed with forEach xd

willow widget
waxen plinth
#

List<Material> materials = list.stream().map(Material::getMaterial).toList();

ornate patio
#

hey burchard do you think you can help me with my problem from earlier

noble lantern
ornate patio
#

been banging my head against a wall for awhile

noble lantern
#

if so that would be poggers

golden turret
#

actually maybe

noble lantern
#

sad

#

oh?

golden turret
#

.filter(s -> s != null)

noble lantern
#

i dont rly use the streams too often

#

ahh

waxen plinth
noble lantern
#

bam

limber wolf
#

get codegolfed

noble lantern
#

one liner

willow widget
#

I don't use streams at all xd don't know how yet

#

should learn tho

waxen plinth
#

I also have a config library you could use

willow widget
waxen plinth
#

You just define a List<Material> and the library handles the rest

willow widget
#

oh nice

#

what's the lib?

ornate patio
waxen plinth
#

RedLib comes with a hell of a lot more than just the config library

willow widget
waxen plinth
#

But the config library is certainly very nice

waxen plinth
willow widget
fleet comet
#

just dm me some stuff. so i wake up and say, ya know what time it is

noble lantern
#

whats with these static variables in your main class

#

convert to dependency injection

#

?di

undone axleBOT
summer sapphire
willow widget
#

Will Player#setBedSpawnLocation() set the players default spawn?

fleet comet
#

its just gonna be a pain

willow widget
#

Has anyone had an issue using line breaks on yaml files? xd
I got

regreso-iniciada: >
    &e¡Bienvenid@ de vuelta &a{PLAYER}&e a SpainMC WW1!
    \n&cSalir del juego durante la guerra puede hacer que no vuelvas, te quedan

but that \n is sent on mc literally as "\n" and not as a line break

#

wdym?

#

it shouldn't be a string?

carmine nacelle
#

Sooo im setting the honey level of a beehive, right

#

im setting it to its max and calling #update, it doesnt work

#
                                hiveData.setHoneyLevel(hiveData.getMaximumHoneyLevel());
                                enteredHiveBlock.update(true);
willow widget
#

The code using that is...

event.getPlayer().sendMessage(Utils.color(            joinStringReplace(plugin.mainConfig.getString("General.regreso-iniciada"),event.getPlayer())));

and joinStringReplace returns a String, what should it return then?

willow widget
lunar mica
#

The easiest way:
p.sendMessage(line1);
p.sendMessage(line2);

carmine nacelle
#

I think I figured it out

#

gotta set the block data again i believe

willow widget
willow widget
carmine nacelle
#

close enough

willow widget
#

but that can have issues when the user gets the messages as

  • my p.sendmsg(l1)
  • someone sends a message in this right milisecond
  • my p.sendmsg(l2)
drowsy helm
#

show us the entire stack trace

willow widget
#

not sure if glass was called STAINED_GLASS on 1.8.X