Skip to content

Commit

Permalink
1.0.1
Browse files Browse the repository at this point in the history
Fixed newPage upgade
  • Loading branch information
DVDishka committed Aug 28, 2022
1 parent 21f8c26 commit cac3a00
Show file tree
Hide file tree
Showing 11 changed files with 220 additions and 339 deletions.
13 changes: 9 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,25 @@

### _Plugin that add shops to your server_

## Releases

* paper - only for paper and paper forks
* spigot - for all spigot forks (most server cores)

## Commands

#### Main

* `/shop create <name>` command to create a shop
* `/shop open` command to open shop menu (click on the icon to open shop)![img.png](img.png)
* `/shop upgrade <shopName>` command to open shop upgrade menu (Stick - `new Line`, Paper - `new Page`)![img_3.png](img_3.png)
* `/shop open` command to open shop menu (click on the icon to open shop)![img.png](images/img.png)
* `/shop upgrade <shopName>` command to open shop upgrade menu (Stick - `new Line`, Paper - `new Page`)![img_3.png](images/img_3.png)
* `/shop coffer <shopName>` Command to open shop storage where sales revenue is located

#### Edit

* `/shop edit <shopName> name <newName>` command to change shop name
* `/shop edit <shopName> price <page> <index> <material> <amount>` command to set the price for an item in the shop![img_2.png](img_2.png)
* `/shop edit <shopName> icon` command to open icon menu![img_1.png](img_1.png)
* `/shop edit <shopName> price <page> <index> <material> <amount>` command to set the price for an item in the shop![img_2.png](images/img_2.png)
* `/shop edit <shopName> icon` command to open icon menu![img_1.png](images/img_1.png)

## Notes

Expand Down
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
22 changes: 16 additions & 6 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>dvdishka</groupId>
<artifactId>shops</artifactId>
<version>1.0.0-paper</version>
<version>1.0.1-spigot</version>
<packaging>jar</packaging>

<name>Shops</name>
Expand Down Expand Up @@ -56,8 +56,8 @@

<repositories>
<repository>
<id>papermc-repo</id>
<url>https://papermc.io/repo/repository/maven-public/</url>
<id>spigot-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository>
<repository>
<id>sonatype</id>
Expand All @@ -67,10 +67,20 @@

<dependencies>
<dependency>
<groupId>io.papermc.paper</groupId>
<artifactId>paper-api</artifactId>
<version>1.18.2-R0.1-SNAPSHOT</version>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.16.5-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>net.kyori</groupId>
<artifactId>adventure-api</artifactId>
<version>4.11.0</version>
</dependency>
<dependency>
<groupId>net.md-5</groupId>
<artifactId>bungeecord-chat</artifactId>
<version>1.16-R0.4</version>
</dependency>
</dependencies>
</project>
1 change: 0 additions & 1 deletion src/main/java/ru/dvdishka/shops/common/Functions.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.checkerframework.checker.units.qual.A;

import java.util.ArrayList;

Expand Down
1 change: 0 additions & 1 deletion src/main/java/ru/dvdishka/shops/shop/Classes/Upgrade.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import org.bukkit.configuration.serialization.ConfigurationSerializable;
import org.bukkit.configuration.serialization.SerializableAs;
import org.jetbrains.annotations.NotNull;
import ru.dvdishka.shops.common.CommonVariables;

import java.util.HashMap;
import java.util.Map;
Expand Down
108 changes: 37 additions & 71 deletions src/main/java/ru/dvdishka/shops/shop/shopHandlers/CommandExecutor.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
package ru.dvdishka.shops.shop.shopHandlers;

import com.destroystokyo.paper.Title;
import net.kyori.adventure.sound.Sound;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.TextComponent;
import net.kyori.adventure.text.event.ClickEvent;
import net.md_5.bungee.api.chat.BaseComponent;
import net.md_5.bungee.api.chat.ClickEvent;
import net.md_5.bungee.api.chat.ComponentBuilder;
import org.bukkit.Sound;
import ru.dvdishka.shops.common.ConfigVariables;
import ru.dvdishka.shops.shop.Classes.Shop;
import ru.dvdishka.shops.common.CommonVariables;
Expand Down Expand Up @@ -50,15 +49,17 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command

CommonVariables.playerShopCreating.put(player.getName(), shopName);

TextComponent text = Component
.text("Creating a shop costs " + ConfigVariables.shopCost.getAmount() + " "
BaseComponent[] text = new ComponentBuilder("Creating a shop costs " + ConfigVariables.shopCost.getAmount() + " "
+ ConfigVariables.shopCost.getType().name().toLowerCase() + "\n")
.append(Component.text(ChatColor.GREEN + "[CREATE]")
.clickEvent(ClickEvent.runCommand("/shop creating " + shopName + " " + player.getName())))
.append(Component.text(" "))
.append(Component.text(ChatColor.RED + "[CANCEL]")
.clickEvent(ClickEvent.runCommand("/shop creating cancel " + player.getName())));
sender.sendMessage(text);
.append("[CREATE]")
.color(net.md_5.bungee.api.ChatColor.GREEN)
.event(new net.md_5.bungee.api.chat.ClickEvent(net.md_5.bungee.api.chat.ClickEvent.Action.RUN_COMMAND, "/shop creating " + shopName + " " + player.getName()))
.append(" ")
.append("[CANCEL]")
.color(net.md_5.bungee.api.ChatColor.RED)
.event(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/shop creating cancel " + player.getName()))
.create();
sender.spigot().sendMessage(text);
return true;
}

Expand Down Expand Up @@ -107,18 +108,12 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command
CommonVariables.shopsInventories.put(shop.getName(), pages);
CommonVariables.playerShopCreating.remove(player.getName());

player.playSound(
net.kyori.adventure.sound.Sound.sound
(org.bukkit.Sound.ENTITY_PLAYER_LEVELUP,
Sound.Source.NEUTRAL,
50,
1));

player.sendTitle(Title
.builder()
.title(ChatColor.DARK_GREEN + shop.getName())
.subtitle(ChatColor.GOLD + "has been created")
.build());
player.playSound(player.getLocation(),
Sound.ENTITY_PLAYER_LEVELUP,
50, 1);

player.sendTitle(ChatColor.DARK_GREEN + shop.getName(),
ChatColor.GOLD + "has been created");
return true;
}

