Skip to content

Commit

Permalink
Add hash code based unique ID to signs
Browse files Browse the repository at this point in the history
  • Loading branch information
RoyCurtis committed May 18, 2017
1 parent 8287510 commit 3db647a
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 1 deletion.
1 change: 1 addition & 0 deletions docs/FORMAT.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Each shop sign is represented by an object, that _always_ contains the following
* . . .if using **QuickShop**:
* `true` if `buy` type and has stock available
* `true` if `sell` type and has free space available
* `id` - Sign's unique ID number, calculated from world and position coordinates
* `locWorld` - Sign's world
* `locX` - Sign's integer X block position
* `locY` - Sign's integer Y block position
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<!-- Project properties -->
<groupId>roycurtis.signshopexport</groupId>
<artifactId>SignShopExport</artifactId>
<version>1.11.2-1.0.0</version>
<version>1.11.2-1.1.0</version>

<description>
Emits a public JSON database of SignShop or QuickShop shops available on the server
Expand Down
11 changes: 11 additions & 0 deletions src/main/java/roycurtis/signshopexport/json/Record.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,14 @@

import org.bukkit.inventory.ItemStack;

import java.util.Objects;

/** Represents a JSON record for Gson serialization */
public class Record
{
// ID
public long id;

// Location
public String locWorld;
public int locX;
Expand Down Expand Up @@ -34,4 +39,10 @@ public String toString()
ownerName, ownerUuid
);
}

@Override
public int hashCode()
{
return Objects.hash(locWorld, locX, locY, locZ);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public Record createRecordForIndex(int idx)
rec.locX = loc.getBlockX();
rec.locY = loc.getBlockY();
rec.locZ = loc.getBlockZ();
rec.id = rec.hashCode();

rec.ownerName = player.getName();
rec.ownerUuid = player.getUniqueId().toString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public Record createRecordForIndex(int idx)
rec.locX = loc.getBlockX();
rec.locY = loc.getBlockY();
rec.locZ = loc.getBlockZ();
rec.id = rec.hashCode();

rec.ownerName = seller.getOwner().getName();
rec.ownerUuid = seller.getOwner().GetIdentifier().getStringIdentifier();
Expand Down

0 comments on commit 3db647a

Please sign in to comment.