PreciousStones

PreciousStones

269k Downloads

meta-name and lore autoset

gabekanegae opened this issue ยท 28 comments

commented

Any way to make meta-name and meta-lore autoset when gotten via /give, ChestShop shops and maybe convert existing blocks when transferred from ie chest to inventory? Or, at least, make PS accept unnamed blocks (gotten directly from a shop or command) when placing a field and then rename them when broken?

ChestShop 3.8.12
Vault 1.5.6-v49
PreciousStones #532
Spigot 1.8.8-R0.1-SNAPSHOT - git-Spigot-fdc1440-880a532

Also, what happens if I set a field # limit for players, and a player already has more fields than the limit I just set? Expected behavior should be that he's not able to place anymore before removing them to a # below the limit. Is that how it works?

Thank you.

commented

No possible with the built in /give command. But they do with the ps command: /ps give city phaed

commented

And I suppose that ChestShop uses /give behind the curtains, so...

Also, what's the unique identifier for a field? As in, I can change everything but x and the changes will apply to all already placed fields. The block ID itself?

commented

Hmm, ill look into ChestShop. The identifier is x,y,z,world. Block type should match as well but not identifier.

commented

What about the field limit? If I set a field # limit for players, and a player already has more fields than the limit I just set? Expected behavior should be that he's not able to place anymore before removing them to a # below the limit. Is that how it works?

commented

Can't recall how the limit works off hand. Make a bug ticket if it doesn't.

commented

Sure, thank you. I'll be waiting for an update on getting blocks via ChestShop. In my case, I'm using the lore as a mini-tutorial for field usage, so it's quite a big deal having them showing when a player buys it from the main/admin shop.

Thanks again. :)

EDIT: Also, crafting. Forgot about that. eg. crafting a diamond block gives the plain item. That'd be awesome too!

Maybe checking and changing/updating field blocks metadata when they enter a player's inventory? That'd solve everything, from crafting to "old" blocks to items from a shop. Not experienced in Java so my suggestion might be worthless, but still.

commented
commented

Huh... Those reports are about selling to a shop and buying from a player shop. I was thinking about buying from an Admin Shop (no item deposit, just buying from the "server"), where the item is "created" when the player buys it, going directly to his inventory.

My suggestion from my last post should work with everything besides buying from a player shop and selling to any shop, in other words, things that need the custom item as an "input".

One of the reports is marked as fixed, though, and the most recent is from a year and a half ago. Most likely fixed, but let's see. I'll be back in 2 hours, will see how much testing I can do with ChestShop.

About the /give, cool. If you manage to integrate that, awesome! :P

commented

Custom items is not something I came up with, that is on the Minecraft core, anyone can create custom items by adding metadata (name, and lore) to items. So that's what PS does. Its up to the ChestShop dev to support custom items in his admin shops.

commented

Wait I believe you can use the /iteminfo command to generate and id for a custom item, and then use that id create a shop with, maybe you can use that id on the admin shops?

Read here: http://dev.bukkit.org/bukkit-plugins/chestshop/tickets/950-custom-item-ids-with-iteminfo-not-working/

commented

Custom items is not something I came up with, that is on the Minecraft core, anyone can create custom items by adding metadata (name, and lore) to items.

Yes, I am aware of that. I might have misunderstood your previous comment. Sorry about that.

Wait I believe you can use the /iteminfo command to generate and id for a custom item, and then use that id create a shop with, maybe you can use that id on the admin shops?

Yes, that does work! Thank you! I wonder how Minecraft keeps track of hundreds or thousands of custom items. Huh.


I still have a problem, though. If I push this update (PS field blocks with metadata) to my server, my players will still have the unnamed blocks, which would be worthless. Is there any way to make PS accept the plain blocks together with the metadata ones, so they don't have to exchange and/or get/buy new blocks? (check OP)

Last thing, any way to make crafting so it gives the player the named block?

commented

Hmm. No easy way to do that. Maybe you can set up shops that allows them to trade in regular blocks for ones with metadata on them?

Gonna look into this crafting business. Forgot about that. I'll add it to the meta-autoset flag if its possible.

commented

Yes, that's exactly what I plan on doing. Not the best idea, but it works!
[EDIT: Shopkeepers seems to work amazingly for this!]

I am probably forgetting of another ways to obtain blocks, that should have the metadata applied to them. I guess /give, crafting and buying from shops are the most used ones. If you can think of others...

Thank you for your help! One last question, I promise you!

On this "update" I'm planning, I just changed all cuboids to, well, just regular fields. I don't want players to be able to shape their fields. I shouldn't have any problem with that, right? I mean, there might be players who already reshaped theirs. I just changed true to false on every field config.

commented

You will have to also move all the entries on the pstone_cuboids db table to the pstone_fields table.

