Split project
This commit is contained in:
@@ -1,77 +0,0 @@
|
||||
package com.alttd.playershops.shop;
|
||||
|
||||
import com.alttd.playershops.api.Shop;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.block.data.Directional;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public abstract class AbstractShop implements Shop {
|
||||
|
||||
@Getter
|
||||
private int id;
|
||||
private String ownerName;
|
||||
@Getter
|
||||
private UUID ownerUUID;
|
||||
@Getter @Setter
|
||||
private ShopType type;
|
||||
@Getter
|
||||
private Location signLocation;
|
||||
@Getter
|
||||
private Location containerLocation;
|
||||
@Getter
|
||||
private String server;
|
||||
@Getter @Setter
|
||||
private double price;
|
||||
@Getter @Setter
|
||||
private int amount;
|
||||
@Getter @Setter
|
||||
private double balance;
|
||||
@Getter @Setter
|
||||
private ItemStack itemStack;
|
||||
@Getter @Setter
|
||||
private ItemStack secondaryItem;
|
||||
@Getter @Setter
|
||||
private long lastTransaction;
|
||||
|
||||
protected boolean initialized;
|
||||
|
||||
AbstractShop(Location signLocation, UUID uuid, double price, int amount) {
|
||||
this.signLocation = signLocation;
|
||||
if (signLocation != null) {
|
||||
Directional sign = (Directional) signLocation.getBlock().getState().getBlockData();
|
||||
this.containerLocation = signLocation.getBlock().getRelative(sign.getFacing().getOppositeFace()).getLocation();
|
||||
}
|
||||
this.ownerUUID = uuid;
|
||||
ownerName = getOwnerName();
|
||||
this.price = price;
|
||||
this.amount = amount;
|
||||
}
|
||||
|
||||
public static AbstractShop create(Location signLocation, UUID player, double price, int amount, ShopType shopType) {
|
||||
return switch (shopType) {
|
||||
case SELL -> new SellShop(signLocation, player, price, amount);
|
||||
case BUY -> new BuyShop(signLocation, player, price, amount);
|
||||
case GAMBLE -> new GambleShop(signLocation, player, price, amount);
|
||||
case BARTER -> new BarterShop(signLocation, player, price, amount);
|
||||
};
|
||||
}
|
||||
|
||||
public String getOwnerName() {
|
||||
if(this.ownerName != null) return ownerName;
|
||||
if (this.getOwnerUUID() != null) {
|
||||
ownerName = Bukkit.getOfflinePlayer(this.getOwnerUUID()).getName();
|
||||
return ownerName;
|
||||
}
|
||||
return ChatColor.RED + "[CLOSED]";
|
||||
}
|
||||
|
||||
public boolean isInitialized() {
|
||||
return initialized;
|
||||
}
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
package com.alttd.playershops.shop;
|
||||
|
||||
import org.bukkit.Location;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class BarterShop extends AbstractShop {
|
||||
|
||||
public BarterShop(Location location, UUID player, double price, int amount) {
|
||||
super(location, player, price, amount);
|
||||
|
||||
this.setType(ShopType.BARTER);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
package com.alttd.playershops.shop;
|
||||
|
||||
import org.bukkit.Location;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class BuyShop extends AbstractShop {
|
||||
|
||||
public BuyShop(Location location, UUID player, double price, int amount) {
|
||||
super(location, player, price, amount);
|
||||
|
||||
this.setType(ShopType.BUY);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
package com.alttd.playershops.shop;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class GambleShop extends AbstractShop {
|
||||
|
||||
private ItemStack gambleItem;
|
||||
|
||||
public GambleShop(Location location, UUID player, double price, int amount) {
|
||||
super(location, player, price, amount);
|
||||
|
||||
this.setType(ShopType.GAMBLE);
|
||||
this.gambleItem = this.getItemStack();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
package com.alttd.playershops.shop;
|
||||
|
||||
import org.bukkit.Location;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class SellShop extends AbstractShop {
|
||||
|
||||
public SellShop(Location location, UUID player, double price, int amount) {
|
||||
super(location, player, price, amount);
|
||||
|
||||
this.setType(ShopType.SELL);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
package com.alttd.playershops.shop;
|
||||
|
||||
public class ShopTransaction {
|
||||
|
||||
public enum ShopTransactionError {
|
||||
CANCELLED,
|
||||
INSUFFICIENT_FUNDS_SHOP,
|
||||
INSUFFICIENT_FUNDS_PLAYER,
|
||||
INVENTORY_FULL_SHOP,
|
||||
INVENTORY_FULL_PLAYER,
|
||||
NONE;
|
||||
}
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
package com.alttd.playershops.shop;
|
||||
|
||||
public enum ShopTransactionError {
|
||||
CANCELLED,
|
||||
INSUFFICIENT_FUNDS_SHOP,
|
||||
INSUFFICIENT_FUNDS_PLAYER,
|
||||
INVENTORY_FULL_SHOP,
|
||||
INVENTORY_FULL_PLAYER,
|
||||
NONE;
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
package com.alttd.playershops.shop;
|
||||
|
||||
import com.alttd.playershops.config.ShopTypeConfig;
|
||||
|
||||
public enum ShopType {
|
||||
|
||||
SELL,
|
||||
BUY,
|
||||
GAMBLE,
|
||||
BARTER;
|
||||
|
||||
private final ShopTypeConfig shopTypeConfig;
|
||||
|
||||
ShopType() {
|
||||
this.shopTypeConfig = new ShopTypeConfig(toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return name().toLowerCase();
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user