mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-26 15:03:30 +00:00
Auction System Implementation
This commit is contained in:
1 parent
9cbd9fd3eb
commit
5afa1c8959
60 files changed
+6187
-589
No files matched your search
@@ -0,0 +1,64 @@
|
||||
package noppes.npcs.controllers.data;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import noppes.npcs.constants.EnumNotificationType;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class AuctionNotification {
|
||||
public String id;
|
||||
public UUID playerUUID;
|
||||
public EnumNotificationType type;
|
||||
public String listingId;
|
||||
public String message;
|
||||
public long timestamp;
|
||||
public boolean sent;
|
||||
|
||||
public AuctionNotification() {
|
||||
this.id = UUID.randomUUID().toString();
|
||||
this.timestamp = System.currentTimeMillis();
|
||||
this.sent = false;
|
||||
}
|
||||
|
||||
public AuctionNotification(UUID playerUUID, EnumNotificationType type, String listingId, String message) {
|
||||
this();
|
||||
this.playerUUID = playerUUID;
|
||||
this.type = type;
|
||||
this.listingId = listingId;
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public boolean isForPlayer(UUID uuid) {
|
||||
return playerUUID != null && playerUUID.equals(uuid);
|
||||
}
|
||||
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound compound) {
|
||||
compound.setString("ID", id);
|
||||
compound.setString("PlayerUUID", playerUUID != null ? playerUUID.toString() : "");
|
||||
compound.setInteger("Type", type.ordinal());
|
||||
compound.setString("ListingID", listingId != null ? listingId : "");
|
||||
compound.setString("Message", message != null ? message : "");
|
||||
compound.setLong("Timestamp", timestamp);
|
||||
compound.setBoolean("Sent", sent);
|
||||
return compound;
|
||||
}
|
||||
|
||||
public void readFromNBT(NBTTagCompound compound) {
|
||||
id = compound.getString("ID");
|
||||
|
||||
String playerUUIDStr = compound.getString("PlayerUUID");
|
||||
playerUUID = playerUUIDStr.isEmpty() ? null : UUID.fromString(playerUUIDStr);
|
||||
|
||||
type = EnumNotificationType.fromOrdinal(compound.getInteger("Type"));
|
||||
listingId = compound.getString("ListingID");
|
||||
message = compound.getString("Message");
|
||||
timestamp = compound.getLong("Timestamp");
|
||||
sent = compound.getBoolean("Sent");
|
||||
}
|
||||
|
||||
public static AuctionNotification fromNBT(NBTTagCompound compound) {
|
||||
AuctionNotification notification = new AuctionNotification();
|
||||
notification.readFromNBT(compound);
|
||||
return notification;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user