diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 000d3569..24965d8e 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -8,7 +8,7 @@ Replace `[ ]` with `[x]` to cross the checkbox. - [ ] I have checked the PRs for upcoming features/bug fixes. - [ ] I have read the [contributing guidelines][contributing]. -> It is sometimes better to include more changes in a single commit. +> It is sometimes better to include more _related_ changes in a single commit. If you find yourself having an overwhelming amount of commits, you can **rebase** your branch. diff --git a/src/main/java/org/shanerx/tradeshop/item/ShopItemStack.java b/src/main/java/org/shanerx/tradeshop/item/ShopItemStack.java index 401c06f8..028d04e9 100644 --- a/src/main/java/org/shanerx/tradeshop/item/ShopItemStack.java +++ b/src/main/java/org/shanerx/tradeshop/item/ShopItemStack.java @@ -51,13 +51,12 @@ import java.io.ByteArrayInputStream; import java.io.IOException; -import java.io.Serializable; import java.util.ArrayList; import java.util.HashMap; import java.util.Map; import java.util.Objects; -public class ShopItemStack implements Serializable, Cloneable { +public class ShopItemStack implements Cloneable { @Expose private ItemStack itemStack; @@ -124,17 +123,6 @@ public Map> getItemSettings() { return itemSettings; } - public static ShopItemStack deserialize(String serialized) { - ShopItemStack item = new GsonProcessor().fromJson(serialized, ShopItemStack.class); - item.loadLegacyData(); - item.buildMap(); - return item; - } - - public String serialize() { - return new GsonProcessor().toJson(this); - } - public ObjectHolder getShopSetting(ShopItemStackSettingKeys key) { if (key.isUserEditable() && itemSettings.containsKey(key)) { ObjectHolder tempObj = itemSettings.get(key); diff --git a/src/main/java/org/shanerx/tradeshop/player/PlayerSetting.java b/src/main/java/org/shanerx/tradeshop/player/PlayerSetting.java index 54812eec..bad1dbe8 100644 --- a/src/main/java/org/shanerx/tradeshop/player/PlayerSetting.java +++ b/src/main/java/org/shanerx/tradeshop/player/PlayerSetting.java @@ -40,13 +40,12 @@ import org.shanerx.tradeshop.utils.Utils; import org.shanerx.tradeshop.utils.gsonprocessing.GsonProcessor; -import java.io.Serializable; import java.util.HashSet; import java.util.Map; import java.util.Set; import java.util.UUID; -public class PlayerSetting implements Serializable { +public class PlayerSetting { private transient UUID uuid; private final String uuidString; @@ -80,12 +79,6 @@ public PlayerSetting(UUID playerUUID) { load(); } - public static PlayerSetting deserialize(String serialized) { - PlayerSetting playerSetting = new GsonProcessor().fromJson(serialized, PlayerSetting.class); - playerSetting.load(); - return playerSetting; - } - public boolean isAdminEnabled() { return adminEnabled; } @@ -147,10 +140,6 @@ public void load() { utils = new Utils(); } - public String serialize() { - return new GsonProcessor().toJson(this); - } - public String getInvolvedStatusesString() { Set nullShops = new HashSet<>(); StringBuilder sb = new StringBuilder(); diff --git a/src/main/java/org/shanerx/tradeshop/player/ShopUser.java b/src/main/java/org/shanerx/tradeshop/player/ShopUser.java index f4119717..8e7a28dc 100644 --- a/src/main/java/org/shanerx/tradeshop/player/ShopUser.java +++ b/src/main/java/org/shanerx/tradeshop/player/ShopUser.java @@ -33,11 +33,10 @@ import org.bukkit.inventory.meta.SkullMeta; import org.shanerx.tradeshop.utils.gsonprocessing.GsonProcessor; -import java.io.Serializable; import java.util.UUID; @SuppressWarnings("unused") -public class ShopUser implements Serializable { +public class ShopUser { private transient OfflinePlayer player; @SerializedName("player") @@ -56,12 +55,6 @@ public ShopUser(UUID pUUID, ShopRole role) { this.role = role; } - public static ShopUser deserialize(String serialized) { - ShopUser shopUser = new GsonProcessor().fromJson(serialized, ShopUser.class); - shopUser.player = Bukkit.getOfflinePlayer(UUID.fromString(shopUser.playerUUID)); - return shopUser; - } - public OfflinePlayer getPlayer() { fix(); return player; @@ -85,10 +78,6 @@ private void fix() { } } - public String serialize() { - return new GsonProcessor().toJson(this); - } - public ItemStack getHead() { ItemStack userHead = new ItemStack(Material.PLAYER_HEAD); SkullMeta userMeta = (SkullMeta) userHead.getItemMeta(); diff --git a/src/main/java/org/shanerx/tradeshop/shop/Shop.java b/src/main/java/org/shanerx/tradeshop/shop/Shop.java index 99e9ef63..cac3bddd 100644 --- a/src/main/java/org/shanerx/tradeshop/shop/Shop.java +++ b/src/main/java/org/shanerx/tradeshop/shop/Shop.java @@ -50,7 +50,6 @@ import org.shanerx.tradeshop.utils.objects.ObjectHolder; import org.shanerx.tradeshop.utils.objects.Tuple; -import java.io.Serializable; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; @@ -61,7 +60,7 @@ import java.util.UUID; import java.util.stream.Collectors; -public class Shop implements Serializable { +public class Shop { private ShopUser owner; private Set managers, members; @@ -146,20 +145,7 @@ public Shop(Location location, ShopType shopType, ShopUser owner) { } /** - * Deserializes the object to Json using Gson - * - * @param serialized Shop GSON to be deserialized - * - * @return Shop object from file - */ - public static Shop deserialize(String serialized) { - Shop shop = new GsonProcessor().fromJson(serialized, Shop.class); - shop.fixAfterLoad(); - return shop; - } - - /** * Loads a shop from file and returns the Shop object * * @param loc Location of the shop sign @@ -260,15 +246,6 @@ public int getAvailableTrades() { return availableTrades; } - /** - * Serializes the object to Json using Gson - * - * @return serialized string - */ - public String serialize() { - return new GsonProcessor().toJson(this); - } - /** * Returns the shop signs location as a ShopLocation * diff --git a/src/main/java/org/shanerx/tradeshop/shop/ShopType.java b/src/main/java/org/shanerx/tradeshop/shop/ShopType.java index c0972bc0..cd13e877 100644 --- a/src/main/java/org/shanerx/tradeshop/shop/ShopType.java +++ b/src/main/java/org/shanerx/tradeshop/shop/ShopType.java @@ -35,10 +35,8 @@ import org.shanerx.tradeshop.player.Permissions; import org.shanerx.tradeshop.utils.gsonprocessing.GsonProcessor; -import java.io.Serializable; - -public enum ShopType implements Serializable { +public enum ShopType { TRADE(Permissions.CREATE), @@ -82,10 +80,6 @@ public static ShopType getType(Sign s) { return null; } - public static ShopType deserialize(String serialized) { - return new GsonProcessor().fromJson(serialized, ShopType.class); - } - @Override public String toString() { return getKey().getString(); @@ -105,10 +99,6 @@ public boolean checkPerm(Player pl) { return Permissions.hasPermission(pl, perm); } - public String serialize() { - return new GsonProcessor().toJson(this); - } - public boolean isTrade() { return this.equals(TRADE); } diff --git a/src/main/java/org/shanerx/tradeshop/shoplocation/ShopChunk.java b/src/main/java/org/shanerx/tradeshop/shoplocation/ShopChunk.java index dfc3c8a2..a18faf60 100644 --- a/src/main/java/org/shanerx/tradeshop/shoplocation/ShopChunk.java +++ b/src/main/java/org/shanerx/tradeshop/shoplocation/ShopChunk.java @@ -31,7 +31,7 @@ import java.io.Serializable; -public class ShopChunk implements Serializable { +public class ShopChunk { final private String div = ";;"; private final World world; diff --git a/src/main/java/org/shanerx/tradeshop/shoplocation/ShopLocation.java b/src/main/java/org/shanerx/tradeshop/shoplocation/ShopLocation.java index f7fe073e..66b42327 100644 --- a/src/main/java/org/shanerx/tradeshop/shoplocation/ShopLocation.java +++ b/src/main/java/org/shanerx/tradeshop/shoplocation/ShopLocation.java @@ -32,7 +32,7 @@ import java.io.Serializable; -public class ShopLocation implements Serializable { +public class ShopLocation { final private String div = "::"; private transient World world; diff --git a/src/main/java/org/shanerx/tradeshop/utils/objects/Tuple.java b/src/main/java/org/shanerx/tradeshop/utils/objects/Tuple.java index d8cf9c6e..cf3082fc 100644 --- a/src/main/java/org/shanerx/tradeshop/utils/objects/Tuple.java +++ b/src/main/java/org/shanerx/tradeshop/utils/objects/Tuple.java @@ -28,9 +28,7 @@ import com.google.gson.annotations.SerializedName; import org.shanerx.tradeshop.utils.gsonprocessing.GsonProcessor; -import java.io.Serializable; - -public class Tuple implements Serializable { +public class Tuple { @SerializedName("right") private R r;