pstone_cuboids and pstone_fields are the same except how the size is defined

  • pstone_cuboids: minx, miny, minz, maxx, maxy, maxz
  • pstone_fields: height, radius

You would have to do something like

INSERT INTO pstone_fields (radius, height, x, y, z, type_id, data, velocity, world, owner, name, packed_allowed, last_used, flags)
SELECT (LEAST(ABS(ROUND(GREATEST(c.maxx-c.minx, 2)-1)/2)), ABS(ROUND(GREATEST(c.maxz-c.minz,2)-1)/2))) as radius, (c.maxy-c.miny) as height, x, y, z, type_id, data, velocity, world, owner, name, packed_allowed, last_used, flags
FROM pstone_cuboids c

This will make all new fields the same size on each side as the smallest side from the cuboid (so as not to take up space it didn't previously cover. So if cuboid had x=10 z=5, the field will have x=5 z=5. It might leave part of one side unprotected, though. The alternative would be changing the LEAST on the sql to GREATEST, making the resulting field x=10 z=10, though it may overlap other's stuff if too close.

commented

Oh, wow. So glad I asked. That would've broken quite a bunch of stuff, I guess. Thanks for your help! I will try and push the update live, then check often for the crafting metadata thingy, haha.

Thanks!

commented

No prob. Updated the SQL to take care of some edge cases.

commented

Your SQL code doesn't seem to be working for me. I'm using SQLite as PS's db, and using DB Browser to edit it. I get a syntax error with it, am I missing something?

commented

Ohh, that is for MySQL.

Try this:

INSERT INTO pstone_fields (radius, height, x, y, z, type_id, data, velocity, world, owner, name, packed_allowed, last_used, flags)
SELECT (min(abs(round(max(c.maxx-c.minx, 2)-1)/2)), abs(round(max(c.maxz-c.minz,2)-1)/2))) as radius, (c.maxy-c.miny) as height, x, y, z, type_id, data, velocity, world, owner, name, packed_allowed, last_used, flags
FROM pstone_cuboids c
commented
INSERT INTO pstone_fields (radius, height, x, y, z, type_id, data, velocity, world, owner, name, packed_allowed, last_used, flags)
SELECT (min(abs(round(max(c.maxx-c.minx, 2)-1)/2), abs(round(max(c.maxz-c.minz,2)-1)/2))) as radius, (c.maxy-c.miny) as height, x, y, z, type_id, data, velocity, world, owner, name, packed_allowed, last_used, flags
FROM pstone_cuboids c

From my poor SQL knowledge, I think I fixed it. There was an extra ) in the middle.

commented

Ah great :) mybad

commented

And then I should drop pstone_cuboids, right? As it just copies the data.

My radius column is all at x-0.5 (ie 2.5 instead of 3 and 19.5 instead of 20). Would slapping a +0.5 before 'as radius' in the code fix it?

commented

round should have taken care of that. maybe sqlite does it different let me check.

commented

Ah, round parenthesis was leaving the /2 outside. try this:

INSERT INTO pstone_fields (radius, height, x, y, z, type_id, data, velocity, world, owner, name, packed_allowed, last_used, flags)
SELECT (min(abs(round((max(c.maxx-c.minx, 2)-1)/2)), abs(round((max(c.maxz-c.minz,2)-1)/2))) as radius, (c.maxy-c.miny) as height, x, y, z, type_id, data, velocity, world, owner, name, packed_allowed, last_used, flags
FROM pstone_cuboids c
commented
INSERT INTO pstone_fields (radius, height, x, y, z, type_id, data, velocity, world, owner, name, packed_allowed, last_used, flags)
SELECT (min(abs(round((max(c.maxx-c.minx, 2)-1)/2)+1), abs(round((max(c.maxz-c.minz,2)-1)/2)+1))) as radius, (c.maxy-c.miny) as height, x, y, z, type_id, data, velocity, world, owner, name, packed_allowed, last_used, flags
FROM pstone_cuboids c

One missing? Haha. It works, thanks.

And about pstone_cuboids? Do I keep it? Clear it? Drop it?
Any more changes I need to worry about?

:)

commented

Yep you can clear out all the records on there.

commented

Oops. It works, though. But everytime a field block is crafted, that pops up.

commented

I think I got an edge case for you. I have

sneak-to-place-normal-block: false
sneak-to-place-field: false

And if a field block is eg. diamond or emerald ore (in my case, renamed and with lore), there is NO way to get the diamond or emerald itself, as when broken it will ALWAYS drop the field block with metadata. /ps off, placing and breaking doesn't work, fortune pickaxe doesn't work. Any idea on how to fix this? Not sure about what happens when changing the config, but I'd guess it will have the same behavior as /ps off.