Expand Down Expand Up @@ -253,20 +248,13 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command
}
ItemMeta meta = CommonVariables.shopsInventories.get(shop.getName()).get(page - 1).getItem(index - 1).getItemMeta();

List<BaseComponent[]> list = new ArrayList<>();
list.add(new ComponentBuilder("Price: ")
.color(net.md_5.bungee.api.ChatColor.GREEN)
.append(args[6])
.color(net.md_5.bungee.api.ChatColor.RED)
.append(" ")
.append(args[5].toUpperCase())
.color(net.md_5.bungee.api.ChatColor.RED)
.create());
meta.setLoreComponents(list);
List<String> list = new ArrayList<>();
list.add(ChatColor.GREEN + "Price: " + ChatColor.RED + args[6] + " " + args[5].toUpperCase());
meta.setLore(list);

CommonVariables.shopsInventories.get(shop.getName()).get(page - 1).getItem(index - 1).setItemMeta(meta);
player.sendTitle(Title.builder().title(ChatColor.DARK_GREEN + shop.getName()).subtitle(ChatColor.GOLD +
"price has been set").build());
player.sendTitle(ChatColor.DARK_GREEN + shop.getName(), ChatColor.GOLD +
"price has been set");
return true;
}

Expand Down Expand Up @@ -310,10 +298,8 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command
checkShop.setIcon(icon);
}
}
player.sendTitle(Title.builder()
.title(ChatColor.DARK_GREEN + name)
.subtitle(ChatColor.GOLD + "Shop name has been set")
.build());
player.sendTitle(ChatColor.DARK_GREEN + name,
ChatColor.GOLD + "Shop name has been set");
return true;
}

Expand Down Expand Up @@ -425,43 +411,23 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command

ItemStack newPage = new ItemStack(Material.PAPER);
ItemMeta newPageMeta = newPage.getItemMeta();
newPageMeta.setDisplayNameComponent(new ComponentBuilder("New Page")
.color(net.md_5.bungee.api.ChatColor.LIGHT_PURPLE)
.create());
List<BaseComponent[]> lore = new ArrayList<>();
lore.add(new ComponentBuilder("Price: ")
.color(net.md_5.bungee.api.ChatColor.GREEN)
.append(ConfigVariables.newPageCost.getAmount() + " " +
ConfigVariables.newPageCost.getType().name())
.color(net.md_5.bungee.api.ChatColor.RED)
.create());
lore.add(new ComponentBuilder("Progress: ")
.color(net.md_5.bungee.api.ChatColor.AQUA)
.append(String.valueOf(shop.getUpgrade().getPageProgress()))
.color(net.md_5.bungee.api.ChatColor.GOLD)
.create());
newPageMeta.setLoreComponents(lore);
newPageMeta.setDisplayName(ChatColor.LIGHT_PURPLE + "New Page");
List<String> lore = new ArrayList<>();
lore.add(ChatColor.GREEN + "Price: " + ChatColor.RED + ConfigVariables.newPageCost.getAmount() + " " +
ConfigVariables.newPageCost.getType().name());
lore.add(ChatColor.AQUA + "Progress: " + ChatColor.GOLD + shop.getUpgrade().getPageProgress());
newPageMeta.setLore(lore);
newPage.setItemMeta(newPageMeta);
inventory.setItem(13, newPage);

ItemStack newLine = new ItemStack(Material.STICK);
ItemMeta newLineMeta = newLine.getItemMeta();
newLineMeta.setDisplayNameComponent(new ComponentBuilder("New Line")
.color(net.md_5.bungee.api.ChatColor.GREEN)
.create());
List<BaseComponent[]> newLineLore = new ArrayList<>();
newLineLore.add(new ComponentBuilder("Price: ")
.color(net.md_5.bungee.api.ChatColor.GREEN)
.append(ConfigVariables.newLineCost.getAmount() + " " +
ConfigVariables.newLineCost.getType().name())
.color(net.md_5.bungee.api.ChatColor.RED)
.create());
newLineLore.add(new ComponentBuilder("Progress: ")
.color(net.md_5.bungee.api.ChatColor.AQUA)
.append(shop.getUpgrade().getLineProgress() + "/6")
.color(net.md_5.bungee.api.ChatColor.GOLD)
.create());
newLineMeta.setLoreComponents(newLineLore);
newLineMeta.setDisplayName(ChatColor.GREEN + "New Line");
List<String> newLineLore = new ArrayList<>();
newLineLore.add(ChatColor.GREEN + "Price: " + ChatColor.RED + ConfigVariables.newLineCost.getAmount() + " " +
ConfigVariables.newLineCost.getType().name());
newLineLore.add(ChatColor.AQUA + "Progress: " + ChatColor.GOLD + shop.getUpgrade().getLineProgress() + "/6");
newLineMeta.setLore(newLineLore);
newLine.setItemMeta(newLineMeta);
inventory.setItem(12, newLine);

Expand Down
Loading

0 comments on commit cac3a00

Please sign in to comment.