Spigot Plugin Development - 58 - Persistent Data Storage

แชร์
ฝัง
  • เผยแพร่เมื่อ 12 ม.ค. 2025

ความคิดเห็น • 68

  • @ghit2494
    @ghit2494 4 ปีที่แล้ว +69

    Great video. I liked the part where you spoke about the Persistent Data Storage

    • @KodySimpson
      @KodySimpson  4 ปีที่แล้ว +5

      Glad to hear it!

    • @sfraction9004
      @sfraction9004 4 ปีที่แล้ว +3

      Wow, I also liked a lot this part!

  • @MeedoWasTaken
    @MeedoWasTaken 2 ปีที่แล้ว +3

    I've started coding because of you, the thing you are doing is really amazing, it got me jobs at huge servers and I started working with youtubers, it so amazing what you did, it changed my life from downloading plugins from spigot to making my own plugin which is an amazing feeling, you keep doing what you do

    • @KodySimpson
      @KodySimpson  2 ปีที่แล้ว

      Keep up the great work, thanks for watching and supporting

  • @KelvenOne
    @KelvenOne 4 ปีที่แล้ว +6

    Good to know that you are still working on this course

  • @arkdirfe
    @arkdirfe 3 ปีที่แล้ว +5

    I believe instead of creating a new NamespacedKey each time you call a persistent data method it would be better to just create the object once and use a static utility class (or whichever design pattern you prefer) to access it. Probably better runtime wise and readability wise.

  • @Sifarth
    @Sifarth 7 หลายเดือนก่อน

    Persistent Data Storage saved my life, I was like, no way am I going to have to write yml file reading, storing, and editing every time I make a plugin I want to store data in. Giving me PTSD back when I was messing around in code golf with my friends, a lot of js and text file manipulation happened.

  • @kiryu144
    @kiryu144 3 ปีที่แล้ว +3

    1:18 is really missleading. Not every block stores NBT data. Only every Tile Entity.

  • @dylanroberts9351
    @dylanroberts9351 2 ปีที่แล้ว +1

    BTW If anyone was wondering, PersistentDataContainer will keep all that data for an item through serialization/deserialization.

  • @Badbird-vg7jv
    @Badbird-vg7jv 4 ปีที่แล้ว +7

    Great video! can you please make a video on making a StaffChat plugin?

    • @KodySimpson
      @KodySimpson  4 ปีที่แล้ว +2

      Thanks for the idea!

  • @luawastaken
    @luawastaken 4 ปีที่แล้ว +1

    Thank you for the tutorial. I am actually struggling a bit since I want to apply this PersistentDataContainer (In my case CraftPersistentDataContainer) to an *entity* again & I am not really sure how to do that.
    Current code:
    GuildVillager gv = new GuildVillager(placedloc, guildname);

    CraftPersistentDataContainer data = gv.getBukkitEntity().getPersistentDataContainer();
    data.set(new NamespacedKey(plugin, "special"), PersistentDataType.STRING, "guildvillager");

    ((CraftWorld) placedloc.getWorld()).getHandle().addEntity(gv);
    Any clues on how to add it to the entity again?

  • @GaLzZy.
    @GaLzZy. 4 ปีที่แล้ว +3

    Can we do that with block that are placed in the world ? Like a fence gate ?

    • @KodySimpson
      @KodySimpson  4 ปีที่แล้ว +1

      It needs to be a block with a TiledState, I'll make a video on it.

    • @GaLzZy.
      @GaLzZy. 4 ปีที่แล้ว

      @@KodySimpson Ok thanks a lot

    • @GaLzZy.
      @GaLzZy. 4 ปีที่แล้ว

      @@KodySimpson And so that means that a door, fence gate, etc cant store persistent data ? :O

    • @KodySimpson
      @KodySimpson  4 ปีที่แล้ว

      @@GaLzZy. Pretty much

  • @GaLzZy.
    @GaLzZy. 4 ปีที่แล้ว +4

    Do you have any idea how efficient this is compared to working with files myself or even a database ? Thanks and great video :)

    • @KodySimpson
      @KodySimpson  4 ปีที่แล้ว +1

      I think a database would be better since you can easily query data or when you remove the plugin you are able to wipe all the data. Those are the immediate improvements off the top of my head, but for small things I would use the persistant storage api, and other stuff use a DB.

    • @GaLzZy.
      @GaLzZy. 4 ปีที่แล้ว +1

      @@KodySimpson Aight aight, and when you use a database would you query all the time or cache somewhere ? Also can Persistent Data Storage can share through different worlds ? Thansk :)

    • @KodySimpson
      @KodySimpson  4 ปีที่แล้ว

      @@GaLzZy. You would probably want to cache if you need to grab information frequently. And idk, test that out. I would assume so

  • @voltywolty
    @voltywolty 3 ปีที่แล้ว

    Would this be useful for checking to see how much of a certain item this player has in their inventory in order to use another item? I'm working on a game mode where Blacksmiths need at least 3 clocks in order to use their book.

  • @luneomusic
    @luneomusic 4 ปีที่แล้ว +1

    Hey can you make a tutorial about updating scoreboards?

  • @ivan-w7q
    @ivan-w7q 2 ปีที่แล้ว +1

    is there a limit to the persistent data storage values? like for attribute max health the limit is 1024 was just wondering if there was a limit for this too

    • @KodySimpson
      @KodySimpson  2 ปีที่แล้ว

      Good question! No idea but if you find out lemme know

    • @ivan-w7q
      @ivan-w7q 2 ปีที่แล้ว

      @@KodySimpson i think it depends on the data type, if it's an integer then it's probably the integer limit

  • @AJARETRO
    @AJARETRO 2 ปีที่แล้ว

    does this always update or needs to be updated like the config files?

  • @Nanagos
    @Nanagos 2 ปีที่แล้ว +1

    I wish I would have known that earlier.

  • @trashcan6836
    @trashcan6836 4 ปีที่แล้ว +18

    im a trash can

    • @KodySimpson
      @KodySimpson  4 ปีที่แล้ว +9

      nice to meet you trash can

  • @nikolqy
    @nikolqy 3 ปีที่แล้ว +1

    Would this be a good idea to store something like coins collected for a mini game?

    • @KodySimpson
      @KodySimpson  3 ปีที่แล้ว +1

      Definitely

    • @ybacornae7851
      @ybacornae7851 ปีที่แล้ว

      wouldnt u want to use a hashmap tho? i think persis data would be efficient to use on items idk tho

  • @henryreimer8310
    @henryreimer8310 3 ปีที่แล้ว +1

    Can you store classes in the NBT data?

    • @KodySimpson
      @KodySimpson  3 ปีที่แล้ว +1

      Yes, serialize them

    • @henryreimer8310
      @henryreimer8310 3 ปีที่แล้ว

      @@KodySimpson That will save the data stored in the class right? I am making a bank plugin and I want each player to have a record of their items

    • @KodySimpson
      @KodySimpson  3 ปีที่แล้ว

      @@henryreimer8310 yes

    • @henryreimer8310
      @henryreimer8310 3 ปีที่แล้ว +1

      @@KodySimpson For all those who are wondering, this is how I solved the issue. I used the Gson library to convert the account class into a string. That string is saved in the player data. When the account needs to be accessed, the string is grabbed from the NBT and converted into an account class.

  • @Culvanen
    @Culvanen 4 ปีที่แล้ว +2

    Is there a tutorial on this youtube channel to create NPCs?

    • @KodySimpson
      @KodySimpson  4 ปีที่แล้ว

      Not at this time

    • @Culvanen
      @Culvanen 4 ปีที่แล้ว

      @@KodySimpson Is planned ? thx

    • @KodySimpson
      @KodySimpson  4 ปีที่แล้ว +1

      @@Culvanen Eventually

  • @magic_2942
    @magic_2942 4 ปีที่แล้ว +2

    How can I do this for placed blocks ?

    • @KodySimpson
      @KodySimpson  4 ปีที่แล้ว

      Same way as items pretty much

    • @magic_2942
      @magic_2942 4 ปีที่แล้ว +1

      @@KodySimpson Are you sure about that ? I've read that blocks lose their data after they are placed ;/

    • @dariobusia3128
      @dariobusia3128 4 ปีที่แล้ว

      @@KodySimpson I've been breaking my head over this for a while now, where do you find the NBT for the block's data?
      like the block datatype does not simply have a getPersistentDataContainer()

    • @KodySimpson
      @KodySimpson  4 ปีที่แล้ว +1

      @@dariobusia3128 Oh I just recalled, the block must implement TiledState. Only tiled blocks like chests, hoppers, etc

    • @dariobusia3128
      @dariobusia3128 4 ปีที่แล้ว +1

      @@KodySimpson
      So as for normal blocks who dont implement TiledState, there currently is no way to do this?
      or could we expect a future episode on this topic as I'm sure plenty of people looking for set info would end up here.

  • @graffity_x6624
    @graffity_x6624 3 ปีที่แล้ว

    probably a really dumb question, bu is there a way to make items with different persistent data stackable?

    • @codingidiot6754
      @codingidiot6754 2 ปีที่แล้ว

      nope

    • @jacobcox2006
      @jacobcox2006 2 ปีที่แล้ว

      Did you look into this at all because it would be really helpful for what I'm trying to do?

    • @graffity_x6624
      @graffity_x6624 2 ปีที่แล้ว

      @@jacobcox2006 idk what you're trying to do

    • @jacobcox2006
      @jacobcox2006 2 ปีที่แล้ว

      @@graffity_x6624 make items distinguishable but stackable.

    • @codingidiot6754
      @codingidiot6754 2 ปีที่แล้ว

      @@jacobcox2006 not really possible unless you track the order which you put items in

  • @codingidiot6754
    @codingidiot6754 2 ปีที่แล้ว

    having a weird glitch that says "Cannot return a value from a method with void result type" in this code:
    public void onDisable() {
    public static Main getPlugin {
    return plugin;
    }
    }
    could anyone help?

    • @KodySimpson
      @KodySimpson  2 ปีที่แล้ว +1

      Why would you declare a method inside of a method???

    • @codingidiot6754
      @codingidiot6754 2 ปีที่แล้ว

      @@KodySimpson o, i thought that you moved it into the method im blind

    • @KodySimpson
      @KodySimpson  2 ปีที่แล้ว +1

      @@codingidiot6754 Its ok, dont do something without understanding why I did it

  • @AJARETRO
    @AJARETRO 2 ปีที่แล้ว

    can i change the value?

  • @mikeyadams
    @mikeyadams 3 ปีที่แล้ว +1

    Is the code really coming soon?

  • @helloworld8428
    @helloworld8428 4 ปีที่แล้ว +2

    :o Yay! :D

  • @jesusshelby5431
    @jesusshelby5431 ปีที่แล้ว

    Жаль что я ни черта не понимаю(