Compare commits

..

No commits in common. "df388ed93fb3ead0199b70838be02acc6b08ccce" and "fa8e43eeb0e38bdc74268e35590ac3cb35590a10" have entirely different histories.

9 changed files with 44 additions and 38 deletions

View File

@ -12,7 +12,7 @@ plugins {
} }
group = "com.alttd.playershops" group = "com.alttd.playershops"
version = System.getenv("BUILD_NUMBER") ?: "1.3-SNAPSHOT" version = System.getenv("BUILD_NUMBER") ?: "1.2-SNAPSHOT"
description = "Player Shop plugin for Altitude." description = "Player Shop plugin for Altitude."
apply<JavaLibraryPlugin>() apply<JavaLibraryPlugin>()
@ -34,13 +34,14 @@ tasks {
} }
runServer { runServer {
val fileName = "./run/cosmos.jar" // runDirectory.set(File("./run1"))
val fileName = "./run/galaxy.jar"
val file = File(fileName) val file = File(fileName)
if (!file.parentFile.exists()) { if (!file.parentFile.exists()) {
file.parentFile.mkdirs() file.parentFile.mkdirs()
} }
if (!file.exists()) { if (!file.exists()) {
download("https://jenkins.destro.xyz/job/Cosmos/lastSuccessfulBuild/artifact/cosmos-server/build/libs/cosmos-bundler-1.21.6-R0.1-SNAPSHOT-mojmap.jar", fileName) download("https://jenkins.destro.xyz/job/Galaxy/lastSuccessfulBuild/artifact/build/libs/Galaxy-paperclip-1.21-R0.1-SNAPSHOT-reobf.jar", fileName)
} }
serverJar(file) serverJar(file)
minecraftVersion("1.21") minecraftVersion("1.21")
@ -70,7 +71,7 @@ publishing {
} }
dependencies { dependencies {
compileOnly("com.alttd.cosmos:cosmos-api:1.21.6-R0.1-SNAPSHOT") compileOnly("com.alttd:Galaxy-API:1.21-R0.1-SNAPSHOT")
compileOnly("com.github.milkbowl:VaultAPI:1.7") { compileOnly("com.github.milkbowl:VaultAPI:1.7") {
exclude("org.bukkit","bukkit") exclude("org.bukkit","bukkit")
} }

View File

@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.2-bin.zip distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
networkTimeout=10000 networkTimeout=10000
validateDistributionUrl=true validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME

View File

@ -8,7 +8,6 @@ import com.alttd.playershops.shop.PlayerShop;
import com.alttd.playershops.utils.ShopUtil; import com.alttd.playershops.utils.ShopUtil;
import com.alttd.playershops.utils.Util; import com.alttd.playershops.utils.Util;
import com.destroystokyo.paper.ParticleBuilder; import com.destroystokyo.paper.ParticleBuilder;
import net.kyori.adventure.chat.ChatType;
import net.kyori.adventure.text.Component; import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder; import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver; import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
@ -49,11 +48,11 @@ public class CheckStockCommand implements Subcommand {
public boolean doStockCheck(final CommandSender sender, final String[] args) { public boolean doStockCheck(final CommandSender sender, final String[] args) {
if (!(sender instanceof Player player)) { if (!(sender instanceof Player player)) {
sender.sendRichMessage("<red>Only players can use this command."); sender.sendMessage(Util.parseMiniMessage("<red>Only players can use this command."));
return false; return false;
} }
if (args.length != 1 && args.length != 2) { if (args.length != 1 && args.length != 2) {
player.sendRichMessage("<red>Invalid command syntax, use /checkstock <radius> [minimum stock]"); player.sendMessage(Util.parseMiniMessage("<red>Invalid command syntax, use /checkstock <radius> [minimum stock]"));
return false; return false;
} }
@ -61,12 +60,12 @@ public class CheckStockCommand implements Subcommand {
try { try {
radius = Integer.parseInt(args[0]); radius = Integer.parseInt(args[0]);
} catch (NumberFormatException e) { } catch (NumberFormatException e) {
player.sendRichMessage("<red>radius has to be a valid number, use /checkstock <radius> [minimum stock]"); player.sendMessage(Util.parseMiniMessage("<red>radius has to be a valid number, use /checkstock <radius> [minimum stock]"));
return false; return false;
} }
if (radius > 100 || radius <= 0) { if (radius > 100 || radius <= 0) {
player.sendRichMessage("<red>Please keep the radius between 1 and 100"); player.sendMessage(Util.parseMiniMessage("<red>Please keep the radius between 1 and 100"));
return false; return false;
} }
@ -74,7 +73,7 @@ public class CheckStockCommand implements Subcommand {
try { try {
minimumStock = Integer.parseInt(args[1]); minimumStock = Integer.parseInt(args[1]);
} catch (NumberFormatException e) { } catch (NumberFormatException e) {
player.sendRichMessage("<red>minimum stock has to be a valid number, use /checkstock <radius> [minimum stock]"); player.sendMessage(Util.parseMiniMessage("<red>minimum stock has to be a valid number, use /checkstock <radius> [minimum stock]"));
return false; return false;
} }
} }
@ -176,11 +175,11 @@ public class CheckStockCommand implements Subcommand {
} }
if (component == null) if (component == null)
if (minimumStock == -1) if (minimumStock == -1)
player.sendRichMessage("<yellow>No shops that you have permission to view found in specified radius.<yellow>"); player.sendMessage(Util.parseMiniMessage("<yellow>No shops that you have permission to view found in specified radius.<yellow>"));
else else
player.sendRichMessage( player.sendMessage(Util.parseMiniMessage(
"<yellow>No shops with less than <minimum_stock> stock found.</yellow>", "<yellow>No shops with less than <minimum_stock> stock found.</yellow>",
TagResolver.resolver(Placeholder.parsed("minimum_stock", minimumStock + ""))); TagResolver.resolver(Placeholder.parsed("minimum_stock", minimumStock + ""))));
else else
player.sendMessage(component); player.sendMessage(component);
} }

View File

@ -33,31 +33,31 @@ public class TransferShopsCommand implements Subcommand {
@Override @Override
public boolean execute(CommandSender sender, String subCommand, String[] args) { public boolean execute(CommandSender sender, String subCommand, String[] args) {
if (!(sender instanceof Player player)) { if (!(sender instanceof Player player)) {
sender.sendRichMessage("<red>Only players can use this command."); sender.sendMiniMessage("<red>Only players can use this command.", null);
return false; return false;
} }
if (args.length != 1 && args.length != 2) { if (args.length != 1 && args.length != 2) {
player.sendRichMessage("<red>Invalid command syntax, use /transfershops <uuid> <newplayer>"); player.sendMiniMessage("<red>Invalid command syntax, use /transfershops <uuid> <newplayer>", null);
return false; return false;
} }
OfflinePlayer oldOfflinePlayer = Bukkit.getOfflinePlayer(args[0]); OfflinePlayer oldOfflinePlayer = Bukkit.getOfflinePlayer(args[0]);
if (!oldOfflinePlayer.hasPlayedBefore()) { if (!oldOfflinePlayer.hasPlayedBefore()) {
player.sendRichMessage("<red>" + args[0] + " has not joined this server before."); player.sendMiniMessage("<red>" + args[0] + " has not joined this server before.", null);
return false; return false;
} }
Player newShopOwner = Bukkit.getPlayer(args[1]); Player newShopOwner = Bukkit.getPlayer(args[1]);
if (newShopOwner == null) { if (newShopOwner == null) {
player.sendRichMessage("<red>" + args[1] + " is not online and has to be online for this process."); player.sendMiniMessage("<red>" + args[1] + " is not online and has to be online for this process.", null);
return false; return false;
} }
UUID oldUUID = oldOfflinePlayer.getUniqueId(); UUID oldUUID = oldOfflinePlayer.getUniqueId();
List<PlayerShop> playerShops = PlayerShops.getInstance().getShopHandler().getShops(oldUUID); List<PlayerShop> playerShops = PlayerShops.getInstance().getShopHandler().getShops(oldUUID);
sender.sendRichMessage("<red>Starting the transfer process now, this might lag the server."); sender.sendMiniMessage("<red>Starting the transfer process now, this might lag the server.", null);
for (PlayerShop playerShop : playerShops) { for (PlayerShop playerShop : playerShops) {
playerShop.setOwner(newShopOwner); playerShop.setOwner(newShopOwner);
} }
newShopOwner.sendRichMessage(playerShops.size() + " have been transferred to you."); newShopOwner.sendMiniMessage(playerShops.size() + " have been transferred to you.", null);
sender.sendRichMessage(playerShops.size() + " have been transferred to " + args[1] + "."); sender.sendMiniMessage(playerShops.size() + " have been transferred to " + args[1] + ".", null);
return true; return true;
} }

View File

@ -95,7 +95,7 @@ public class ListShopsGui extends AbstractGui {
Placeholder.parsed("balance", String.valueOf(d)), Placeholder.parsed("balance", String.valueOf(d)),
Placeholder.parsed("count", String.valueOf(count)) Placeholder.parsed("count", String.valueOf(count))
); );
player.sendRichMessage(count > 0 ? "<green>You have collected <balance> from <count> shops." : "<red>No shops to be collected from.", placeholders); player.sendMiniMessage(count > 0 ? "<green>You have collected <balance> from <count> shops." : "<red>No shops to be collected from.", placeholders);
return; return;
} }

View File

@ -98,7 +98,7 @@ public class ShopManagementGui extends AbstractGui {
Placeholder.parsed("balance", String.valueOf(d)), Placeholder.parsed("balance", String.valueOf(d)),
Placeholder.parsed("count", String.valueOf(count)) Placeholder.parsed("count", String.valueOf(count))
); );
player.sendRichMessage("<green>You have collected <balance> from <count> shops.", placeholders); player.sendMiniMessage("<green>You have collected <balance> from <count> shops.", placeholders);
return; return;
} }
@ -111,13 +111,13 @@ public class ShopManagementGui extends AbstractGui {
if (EconomyUtils.getFunds(getPlayer()) > 0) { if (EconomyUtils.getFunds(getPlayer()) > 0) {
openChangePrompt(ConversationType.ADD_BALANCE); openChangePrompt(ConversationType.ADD_BALANCE);
} else { } else {
getPlayer().sendRichMessage("<red>You do not have money to add to this shop"); getPlayer().sendMiniMessage("<red>You do not have money to add to this shop", null);
} }
} else if (slot == GuiIcon.MANAGE_SHOP_BALANCE_REMOVE.getSlot() && GuiIcon.MANAGE_SHOP_BALANCE_REMOVE.getItemStack().equals(item)) { } else if (slot == GuiIcon.MANAGE_SHOP_BALANCE_REMOVE.getSlot() && GuiIcon.MANAGE_SHOP_BALANCE_REMOVE.getItemStack().equals(item)) {
if (shop.getBalance() > 0) { if (shop.getBalance() > 0) {
openChangePrompt(ConversationType.WITHDRAW_BALANCE); openChangePrompt(ConversationType.WITHDRAW_BALANCE);
} else { } else {
getPlayer().sendRichMessage("<red>You can't withdraw money from this shop"); getPlayer().sendMiniMessage("<red>You can't widraw money from this shop", null);
} }
} else if (slot == GuiIcon.MANAGE_SHOP_SALES.getSlot() && GuiIcon.MANAGE_SHOP_SALES.getItemStack().equals(item)) { } else if (slot == GuiIcon.MANAGE_SHOP_SALES.getSlot() && GuiIcon.MANAGE_SHOP_SALES.getItemStack().equals(item)) {
ListTransactionsGui listTransactionsGui = new ListTransactionsGui(uuid, shop); ListTransactionsGui listTransactionsGui = new ListTransactionsGui(uuid, shop);

View File

@ -104,14 +104,14 @@ public class PlayerListener extends EventListener {
// Player player = event.getPlayer(); // Player player = event.getPlayer();
if(shop != null) { if(shop != null) {
event.setCancelled(true); event.setCancelled(true);
player.sendRichMessage(MessageConfig.SHOP_ALREADY_EXISTS); player.sendMiniMessage(MessageConfig.SHOP_ALREADY_EXISTS, null);
return; return;
} }
UUID playerUUID = player.getUniqueId(); UUID playerUUID = player.getUniqueId();
if (!player.hasPermission("playershops.shop.create")) { if (!player.hasPermission("playershops.shop.create")) {
event.setCancelled(true); event.setCancelled(true);
player.sendRichMessage(MessageConfig.NO_SHOP_CREATE_PERMISSION); player.sendMiniMessage(MessageConfig.NO_SHOP_CREATE_PERMISSION, null);
return; return;
} }
@ -120,13 +120,13 @@ public class PlayerListener extends EventListener {
if (numberOfShops >= shopLimit) { if (numberOfShops >= shopLimit) {
event.setCancelled(true); event.setCancelled(true);
player.sendRichMessage(MessageConfig.SHOP_LIMIT_REACHED, Placeholder.parsed("limit", String.valueOf(shopLimit))); player.sendMiniMessage(MessageConfig.SHOP_LIMIT_REACHED, Placeholder.parsed("limit", String.valueOf(shopLimit)));
return; return;
} }
if (!EconomyUtils.hasSufficientFunds(player, Config.shopCreationBalance + Config.shopCreationCost)) { if (!EconomyUtils.hasSufficientFunds(player, Config.shopCreationBalance + Config.shopCreationCost)) {
event.setCancelled(true); event.setCancelled(true);
player.sendRichMessage(MessageConfig.INSUFFICIENT_FUNDS); player.sendMiniMessage(MessageConfig.INSUFFICIENT_FUNDS, null);
return; return;
} }

View File

@ -5,6 +5,8 @@ import com.alttd.playershops.config.MessageConfig;
import com.alttd.playershops.handler.ShopHandler; import com.alttd.playershops.handler.ShopHandler;
import com.alttd.playershops.shop.PlayerShop; import com.alttd.playershops.shop.PlayerShop;
import com.alttd.playershops.utils.EconomyUtils; import com.alttd.playershops.utils.EconomyUtils;
import com.destroystokyo.paper.MaterialSetTag;
import me.ryanhamshire.GriefPrevention.events.ClaimExpirationEvent;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.Tag; import org.bukkit.Tag;
@ -14,6 +16,8 @@ import org.bukkit.block.BlockFace;
import org.bukkit.block.BlockState; import org.bukkit.block.BlockState;
import org.bukkit.block.Sign; import org.bukkit.block.Sign;
import org.bukkit.block.data.BlockData; import org.bukkit.block.data.BlockData;
import org.bukkit.block.data.Directional;
import org.bukkit.block.data.Rotatable;
import org.bukkit.block.data.type.WallSign; import org.bukkit.block.data.type.WallSign;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
@ -31,6 +35,8 @@ import org.bukkit.inventory.InventoryHolder;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import java.util.Iterator; import java.util.Iterator;
import java.util.List;
import java.util.UUID;
/** /**
* Dedicated class to listen to events related to shops. * Dedicated class to listen to events related to shops.
@ -133,7 +139,7 @@ public class ShopListener extends EventListener {
} }
if (player.isConversing()) { // TODO enhance method to check if the conversation is about this shop if (player.isConversing()) { // TODO enhance method to check if the conversation is about this shop
player.sendRichMessage(MessageConfig.BREAK_SHOP_WHILE_CONVERSING); player.sendMiniMessage(MessageConfig.BREAK_SHOP_WHILE_CONVERSING, null);
event.setCancelled(true); event.setCancelled(true);
return; return;
} }

View File

@ -64,7 +64,7 @@ public class TransactionListener extends EventListener {
String shopType = playerShop.getType().toString(); String shopType = playerShop.getType().toString();
if (!player.hasPermission("playershops.shop.use." + shopType)) { if (!player.hasPermission("playershops.shop.use." + shopType)) {
player.sendRichMessage(MessageConfig.NO_PERMISSION_FOR_SHOP_TYPE, Placeholder.unparsed("shop_type", shopType)); player.sendMiniMessage(MessageConfig.NO_PERMISSION_FOR_SHOP_TYPE, Placeholder.unparsed("shop_type", shopType));
event.setCancelled(true); event.setCancelled(true);
return; return;
} }
@ -134,7 +134,7 @@ public class TransactionListener extends EventListener {
TagResolver placeholders = TagResolver.resolver(type, stock); TagResolver placeholders = TagResolver.resolver(type, stock);
player.sendRichMessage(MessageConfig.SHOP_STOCK_INFO, placeholders); player.sendMiniMessage(MessageConfig.SHOP_STOCK_INFO, placeholders);
} }
private void giveInfo(PlayerShop playerShop, Player player) { private void giveInfo(PlayerShop playerShop, Player player) {
@ -156,7 +156,7 @@ public class TransactionListener extends EventListener {
Placeholder.parsed("price", "" + ShopUtil.round(playerShop.getPrice())) Placeholder.parsed("price", "" + ShopUtil.round(playerShop.getPrice()))
); );
player.sendRichMessage(MessageConfig.SHOP_INFO, placeholders); player.sendMiniMessage(MessageConfig.SHOP_INFO, placeholders);
} }
private void executeTransaction(Player player, PlayerShop shop) { private void executeTransaction(Player player, PlayerShop shop) {
@ -185,13 +185,13 @@ public class TransactionListener extends EventListener {
// TODO notify shopowner in game if not on cooldown and once per day on discord if linked and enabled // TODO notify shopowner in game if not on cooldown and once per day on discord if linked and enabled
shopOwner.sendActionBar(Util.parseMiniMessage(shop.getType().getShopTypeConfig().yourShopNoFunds, placeholders)); shopOwner.sendActionBar(Util.parseMiniMessage(shop.getType().getShopTypeConfig().yourShopNoFunds, placeholders));
} }
player.sendRichMessage(shop.getType().getShopTypeConfig().shopNoStock, placeholders); player.sendMiniMessage(shop.getType().getShopTypeConfig().shopNoStock, placeholders);
} }
case INSUFFICIENT_FUNDS_PLAYER -> { case INSUFFICIENT_FUNDS_PLAYER -> {
player.sendRichMessage(shop.getType().getShopTypeConfig().playerNoFunds, placeholders); player.sendMiniMessage(shop.getType().getShopTypeConfig().playerNoFunds, placeholders);
} }
case INSUFFICIENT_ITEMS_PLAYER -> { case INSUFFICIENT_ITEMS_PLAYER -> {
player.sendRichMessage(shop.getType().getShopTypeConfig().playerNoItems, placeholders); player.sendMiniMessage(shop.getType().getShopTypeConfig().playerNoItems, placeholders);
} }
case INVENTORY_FULL_SHOP -> { case INVENTORY_FULL_SHOP -> {
Player shopOwner = Bukkit.getPlayer(shop.getOwnerUUID()); Player shopOwner = Bukkit.getPlayer(shop.getOwnerUUID());
@ -199,10 +199,10 @@ public class TransactionListener extends EventListener {
shopOwner.sendActionBar(Util.parseMiniMessage(shop.getType().getShopTypeConfig().yourShopNoStock, placeholders)); shopOwner.sendActionBar(Util.parseMiniMessage(shop.getType().getShopTypeConfig().yourShopNoStock, placeholders));
// TODO notify shopowner in game if not on cooldown and once per day on discord if linked and enabled // TODO notify shopowner in game if not on cooldown and once per day on discord if linked and enabled
} }
player.sendRichMessage(shop.getType().getShopTypeConfig().shopInventoryFull, placeholders); player.sendMiniMessage(shop.getType().getShopTypeConfig().shopInventoryFull, placeholders);
} }
case INVENTORY_FULL_PLAYER -> { case INVENTORY_FULL_PLAYER -> {
player.sendRichMessage(shop.getType().getShopTypeConfig().playerInventoryFull, placeholders); player.sendMiniMessage(shop.getType().getShopTypeConfig().playerInventoryFull, placeholders);
} }
} }
return; return;