Compare commits
10 Commits
5202301fdb
...
af6c052404
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
af6c052404 | ||
|
|
c209e0098a | ||
|
|
11c5c69dc7 | ||
|
|
d6d0556d5c | ||
|
|
8e606458b2 | ||
|
|
dabdafb1de | ||
|
|
13c8caed99 | ||
|
|
ce2b8deef9 | ||
|
|
e7886b5e83 | ||
|
|
5c3bbf4203 |
|
|
@ -7,13 +7,13 @@ import net.minecrell.pluginyml.paper.PaperPluginDescription
|
||||||
plugins {
|
plugins {
|
||||||
id("java")
|
id("java")
|
||||||
id("java-library")
|
id("java-library")
|
||||||
id("de.eldoria.plugin-yml.paper") version "0.8.0"
|
id("de.eldoria.plugin-yml.paper") version "0.9.0"
|
||||||
id("xyz.jpenilla.run-paper") version "1.0.6"
|
id("xyz.jpenilla.run-paper") version "1.0.6"
|
||||||
id("maven-publish")
|
id("maven-publish")
|
||||||
}
|
}
|
||||||
|
|
||||||
group = "com.alttd.playershops"
|
group = "com.alttd.playershops"
|
||||||
version = System.getenv("BUILD_NUMBER") ?: "1.3-SNAPSHOT"
|
version = System.getenv("BUILD_NUMBER") ?: "1.4-SNAPSHOT"
|
||||||
description = "Player Shop plugin for Altitude."
|
description = "Player Shop plugin for Altitude."
|
||||||
|
|
||||||
apply<JavaLibraryPlugin>()
|
apply<JavaLibraryPlugin>()
|
||||||
|
|
@ -29,16 +29,17 @@ tasks {
|
||||||
}
|
}
|
||||||
|
|
||||||
runServer {
|
runServer {
|
||||||
val fileName = "./run/cosmos.jar"
|
val dir = File(System.getProperty("user.home") + "/share/devserver/")
|
||||||
val file = File(fileName)
|
if (!dir.parentFile.exists()) {
|
||||||
if (!file.parentFile.exists()) {
|
dir.parentFile.mkdirs()
|
||||||
file.parentFile.mkdirs()
|
|
||||||
}
|
|
||||||
if (!file.exists()) {
|
|
||||||
// download("https://jenkins.destro.xyz/job/Cosmos/lastSuccessfulBuild/artifact/cosmos-server/build/libs/cosmos-bundler-1.21.11-R0.1-SNAPSHOT-mojmap.jar", fileName)
|
|
||||||
}
|
}
|
||||||
|
runDirectory.set(dir)
|
||||||
|
|
||||||
|
val fileName = "/cosmos.jar"
|
||||||
|
val file = File(dir.path + fileName)
|
||||||
|
|
||||||
serverJar(file)
|
serverJar(file)
|
||||||
minecraftVersion("1.21")
|
minecraftVersion("26.2")
|
||||||
}
|
}
|
||||||
|
|
||||||
jar {
|
jar {
|
||||||
|
|
@ -73,8 +74,8 @@ dependencies {
|
||||||
}
|
}
|
||||||
compileOnly("com.github.TechFortress:GriefPrevention:16.17.1")
|
compileOnly("com.github.TechFortress:GriefPrevention:16.17.1")
|
||||||
|
|
||||||
compileOnly("org.projectlombok:lombok:1.18.30")
|
compileOnly("org.projectlombok:lombok:1.18.46")
|
||||||
annotationProcessor("org.projectlombok:lombok:1.18.30")
|
annotationProcessor("org.projectlombok:lombok:1.18.46")
|
||||||
}
|
}
|
||||||
|
|
||||||
fun download(link: String, path: String) {
|
fun download(link: String, path: String) {
|
||||||
|
|
|
||||||
|
|
@ -174,12 +174,14 @@ public class MessageConfig {
|
||||||
public static String GUI_HOME_TITLE = "<green>PlayerShops";
|
public static String GUI_HOME_TITLE = "<green>PlayerShops";
|
||||||
public static String GUI_LIST_PLAYERS_TITLE = "<green>Player shops";
|
public static String GUI_LIST_PLAYERS_TITLE = "<green>Player shops";
|
||||||
public static String GUI_LIST_SHOPS_TITLE = "<green>Players shops by <playername>";
|
public static String GUI_LIST_SHOPS_TITLE = "<green>Players shops by <playername>";
|
||||||
|
public static String GUI_LIST_SHOPS_ITEM_TITLE = "<green>Players shops by item";
|
||||||
public static String GUI_LIST_TRANSACTIONS_TITLE = "<green>Shop Transactions";
|
public static String GUI_LIST_TRANSACTIONS_TITLE = "<green>Shop Transactions";
|
||||||
public static String GUI_MANAGE_TITLE = "<green>Shop Manager";
|
public static String GUI_MANAGE_TITLE = "<green>Shop Manager";
|
||||||
public static String GUI_PLAYER_SETTINGS_TITLE = "<green>Shop Settings Manager";
|
public static String GUI_PLAYER_SETTINGS_TITLE = "<green>Shop Settings Manager";
|
||||||
private static void guiTitles() {
|
private static void guiTitles() {
|
||||||
GUI_HOME_TITLE = getString("gui.home-title", GUI_HOME_TITLE);
|
GUI_HOME_TITLE = getString("gui.home-title", GUI_HOME_TITLE);
|
||||||
GUI_LIST_PLAYERS_TITLE = getString("gui.list-players-title", GUI_LIST_PLAYERS_TITLE);
|
GUI_LIST_PLAYERS_TITLE = getString("gui.list-players-title", GUI_LIST_PLAYERS_TITLE);
|
||||||
|
GUI_LIST_SHOPS_ITEM_TITLE = getString("gui.list-items-title", GUI_LIST_SHOPS_ITEM_TITLE);
|
||||||
GUI_LIST_SHOPS_TITLE = getString("gui.list-shops-title", GUI_LIST_SHOPS_TITLE);
|
GUI_LIST_SHOPS_TITLE = getString("gui.list-shops-title", GUI_LIST_SHOPS_TITLE);
|
||||||
GUI_LIST_TRANSACTIONS_TITLE = getString("gui.list-transactions-title", GUI_LIST_TRANSACTIONS_TITLE);
|
GUI_LIST_TRANSACTIONS_TITLE = getString("gui.list-transactions-title", GUI_LIST_TRANSACTIONS_TITLE);
|
||||||
GUI_MANAGE_TITLE = getString("gui.manage-title", GUI_MANAGE_TITLE);
|
GUI_MANAGE_TITLE = getString("gui.manage-title", GUI_MANAGE_TITLE);
|
||||||
|
|
|
||||||
|
|
@ -85,9 +85,6 @@ public class ManageShopDialog extends AbstractDialog {
|
||||||
.initial(false)
|
.initial(false)
|
||||||
.build()
|
.build()
|
||||||
);
|
);
|
||||||
inputs.add(
|
|
||||||
DialogInput.singleOption("item", MiniMessage.miniMessage().deserialize("<gold>Item</gold>"), itemEntries()).build()
|
|
||||||
);
|
|
||||||
int maxQty = (shop.isInitialized() && shop.getItemStack() != null ? shop.getItemStack().getMaxStackSize() : 64);
|
int maxQty = (shop.isInitialized() && shop.getItemStack() != null ? shop.getItemStack().getMaxStackSize() : 64);
|
||||||
int initialQty = (shop.isInitialized() ? Math.min(shop.getAmount(), maxQty) : 1);
|
int initialQty = (shop.isInitialized() ? Math.min(shop.getAmount(), maxQty) : 1);
|
||||||
inputs.add(
|
inputs.add(
|
||||||
|
|
@ -148,19 +145,21 @@ public class ManageShopDialog extends AbstractDialog {
|
||||||
|
|
||||||
// Change Item
|
// Change Item
|
||||||
if (Boolean.TRUE.equals(view.getBoolean("changeitem"))) {
|
if (Boolean.TRUE.equals(view.getBoolean("changeitem"))) {
|
||||||
String selection = view.getText("item");
|
ItemStack itemStack = player.getInventory().getItemInMainHand().clone();
|
||||||
if (selection != null) {
|
shop.setItemStack(itemStack);
|
||||||
if (selection.equalsIgnoreCase("reset")) {
|
// String selection = view.getText("item");
|
||||||
shop.setItemStack(null);
|
// if (selection != null) {
|
||||||
} else {
|
// if (selection.equalsIgnoreCase("reset")) {
|
||||||
int slot;
|
// shop.setItemStack(null);
|
||||||
try {
|
// } else {
|
||||||
slot = Integer.parseInt(selection);
|
// int slot;
|
||||||
shop.setItemStack(player.getInventory().getItem(slot));
|
// try {
|
||||||
} catch (NumberFormatException ignored) {
|
// slot = Integer.parseInt(selection);
|
||||||
}
|
// shop.setItemStack(player.getInventory().getItem(slot));
|
||||||
}
|
// } catch (NumberFormatException ignored) {
|
||||||
}
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
// Change Amount
|
// Change Amount
|
||||||
|
|
@ -188,27 +187,27 @@ public class ManageShopDialog extends AbstractDialog {
|
||||||
actions.add(saveButton);
|
actions.add(saveButton);
|
||||||
}
|
}
|
||||||
|
|
||||||
List<SingleOptionDialogInput.OptionEntry> itemEntries() {
|
// List<SingleOptionDialogInput.OptionEntry> itemEntries() {
|
||||||
List<SingleOptionDialogInput.OptionEntry> optionEntries = new ArrayList<>();
|
// List<SingleOptionDialogInput.OptionEntry> optionEntries = new ArrayList<>();
|
||||||
|
//
|
||||||
if (getPlayer() == null) {
|
// if (getPlayer() == null) {
|
||||||
return optionEntries;
|
// return optionEntries;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
optionEntries.add(
|
// optionEntries.add(
|
||||||
SingleOptionDialogInput.OptionEntry.create("reset", MiniMessage.miniMessage().deserialize("<gold>Reset"), false)
|
// SingleOptionDialogInput.OptionEntry.create("reset", MiniMessage.miniMessage().deserialize("<gold>Reset"), false)
|
||||||
);
|
// );
|
||||||
|
//
|
||||||
for (int i = 0; i < getPlayer().getInventory().getSize() ; i++) {
|
// for (int i = 0; i < getPlayer().getInventory().getSize() ; i++) {
|
||||||
ItemStack item = getPlayer().getInventory().getItem(i);
|
// ItemStack item = getPlayer().getInventory().getItem(i);
|
||||||
if (item == null || item.getType() == Material.AIR) continue;
|
// if (item == null || item.getType() == Material.AIR) continue;
|
||||||
ItemStack itemStack = item.clone();
|
// ItemStack itemStack = item.clone();
|
||||||
optionEntries.add(
|
// optionEntries.add(
|
||||||
SingleOptionDialogInput.OptionEntry.create(String.valueOf(i), ShopUtil.spriteComponent(itemStack), shop.getItemStack() == itemStack)
|
// SingleOptionDialogInput.OptionEntry.create(String.valueOf(i), ShopUtil.spriteComponent(itemStack), shop.getItemStack() == itemStack)
|
||||||
);
|
// );
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
return optionEntries;
|
// return optionEntries;
|
||||||
}
|
// }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -44,7 +44,7 @@ public class SearchShopsDialog extends AbstractDialog {
|
||||||
closeButton,
|
closeButton,
|
||||||
5)
|
5)
|
||||||
)
|
)
|
||||||
.base(DialogBase.builder(MiniMessage.miniMessage().deserialize(MessageConfig.GUI_LIST_SHOPS_TITLE))
|
.base(DialogBase.builder(MiniMessage.miniMessage().deserialize(MessageConfig.GUI_LIST_SHOPS_ITEM_TITLE))
|
||||||
.body(texts)
|
.body(texts)
|
||||||
.inputs(inputs)
|
.inputs(inputs)
|
||||||
.afterAction(DialogBase.DialogAfterAction.CLOSE)
|
.afterAction(DialogBase.DialogAfterAction.CLOSE)
|
||||||
|
|
@ -59,6 +59,11 @@ public class SearchShopsDialog extends AbstractDialog {
|
||||||
|
|
||||||
for (Map.Entry<Material, List<PlayerShop>> entry : PlayerShops.getInstance().getShopHandler().shopByMaterial().entrySet()) {
|
for (Map.Entry<Material, List<PlayerShop>> entry : PlayerShops.getInstance().getShopHandler().shopByMaterial().entrySet()) {
|
||||||
actions.add(ActionButton.builder(ShopUtil.spriteComponent(entry.getKey()))
|
actions.add(ActionButton.builder(ShopUtil.spriteComponent(entry.getKey()))
|
||||||
|
.tooltip(
|
||||||
|
MiniMessage.miniMessage().deserialize(
|
||||||
|
entry.getValue().size() + "<green> Shops"
|
||||||
|
)
|
||||||
|
)
|
||||||
.action(
|
.action(
|
||||||
DialogAction.customClick((view, audience) -> {
|
DialogAction.customClick((view, audience) -> {
|
||||||
if (!(audience instanceof Player player)) {
|
if (!(audience instanceof Player player)) {
|
||||||
|
|
|
||||||
|
|
@ -210,7 +210,7 @@ public class ShopHandler {
|
||||||
* @return TreeMap containing a list of PlayerShops per material.
|
* @return TreeMap containing a list of PlayerShops per material.
|
||||||
*/
|
*/
|
||||||
public TreeMap<Material, List<PlayerShop>> shopByMaterial() {
|
public TreeMap<Material, List<PlayerShop>> shopByMaterial() {
|
||||||
// TODO -- make this a cache. update cache on change, do not calc dynamicly
|
// TODO -- make this a cache. update cache on change, do not calc dynamically
|
||||||
TreeMap<Material, List<PlayerShop>> shopByMaterialTreeSet = new TreeMap<>();
|
TreeMap<Material, List<PlayerShop>> shopByMaterialTreeSet = new TreeMap<>();
|
||||||
|
|
||||||
for (PlayerShop shop : getShops()) {
|
for (PlayerShop shop : getShops()) {
|
||||||
|
|
@ -218,7 +218,7 @@ public class ShopHandler {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
Material material = shop.getItemStack().getType();
|
Material material = shop.getShopItemType();
|
||||||
List<PlayerShop> shopList = shopByMaterialTreeSet.computeIfAbsent(material, v -> new ArrayList<>());
|
List<PlayerShop> shopList = shopByMaterialTreeSet.computeIfAbsent(material, v -> new ArrayList<>());
|
||||||
shopList.add(shop);
|
shopList.add(shop);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -148,9 +148,10 @@ public class PlayerShop {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Inventory getInventory() {
|
public Inventory getInventory() {
|
||||||
// Could use a check if the block is still an InventoryHolder.
|
if (shopLocation.getBlock().getState() instanceof InventoryHolder inventoryHolder) {
|
||||||
InventoryHolder container = (InventoryHolder) shopLocation.getBlock().getState();
|
return inventoryHolder.getInventory();
|
||||||
return container.getInventory();
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isInitialized() {
|
public boolean isInitialized() {
|
||||||
|
|
@ -432,12 +433,15 @@ public class PlayerShop {
|
||||||
}
|
}
|
||||||
|
|
||||||
public ItemStack getItemStack() {
|
public ItemStack getItemStack() {
|
||||||
if (!isInitialized())
|
if (!isInitialized()) {
|
||||||
return null;
|
return null;
|
||||||
if (this.getType() != ShopType.RANDOM)
|
}
|
||||||
|
if (this.getType() != ShopType.RANDOM) {
|
||||||
return itemStack;
|
return itemStack;
|
||||||
if (this.getInventory().isEmpty())
|
}
|
||||||
|
if (this.getInventory() == null) {
|
||||||
return null;
|
return null;
|
||||||
|
}
|
||||||
ArrayList<ItemStack> contents = new ArrayList<>();
|
ArrayList<ItemStack> contents = new ArrayList<>();
|
||||||
for (ItemStack it : this.getInventory().getContents()) {
|
for (ItemStack it : this.getInventory().getContents()) {
|
||||||
if (it != null) {
|
if (it != null) {
|
||||||
|
|
@ -468,11 +472,13 @@ public class PlayerShop {
|
||||||
Component component = ShopUtil.itemNameComponent(getItemStack())
|
Component component = ShopUtil.itemNameComponent(getItemStack())
|
||||||
.append(Component.newline())
|
.append(Component.newline())
|
||||||
.append(Component.newline())
|
.append(Component.newline())
|
||||||
|
.append(Component.text("ShopOwner: " + getOwnerName()))
|
||||||
|
.append(Component.newline())
|
||||||
.append(Component.text("ShopType: " + type))
|
.append(Component.text("ShopType: " + type))
|
||||||
.append(Component.newline())
|
.append(Component.newline())
|
||||||
.append(Component.text("Price: " + price))
|
.append(Component.text("Price: " + price))
|
||||||
.append(Component.newline())
|
.append(Component.newline())
|
||||||
.append(Component.text("ShopType: " + amount))
|
.append(Component.text("Amount: " + amount))
|
||||||
.append(Component.newline())
|
.append(Component.newline())
|
||||||
.append(Component.text("World: " + shopLocation.getWorld().getName()))
|
.append(Component.text("World: " + shopLocation.getWorld().getName()))
|
||||||
.append(Component.newline())
|
.append(Component.newline())
|
||||||
|
|
@ -484,4 +490,11 @@ public class PlayerShop {
|
||||||
|
|
||||||
return component;
|
return component;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Material getShopItemType() {
|
||||||
|
if (this.type == ShopType.RANDOM) {
|
||||||
|
return Material.STRUCTURE_VOID; // TODO -- Load from config
|
||||||
|
}
|
||||||
|
return itemStack.getType();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -209,8 +209,7 @@ public class ItemMatcher {
|
||||||
if (mapView1 == null || mapView2 == null)
|
if (mapView1 == null || mapView2 == null)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (mapView1.getId() == mapView2.getId())
|
return mapView1.getId() == mapView2.getId();
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user