forked from ChestShop-authors/ChestShop-3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update ChestShopSign validation method
The validation method "isValid" in the ChestShopSign class has been replaced with "isLegacyValid". Changes were made across multiple files where this method is used. Additionally, import sections were tidied in several classes, grouping related imports together.
- Loading branch information
Showing
15 changed files
with
291 additions
and
227 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
100 changes: 100 additions & 0 deletions
100
src/main/java/com/Acrobot/ChestShop/Signs/ChestShopMetaData.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
package com.Acrobot.ChestShop.Signs; | ||
|
||
import java.util.HashMap; | ||
import java.util.HashSet; | ||
import java.util.Map; | ||
import java.util.Set; | ||
import java.util.UUID; | ||
|
||
import org.bukkit.configuration.serialization.ConfigurationSerializable; | ||
import org.bukkit.inventory.ItemStack; | ||
|
||
public class ChestShopMetaData implements ConfigurationSerializable { | ||
|
||
private UUID owner; | ||
private Set<UUID> accessors; | ||
|
||
private int quantity; | ||
|
||
private double buyPrice; | ||
|
||
private double sellPrice; | ||
|
||
private ItemStack itemStack; | ||
|
||
public ChestShopMetaData(UUID owner, int quantity, double sellPrice, double buyPrice, ItemStack itemStack) { | ||
this(owner, quantity, sellPrice, buyPrice, itemStack, new HashSet<>()); | ||
} | ||
|
||
private ChestShopMetaData(UUID owner, int quantity, double sellPrice, double buyPrice, ItemStack itemStack, Set<UUID> accessors) { | ||
this.owner = owner; | ||
this.quantity = quantity; | ||
this.sellPrice = sellPrice; | ||
this.buyPrice = buyPrice; | ||
this.itemStack = itemStack; | ||
this.accessors = accessors; | ||
} | ||
|
||
public HashSet<UUID> getAccessors() { | ||
return new HashSet<>(accessors); | ||
} | ||
|
||
public void addAccessor(UUID uuid) { | ||
accessors.add(uuid); | ||
} | ||
|
||
public void removeAccessor(UUID uuid) { | ||
accessors.remove(uuid); | ||
} | ||
|
||
public boolean isAccessor(UUID uuid) { | ||
return accessors.contains(uuid); | ||
} | ||
|
||
public UUID getOwner() { | ||
return owner; | ||
} | ||
|
||
public boolean isOwner(UUID uuid) { | ||
return owner.equals(uuid); | ||
} | ||
|
||
public int getQuantity() { | ||
return quantity; | ||
} | ||
|
||
public double getBuyPrice() { | ||
return buyPrice; | ||
} | ||
|
||
public double getSellPrice() { | ||
return sellPrice; | ||
} | ||
|
||
public ItemStack getItemStack() { | ||
return itemStack; | ||
} | ||
|
||
@Override | ||
public Map<String, Object> serialize() { | ||
Map<String, Object> data = new HashMap<>(); | ||
data.put("owner", owner); | ||
data.put("accessors", accessors); | ||
data.put("amount", quantity); | ||
data.put("buyPrice", buyPrice); | ||
data.put("sellPrice", sellPrice); | ||
data.put("itemStack", itemStack.serialize()); | ||
return data; | ||
} | ||
|
||
public static ChestShopMetaData deserialize(Map<String, Object> map) { | ||
|
||
UUID owner = (UUID) map.get("owner"); | ||
int amount = (int) map.get("amount"); | ||
double sellPrice = (double) map.get("sellPrice"); | ||
double buyPrice = (double) map.get("buyPrice"); | ||
ItemStack itemStack = (ItemStack) map.get("itemStack"); | ||
Set<UUID> accessors = new HashSet<>((HashSet<UUID>) map.get("accessors")); | ||
return new ChestShopMetaData(owner, amount, sellPrice, buyPrice, itemStack, accessors); | ||
} | ||
} |
Oops, something went wrong.