Initial commit
This commit is contained in:
70
pom.xml
Normal file
70
pom.xml
Normal file
@@ -0,0 +1,70 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>com.github.krzysiek944</groupId>
|
||||
<artifactId>MSCROLE</artifactId>
|
||||
<version>1.2</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>MSCROLE</name>
|
||||
|
||||
<properties>
|
||||
<java.version>1.8</java.version>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.8.1</version>
|
||||
<configuration>
|
||||
<source>${java.version}</source>
|
||||
<target>${java.version}</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
<version>3.2.4</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>shade</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>src/main/resources</directory>
|
||||
<filtering>true</filtering>
|
||||
</resource>
|
||||
</resources>
|
||||
</build>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>papermc-repo</id>
|
||||
<url>https://repo.papermc.io/repository/maven-public/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>sonatype</id>
|
||||
<url>https://oss.sonatype.org/content/groups/public/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>io.papermc.paper</groupId>
|
||||
<artifactId>paper-api</artifactId>
|
||||
<version>1.21-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
101
src/main/java/com/github/krzysiek944/mscrole/MSCROLE.java
Normal file
101
src/main/java/com/github/krzysiek944/mscrole/MSCROLE.java
Normal file
@@ -0,0 +1,101 @@
|
||||
package com.github.krzysiek944.mscrole;
|
||||
|
||||
import com.github.krzysiek944.mscrole.commands.MscroleAdminCommand;
|
||||
import com.github.krzysiek944.mscrole.commands.MscroleCommand;
|
||||
import com.github.krzysiek944.mscrole.listeners.GuiListener;
|
||||
import com.github.krzysiek944.mscrole.listeners.PlayerJoinListener;
|
||||
import com.github.krzysiek944.mscrole.services.CurrencyManager;
|
||||
import com.github.krzysiek944.mscrole.services.ShopManager;
|
||||
import com.github.krzysiek944.mscrole.utils.DataManager;
|
||||
import com.github.krzysiek944.mscrole.utils.ShopDataManager;
|
||||
import com.github.krzysiek944.mscrole.utils.MessageManager;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.bukkit.ChatColor;
|
||||
|
||||
import java.util.logging.Logger;
|
||||
import java.io.File;
|
||||
|
||||
public class MSCROLE extends JavaPlugin {
|
||||
|
||||
private static MSCROLE instance;
|
||||
private CurrencyManager currencyManager;
|
||||
private DataManager dataManager;
|
||||
private ShopManager shopManager;
|
||||
private ShopDataManager shopDataManager;
|
||||
private MessageManager messageManager;
|
||||
private Logger logger = Logger.getLogger("Minecraft");
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
instance = this;
|
||||
saveDefaultConfig();
|
||||
|
||||
this.dataManager = new DataManager();
|
||||
this.dataManager.saveDefaultConfig();
|
||||
this.currencyManager = new CurrencyManager(dataManager);
|
||||
|
||||
this.shopDataManager = new ShopDataManager();
|
||||
this.shopDataManager.saveDefaultConfig();
|
||||
this.shopManager = new ShopManager(shopDataManager);
|
||||
|
||||
this.messageManager = new MessageManager(this);
|
||||
|
||||
getServer().getPluginManager().registerEvents(new PlayerJoinListener(this), this);
|
||||
getServer().getPluginManager().registerEvents(new GuiListener(), this);
|
||||
|
||||
getCommand("mscroll").setExecutor(new MscroleCommand());
|
||||
getCommand("mscrolladmin").setExecutor(new MscroleAdminCommand());
|
||||
|
||||
getLogger().info("Plugin MSCROLE został włączony!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
getLogger().info("Plugin MSCROLE został wyłączony!");
|
||||
}
|
||||
|
||||
public String getPrefix() {
|
||||
return ChatColor.translateAlternateColorCodes('&', getConfig().getString("prefix"));
|
||||
}
|
||||
|
||||
public static MSCROLE getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
public CurrencyManager getCurrencyManager() {
|
||||
return currencyManager;
|
||||
}
|
||||
|
||||
public DataManager getDataManager() {
|
||||
return dataManager;
|
||||
}
|
||||
|
||||
public ShopManager getShopManager() {
|
||||
return shopManager;
|
||||
}
|
||||
|
||||
public ShopDataManager getShopDataManager() {
|
||||
return shopDataManager;
|
||||
}
|
||||
|
||||
public MessageManager getMessageManager() {
|
||||
return messageManager;
|
||||
}
|
||||
|
||||
public void logToFile(String message) {
|
||||
try {
|
||||
File dataFolder = getDataFolder();
|
||||
if (!dataFolder.exists()) {
|
||||
dataFolder.mkdir();
|
||||
}
|
||||
File logFile = new File(getDataFolder(), "logs/currency.log");
|
||||
if (!logFile.exists()) {
|
||||
logFile.getParentFile().mkdirs();
|
||||
logFile.createNewFile();
|
||||
}
|
||||
java.nio.file.Files.write(logFile.toPath(), (new java.text.SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new java.util.Date()) + " " + message + "\n").getBytes(), java.nio.file.StandardOpenOption.APPEND);
|
||||
} catch (java.io.IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,222 @@
|
||||
package com.github.krzysiek944.mscrole.commands;
|
||||
|
||||
import com.github.krzysiek944.mscrole.MSCROLE;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class MscroleAdminCommand implements CommandExecutor {
|
||||
|
||||
private final MSCROLE plugin = MSCROLE.getInstance();
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (!sender.hasPermission(plugin.getConfig().getString("permissions.mscroleadmin"))) {
|
||||
sender.sendMessage(plugin.getPrefix() + plugin.getMessageManager().getMessage("no-permission"));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (args.length == 0) {
|
||||
sendHelp(sender);
|
||||
return true;
|
||||
}
|
||||
|
||||
String subCommand = args[0].toLowerCase();
|
||||
|
||||
switch (subCommand) {
|
||||
case "add":
|
||||
addItem(sender, args);
|
||||
break;
|
||||
case "remove":
|
||||
removeItem(sender, args);
|
||||
break;
|
||||
case "give":
|
||||
giveCurrency(sender, args);
|
||||
break;
|
||||
case "take":
|
||||
takeCurrency(sender, args);
|
||||
break;
|
||||
case "set":
|
||||
setCurrency(sender, args);
|
||||
break;
|
||||
case "list":
|
||||
listItems(sender);
|
||||
break;
|
||||
default:
|
||||
sender.sendMessage(plugin.getPrefix() + plugin.getMessageManager().getMessage("unknown-command"));
|
||||
break;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private void sendHelp(CommandSender sender) {
|
||||
sender.sendMessage("");
|
||||
sender.sendMessage(plugin.getMessageManager().getMessage("admin-help-header"));
|
||||
sender.sendMessage(plugin.getMessageManager().getMessage("admin-help-add"));
|
||||
sender.sendMessage(plugin.getMessageManager().getMessage("admin-help-remove"));
|
||||
sender.sendMessage(plugin.getMessageManager().getMessage("admin-help-give"));
|
||||
sender.sendMessage(plugin.getMessageManager().getMessage("admin-help-take"));
|
||||
sender.sendMessage(plugin.getMessageManager().getMessage("admin-help-set"));
|
||||
sender.sendMessage(plugin.getMessageManager().getMessage("admin-help-list"));
|
||||
sender.sendMessage(plugin.getMessageManager().getMessage("admin-help-footer"));
|
||||
sender.sendMessage("");
|
||||
}
|
||||
|
||||
private void addItem(CommandSender sender, String[] args) {
|
||||
if (args.length < 5) {
|
||||
sender.sendMessage(plugin.getPrefix() + plugin.getMessageManager().getMessage("invalid-usage").replace("{usage}", "/mscrolladmin add <slot> <price> <item> <amount> <commands>"));
|
||||
return;
|
||||
}
|
||||
|
||||
int slot;
|
||||
int price;
|
||||
Material material;
|
||||
int amount = 1;
|
||||
List<String> commands = new ArrayList<>();
|
||||
|
||||
try {
|
||||
slot = Integer.parseInt(args[1]);
|
||||
price = Integer.parseInt(args[2]);
|
||||
material = Material.getMaterial(args[3].toUpperCase());
|
||||
amount = Integer.parseInt(args[4]);
|
||||
for (int i = 5; i < args.length; i++) {
|
||||
commands.add(args[i]);
|
||||
}
|
||||
} catch (NumberFormatException e) {
|
||||
sender.sendMessage(plugin.getPrefix() + plugin.getMessageManager().getMessage("invalid-amount"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (material == null) {
|
||||
sender.sendMessage(plugin.getPrefix() + plugin.getMessageManager().getMessage("material-not-found").replace("{material}", args[3]));
|
||||
return;
|
||||
}
|
||||
|
||||
if (slot < 10 || slot > 43) {
|
||||
sender.sendMessage(plugin.getPrefix() + plugin.getMessageManager().getMessage("invalid-slot"));
|
||||
return;
|
||||
}
|
||||
|
||||
plugin.getShopManager().addItem(slot, price, commands, new ItemStack(material, amount));
|
||||
sender.sendMessage(plugin.getPrefix() + plugin.getMessageManager().getMessage("item-added").replace("{slot}", String.valueOf(slot)).replace("{price}", String.valueOf(price)));
|
||||
}
|
||||
|
||||
private void removeItem(CommandSender sender, String[] args) {
|
||||
if (args.length < 2) {
|
||||
sender.sendMessage(plugin.getPrefix() + plugin.getMessageManager().getMessage("invalid-usage").replace("{usage}", "/mscrolladmin remove <slot>"));
|
||||
return;
|
||||
}
|
||||
|
||||
int slot;
|
||||
try {
|
||||
slot = Integer.parseInt(args[1]);
|
||||
} catch (NumberFormatException e) {
|
||||
sender.sendMessage(plugin.getPrefix() + plugin.getMessageManager().getMessage("invalid-slot"));
|
||||
return;
|
||||
}
|
||||
|
||||
plugin.getShopManager().removeItem(slot);
|
||||
sender.sendMessage(plugin.getPrefix() + plugin.getMessageManager().getMessage("item-removed").replace("{slot}", String.valueOf(slot)));
|
||||
}
|
||||
|
||||
private void giveCurrency(CommandSender sender, String[] args) {
|
||||
if (args.length < 3) {
|
||||
sender.sendMessage(plugin.getPrefix() + plugin.getMessageManager().getMessage("invalid-usage").replace("{usage}", "/mscrolladmin give <player> <amount>"));
|
||||
return;
|
||||
}
|
||||
|
||||
Player target = Bukkit.getPlayer(args[1]);
|
||||
if (target == null) {
|
||||
sender.sendMessage(plugin.getPrefix() + plugin.getMessageManager().getMessage("player-not-found"));
|
||||
return;
|
||||
}
|
||||
|
||||
int amount;
|
||||
try {
|
||||
amount = Integer.parseInt(args[2]);
|
||||
} catch (NumberFormatException e) {
|
||||
sender.sendMessage(plugin.getPrefix() + plugin.getMessageManager().getMessage("invalid-amount"));
|
||||
return;
|
||||
}
|
||||
|
||||
plugin.getCurrencyManager().addBalance(target, amount);
|
||||
sender.sendMessage(plugin.getPrefix() + plugin.getMessageManager().getMessage("currency-given").replace("{amount}", String.valueOf(amount)).replace("{receiver}", target.getName()));
|
||||
target.sendMessage(plugin.getPrefix() + plugin.getMessageManager().getMessage("currency-received-from-admin").replace("{amount}", String.valueOf(amount)));
|
||||
}
|
||||
|
||||
private void takeCurrency(CommandSender sender, String[] args) {
|
||||
if (args.length < 3) {
|
||||
sender.sendMessage(plugin.getPrefix() + plugin.getMessageManager().getMessage("invalid-usage").replace("{usage}", "/mscrolladmin take <player> <amount>"));
|
||||
return;
|
||||
}
|
||||
|
||||
Player target = Bukkit.getPlayer(args[1]);
|
||||
if (target == null) {
|
||||
sender.sendMessage(plugin.getPrefix() + plugin.getMessageManager().getMessage("player-not-found"));
|
||||
return;
|
||||
}
|
||||
|
||||
int amount;
|
||||
try {
|
||||
amount = Integer.parseInt(args[2]);
|
||||
} catch (NumberFormatException e) {
|
||||
sender.sendMessage(plugin.getPrefix() + plugin.getMessageManager().getMessage("invalid-amount"));
|
||||
return;
|
||||
}
|
||||
|
||||
plugin.getCurrencyManager().subtractBalance(target, amount);
|
||||
sender.sendMessage(plugin.getPrefix() + plugin.getMessageManager().getMessage("currency-taken").replace("{amount}", String.valueOf(amount)).replace("{player}", target.getName()));
|
||||
target.sendMessage(plugin.getPrefix() + plugin.getMessageManager().getMessage("currency-taken-by-admin").replace("{amount}", String.valueOf(amount)));
|
||||
}
|
||||
|
||||
private void setCurrency(CommandSender sender, String[] args) {
|
||||
if (args.length < 3) {
|
||||
sender.sendMessage(plugin.getPrefix() + plugin.getMessageManager().getMessage("invalid-usage").replace("{usage}", "/mscrolladmin set <player> <amount>"));
|
||||
return;
|
||||
}
|
||||
|
||||
Player target = Bukkit.getPlayer(args[1]);
|
||||
if (target == null) {
|
||||
sender.sendMessage(plugin.getPrefix() + plugin.getMessageManager().getMessage("player-not-found"));
|
||||
return;
|
||||
}
|
||||
|
||||
int amount;
|
||||
try {
|
||||
amount = Integer.parseInt(args[2]);
|
||||
} catch (NumberFormatException e) {
|
||||
sender.sendMessage(plugin.getPrefix() + plugin.getMessageManager().getMessage("invalid-amount"));
|
||||
return;
|
||||
}
|
||||
|
||||
plugin.getCurrencyManager().setBalance(target, amount);
|
||||
sender.sendMessage(plugin.getPrefix() + plugin.getMessageManager().getMessage("balance-set").replace("{player}", target.getName()).replace("{amount}", String.valueOf(amount)));
|
||||
}
|
||||
|
||||
private void listItems(CommandSender sender) {
|
||||
sender.sendMessage("");
|
||||
sender.sendMessage(plugin.getMessageManager().getMessage("list-items-header"));
|
||||
ConfigurationSection itemsSection = plugin.getShopManager().getItems();
|
||||
if (itemsSection == null || itemsSection.getKeys(false).isEmpty()) {
|
||||
sender.sendMessage(plugin.getMessageManager().getMessage("shop-empty"));
|
||||
} else {
|
||||
for (String key : itemsSection.getKeys(false)) {
|
||||
int slot = Integer.parseInt(key);
|
||||
int price = itemsSection.getInt(key + ".price");
|
||||
ItemStack item = itemsSection.getItemStack(key + ".item");
|
||||
sender.sendMessage(plugin.getMessageManager().getMessage("list-items-format").replace("{slot}", String.valueOf(slot)).replace("{item}", item.getType().toString()).replace("{price}", String.valueOf(price)).replace("{currency}", plugin.getConfig().getString("currency-name")));
|
||||
}
|
||||
}
|
||||
sender.sendMessage(plugin.getMessageManager().getMessage("list-items-footer"));
|
||||
sender.sendMessage("");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,130 @@
|
||||
package com.github.krzysiek944.mscrole.commands;
|
||||
|
||||
import com.github.krzysiek944.mscrole.MSCROLE;
|
||||
import com.github.krzysiek944.mscrole.gui.AdminGUI;
|
||||
import com.github.krzysiek944.mscrole.gui.ShopGUI;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class MscroleCommand implements CommandExecutor {
|
||||
|
||||
private final MSCROLE plugin = MSCROLE.getInstance();
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (!(sender instanceof Player)) {
|
||||
sender.sendMessage(plugin.getMessageManager().getMessage("only-player"));
|
||||
return true;
|
||||
}
|
||||
|
||||
Player player = (Player) sender;
|
||||
|
||||
if (!player.hasPermission(plugin.getConfig().getString("permissions.mscrole"))) {
|
||||
player.sendMessage(plugin.getPrefix() + plugin.getMessageManager().getMessage("no-permission"));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (args.length == 0) {
|
||||
sendHelp(player);
|
||||
return true;
|
||||
}
|
||||
|
||||
String subCommand = args[0].toLowerCase();
|
||||
|
||||
switch (subCommand) {
|
||||
case "balans":
|
||||
case "balance":
|
||||
case "bal":
|
||||
showBalance(player);
|
||||
break;
|
||||
case "wyslij":
|
||||
case "send":
|
||||
case "pay":
|
||||
sendMoney(player, args);
|
||||
break;
|
||||
|
||||
case "sklep":
|
||||
case "shop":
|
||||
new ShopGUI().openShop(player);
|
||||
break;
|
||||
|
||||
case "admin":
|
||||
if (player.hasPermission(plugin.getConfig().getString("permissions.mscroleadmin"))) {
|
||||
new AdminGUI().openAdminPanel(player);
|
||||
} else {
|
||||
player.sendMessage(plugin.getPrefix() + plugin.getMessageManager().getMessage("no-permission"));
|
||||
}
|
||||
break;
|
||||
default:
|
||||
player.sendMessage(plugin.getPrefix() + plugin.getMessageManager().getMessage("unknown-command"));
|
||||
break;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private void sendHelp(Player player) {
|
||||
player.sendMessage("");
|
||||
player.sendMessage(plugin.getMessageManager().getMessage("help-header"));
|
||||
player.sendMessage(plugin.getMessageManager().getMessage("help-balance"));
|
||||
player.sendMessage(plugin.getMessageManager().getMessage("help-send"));
|
||||
player.sendMessage(plugin.getMessageManager().getMessage("help-shop"));
|
||||
player.sendMessage(plugin.getMessageManager().getMessage("help-admin"));
|
||||
player.sendMessage(plugin.getMessageManager().getMessage("help-footer"));
|
||||
player.sendMessage("");
|
||||
}
|
||||
|
||||
private void showBalance(Player player) {
|
||||
int balance = plugin.getCurrencyManager().getBalance(player);
|
||||
player.sendMessage(plugin.getPrefix() + plugin.getMessageManager().getMessage("currency-check").replace("{amount}", String.valueOf(balance)));
|
||||
}
|
||||
|
||||
private void sendMoney(Player player, String[] args) {
|
||||
if (args.length < 3) {
|
||||
player.sendMessage(plugin.getPrefix() + plugin.getMessageManager().getMessage("invalid-usage").replace("{usage}", "/mscroll send <player> <amount>"));
|
||||
return;
|
||||
}
|
||||
|
||||
Player target = Bukkit.getPlayer(args[1]);
|
||||
if (target == null) {
|
||||
player.sendMessage(plugin.getPrefix() + plugin.getMessageManager().getMessage("player-not-found"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (target == player) {
|
||||
player.sendMessage(plugin.getPrefix() + plugin.getMessageManager().getMessage("cannot-send-to-self"));
|
||||
return;
|
||||
}
|
||||
|
||||
int amount;
|
||||
try {
|
||||
amount = Integer.parseInt(args[2]);
|
||||
} catch (NumberFormatException e) {
|
||||
player.sendMessage(plugin.getPrefix() + plugin.getMessageManager().getMessage("invalid-amount"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (amount <= 0) {
|
||||
player.sendMessage(plugin.getPrefix() + plugin.getMessageManager().getMessage("amount-must-be-positive"));
|
||||
return;
|
||||
}
|
||||
|
||||
int playerBalance = plugin.getCurrencyManager().getBalance(player);
|
||||
if (playerBalance < amount) {
|
||||
player.sendMessage(plugin.getPrefix() + plugin.getMessageManager().getMessage("not-enough-currency").replace("{amount}", String.valueOf(playerBalance)));
|
||||
return;
|
||||
}
|
||||
|
||||
plugin.getCurrencyManager().subtractBalance(player, amount);
|
||||
plugin.getCurrencyManager().addBalance(target, amount);
|
||||
|
||||
player.sendMessage(plugin.getPrefix() + plugin.getMessageManager().getMessage("currency-sent").replace("{amount}", String.valueOf(amount)).replace("{receiver}", target.getName()));
|
||||
target.sendMessage(plugin.getPrefix() + plugin.getMessageManager().getMessage("currency-received").replace("{amount}", String.valueOf(amount)).replace("{sender}", player.getName()));
|
||||
|
||||
plugin.logToFile("[Currency] " + player.getName() + " sent " + amount + " to " + target.getName());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
package com.github.krzysiek944.mscrole.gui;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class AdminGUI {
|
||||
|
||||
public void openAdminPanel(Player player) {
|
||||
Inventory gui = Bukkit.createInventory(null, 27, "§c§lPanel Administratora");
|
||||
|
||||
// Frame
|
||||
ItemStack frame = new ItemStack(Material.RED_STAINED_GLASS_PANE);
|
||||
ItemMeta frameMeta = frame.getItemMeta();
|
||||
frameMeta.setDisplayName(" ");
|
||||
frame.setItemMeta(frameMeta);
|
||||
for (int i = 0; i < 27; i++) {
|
||||
if (i < 9 || i > 17) {
|
||||
gui.setItem(i, frame);
|
||||
}
|
||||
}
|
||||
|
||||
// Options
|
||||
ItemStack addItem = new ItemStack(Material.EMERALD);
|
||||
ItemMeta addItemMeta = addItem.getItemMeta();
|
||||
addItemMeta.setDisplayName("§a§lDodaj Przedmiot");
|
||||
List<String> addItemLore = new ArrayList<>();
|
||||
addItemLore.add("§7Kliknij aby dodać");
|
||||
addItemLore.add("§7przedmiot do sklepu");
|
||||
addItemMeta.setLore(addItemLore);
|
||||
addItem.setItemMeta(addItemMeta);
|
||||
gui.setItem(10, addItem);
|
||||
|
||||
ItemStack giveCurrency = new ItemStack(Material.DIAMOND);
|
||||
ItemMeta giveCurrencyMeta = giveCurrency.getItemMeta();
|
||||
giveCurrencyMeta.setDisplayName("§b§lDaj Walutę");
|
||||
List<String> giveCurrencyLore = new ArrayList<>();
|
||||
giveCurrencyLore.add("§7Kliknij aby dać");
|
||||
giveCurrencyLore.add("§7graczowi MSCROLE");
|
||||
giveCurrencyMeta.setLore(giveCurrencyLore);
|
||||
giveCurrency.setItemMeta(giveCurrencyMeta);
|
||||
gui.setItem(12, giveCurrency);
|
||||
|
||||
ItemStack takeCurrency = new ItemStack(Material.GOLD_INGOT);
|
||||
ItemMeta takeCurrencyMeta = takeCurrency.getItemMeta();
|
||||
takeCurrencyMeta.setDisplayName("§e§lZabierz Walutę");
|
||||
List<String> takeCurrencyLore = new ArrayList<>();
|
||||
takeCurrencyLore.add("§7Kliknij aby zabrać");
|
||||
takeCurrencyLore.add("§7graczowi MSCROLE");
|
||||
takeCurrencyMeta.setLore(takeCurrencyLore);
|
||||
takeCurrency.setItemMeta(takeCurrencyMeta);
|
||||
gui.setItem(14, takeCurrency);
|
||||
|
||||
ItemStack listItems = new ItemStack(Material.PAPER);
|
||||
ItemMeta listItemsMeta = listItems.getItemMeta();
|
||||
listItemsMeta.setDisplayName("§f§lLista Przedmiotów");
|
||||
List<String> listItemsLore = new ArrayList<>();
|
||||
listItemsLore.add("§7Kliknij aby zobaczyć");
|
||||
listItemsLore.add("§7wszystkie przedmioty w sklepie");
|
||||
listItemsMeta.setLore(listItemsLore);
|
||||
listItems.setItemMeta(listItemsMeta);
|
||||
gui.setItem(16, listItems);
|
||||
|
||||
ItemStack closeButton = new ItemStack(Material.BARRIER);
|
||||
ItemMeta closeMeta = closeButton.getItemMeta();
|
||||
closeMeta.setDisplayName("§c§lZamknij");
|
||||
closeMeta.setLore(new ArrayList<>());
|
||||
closeButton.setItemMeta(closeMeta);
|
||||
gui.setItem(22, closeButton);
|
||||
|
||||
player.openInventory(gui);
|
||||
}
|
||||
}
|
||||
133
src/main/java/com/github/krzysiek944/mscrole/gui/ShopGUI.java
Normal file
133
src/main/java/com/github/krzysiek944/mscrole/gui/ShopGUI.java
Normal file
@@ -0,0 +1,133 @@
|
||||
package com.github.krzysiek944.mscrole.gui;
|
||||
|
||||
import com.github.krzysiek944.mscrole.MSCROLE;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.inventory.meta.SkullMeta;
|
||||
import org.bukkit.ChatColor;
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class ShopGUI {
|
||||
|
||||
private final MSCROLE plugin = MSCROLE.getInstance();
|
||||
|
||||
public void openShop(Player player) {
|
||||
Inventory gui = Bukkit.createInventory(null, 54, "§6§lSklep MSCROLE");
|
||||
|
||||
// Decorative frame
|
||||
ItemStack frame = new ItemStack(Material.GRAY_STAINED_GLASS_PANE);
|
||||
ItemMeta frameMeta = frame.getItemMeta();
|
||||
frameMeta.setDisplayName(" ");
|
||||
frame.setItemMeta(frameMeta);
|
||||
|
||||
for (int i : new int[]{0, 1, 2, 3, 5, 6, 7, 8, 45, 46, 47, 48, 50, 51, 52, 53}) {
|
||||
gui.setItem(i, frame);
|
||||
}
|
||||
|
||||
// Balance info
|
||||
ItemStack balanceItem = new ItemStack(Material.PLAYER_HEAD);
|
||||
SkullMeta balanceMeta = (SkullMeta) balanceItem.getItemMeta();
|
||||
balanceMeta.setOwningPlayer(player);
|
||||
balanceMeta.setDisplayName("§e§lTwój Balans");
|
||||
List<String> balanceLore = new ArrayList<>();
|
||||
balanceLore.add("§7Posiadasz: §a" + (int) plugin.getCurrencyManager().getBalance(player) + " MSCROLE");
|
||||
balanceLore.add("");
|
||||
balanceLore.add("§7Kliknij przedmioty poniżej");
|
||||
balanceLore.add("§7aby je kupić!");
|
||||
balanceMeta.setLore(balanceLore);
|
||||
balanceItem.setItemMeta(balanceMeta);
|
||||
gui.setItem(4, balanceItem);
|
||||
|
||||
// Close button
|
||||
ItemStack closeButton = new ItemStack(Material.BARRIER);
|
||||
ItemMeta closeMeta = closeButton.getItemMeta();
|
||||
closeMeta.setDisplayName("§c§lZamknij");
|
||||
List<String> closeLore = new ArrayList<>();
|
||||
closeLore.add("§7Kliknij aby zamknąć sklep");
|
||||
closeMeta.setLore(closeLore);
|
||||
closeButton.setItemMeta(closeMeta);
|
||||
gui.setItem(49, closeButton);
|
||||
|
||||
// Load items
|
||||
ConfigurationSection itemsSection = plugin.getShopManager().getItems();
|
||||
if (itemsSection == null) {
|
||||
ItemStack empty = new ItemStack(Material.BARRIER);
|
||||
ItemMeta emptyMeta = empty.getItemMeta();
|
||||
emptyMeta.setDisplayName("§c§lSklep jest pusty!");
|
||||
List<String> emptyLore = new ArrayList<>();
|
||||
emptyLore.add("§7Administrator nie dodał");
|
||||
emptyLore.add("§7jeszcze żadnych przedmiotów!");
|
||||
emptyMeta.setLore(emptyLore);
|
||||
empty.setItemMeta(emptyMeta);
|
||||
gui.setItem(22, empty);
|
||||
} else {
|
||||
for (String key : itemsSection.getKeys(false)) {
|
||||
int slot = Integer.parseInt(key);
|
||||
ItemStack item = null;
|
||||
ConfigurationSection itemSection = itemsSection.getConfigurationSection(key + ".item");
|
||||
|
||||
if (itemSection != null && itemSection.isString("material")) {
|
||||
// New format
|
||||
String materialName = itemSection.getString("material").toUpperCase();
|
||||
Material material = Material.getMaterial(materialName);
|
||||
if (material == null) {
|
||||
plugin.getLogger().warning("Invalid material in shop.yml: " + materialName + " for slot " + key);
|
||||
continue;
|
||||
}
|
||||
int amount = itemSection.getInt("amount", 1);
|
||||
item = new ItemStack(material, amount);
|
||||
ItemMeta itemMeta = item.getItemMeta();
|
||||
if (itemMeta != null) {
|
||||
if (itemSection.isString("name")) {
|
||||
itemMeta.setDisplayName(ChatColor.translateAlternateColorCodes('&', itemSection.getString("name")));
|
||||
}
|
||||
if (itemSection.isList("lore")) {
|
||||
List<String> newLore = new ArrayList<>();
|
||||
for (String line : itemSection.getStringList("lore")) {
|
||||
newLore.add(ChatColor.translateAlternateColorCodes('&', line));
|
||||
}
|
||||
itemMeta.setLore(newLore);
|
||||
}
|
||||
item.setItemMeta(itemMeta);
|
||||
}
|
||||
} else {
|
||||
// Old format
|
||||
item = itemsSection.getItemStack(key + ".item");
|
||||
}
|
||||
|
||||
if (item == null) {
|
||||
plugin.getLogger().warning("Could not load item in shop.yml for slot " + key);
|
||||
continue;
|
||||
}
|
||||
|
||||
int price = itemsSection.getInt(key + ".price");
|
||||
|
||||
ItemMeta itemMeta = item.getItemMeta();
|
||||
List<String> lore;
|
||||
if (itemMeta.hasLore()) {
|
||||
lore = itemMeta.getLore();
|
||||
} else {
|
||||
lore = new ArrayList<>();
|
||||
}
|
||||
lore.add("");
|
||||
lore.add("§7Cena: §e" + price + " MSCROLE");
|
||||
lore.add("");
|
||||
lore.add("§eKliknij aby kupić!");
|
||||
itemMeta.setLore(lore);
|
||||
item.setItemMeta(itemMeta);
|
||||
|
||||
gui.setItem(slot, item);
|
||||
}
|
||||
}
|
||||
|
||||
player.openInventory(gui);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
package com.github.krzysiek944.mscrole.listeners;
|
||||
|
||||
import com.github.krzysiek944.mscrole.MSCROLE;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class GuiListener implements Listener {
|
||||
|
||||
private final MSCROLE plugin = MSCROLE.getInstance();
|
||||
|
||||
@EventHandler
|
||||
public void onInventoryClick(InventoryClickEvent event) {
|
||||
if (event.getView().getTitle().equals("§6§lSklep MSCROLE")) {
|
||||
event.setCancelled(true);
|
||||
Player player = (Player) event.getWhoClicked();
|
||||
ItemStack clickedItem = event.getCurrentItem();
|
||||
|
||||
if (clickedItem == null || clickedItem.getType() == Material.AIR) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (clickedItem.getType() == Material.BARRIER) {
|
||||
player.closeInventory();
|
||||
return;
|
||||
}
|
||||
|
||||
int slot = event.getSlot();
|
||||
int price = plugin.getShopManager().getItems().getInt(slot + ".price");
|
||||
List<String> commands = plugin.getShopManager().getItems().getStringList(slot + ".commands");
|
||||
|
||||
if (price > 0) {
|
||||
int balance = plugin.getCurrencyManager().getBalance(player);
|
||||
if (balance >= price) {
|
||||
plugin.getCurrencyManager().subtractBalance(player, price);
|
||||
for (String command : commands) {
|
||||
plugin.getServer().dispatchCommand(plugin.getServer().getConsoleSender(), command.replace("%player%", player.getName()));
|
||||
}
|
||||
player.sendMessage(plugin.getPrefix() + plugin.getMessageManager().getMessage("item-purchased").replace("{price}", String.valueOf(price)).replace("{currency}", plugin.getConfig().getString("currency-name")));
|
||||
player.playSound(player.getLocation(), Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1, 1);
|
||||
} else {
|
||||
player.sendMessage(plugin.getPrefix() + plugin.getMessageManager().getMessage("not-enough-currency-shop").replace("{currency}", plugin.getConfig().getString("currency-name")).replace("{price}", String.valueOf(price)));
|
||||
player.playSound(player.getLocation(), Sound.ENTITY_VILLAGER_NO, 1, 1);
|
||||
}
|
||||
}
|
||||
} else if (event.getView().getTitle().equals("§c§lPanel Administratora")) {
|
||||
event.setCancelled(true);
|
||||
Player player = (Player) event.getWhoClicked();
|
||||
ItemStack clickedItem = event.getCurrentItem();
|
||||
|
||||
if (clickedItem == null || clickedItem.getType() == Material.AIR) {
|
||||
return;
|
||||
}
|
||||
|
||||
player.closeInventory();
|
||||
|
||||
switch (clickedItem.getType()) {
|
||||
case EMERALD:
|
||||
player.sendMessage("");
|
||||
player.sendMessage(plugin.getPrefix() + plugin.getMessageManager().getMessage("admin-add-item-help-header"));
|
||||
player.sendMessage(plugin.getMessageManager().getMessage("admin-add-item-help-command"));
|
||||
player.sendMessage("");
|
||||
player.sendMessage(plugin.getMessageManager().getMessage("admin-add-item-help-example-command"));
|
||||
player.sendMessage(plugin.getMessageManager().getMessage("admin-add-item-help-example-description"));
|
||||
player.sendMessage("");
|
||||
break;
|
||||
case DIAMOND:
|
||||
player.sendMessage("");
|
||||
player.sendMessage(plugin.getPrefix() + plugin.getMessageManager().getMessage("admin-give-currency-help-header"));
|
||||
player.sendMessage(plugin.getMessageManager().getMessage("admin-give-currency-help-command"));
|
||||
player.sendMessage("");
|
||||
break;
|
||||
case GOLD_INGOT:
|
||||
player.sendMessage("");
|
||||
player.sendMessage(plugin.getPrefix() + plugin.getMessageManager().getMessage("admin-take-currency-help-header"));
|
||||
player.sendMessage(plugin.getMessageManager().getMessage("admin-take-currency-help-command"));
|
||||
player.sendMessage("");
|
||||
break;
|
||||
case PAPER:
|
||||
player.performCommand("mscrolladmin list");
|
||||
break;
|
||||
case BARRIER:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.github.krzysiek944.mscrole.listeners;
|
||||
|
||||
import com.github.krzysiek944.mscrole.MSCROLE;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
|
||||
public class PlayerJoinListener implements Listener {
|
||||
|
||||
private final MSCROLE plugin;
|
||||
|
||||
public PlayerJoinListener(MSCROLE plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerJoin(PlayerJoinEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
if (!player.hasPlayedBefore()) {
|
||||
int startingBalance = plugin.getConfig().getInt("starting-balance", 1000);
|
||||
plugin.getCurrencyManager().setBalance(player, startingBalance);
|
||||
player.sendMessage(plugin.getPrefix() + plugin.getMessageManager().getMessage("player-join").replace("{player}", player.getName()).replace("{amount}", String.valueOf(startingBalance)));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
package com.github.krzysiek944.mscrole.services;
|
||||
|
||||
import com.github.krzysiek944.mscrole.MSCROLE;
|
||||
import com.github.krzysiek944.mscrole.utils.DataManager;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class CurrencyManager {
|
||||
|
||||
private final MSCROLE plugin = MSCROLE.getInstance();
|
||||
private final DataManager dataManager;
|
||||
|
||||
public CurrencyManager(DataManager dataManager) {
|
||||
this.dataManager = dataManager;
|
||||
}
|
||||
|
||||
public int getBalance(Player player) {
|
||||
return getBalance(player.getUniqueId());
|
||||
}
|
||||
|
||||
public int getBalance(UUID uuid) {
|
||||
return dataManager.getConfig().getInt("balances." + uuid.toString(), 0);
|
||||
}
|
||||
|
||||
public void setBalance(Player player, int amount) {
|
||||
setBalance(player.getUniqueId(), amount);
|
||||
}
|
||||
|
||||
public void setBalance(UUID uuid, int amount) {
|
||||
dataManager.getConfig().set("balances." + uuid.toString(), amount);
|
||||
dataManager.saveConfig();
|
||||
plugin.logToFile("[Currency] Set balance of " + uuid.toString() + " to " + amount);
|
||||
}
|
||||
|
||||
public void addBalance(Player player, int amount) {
|
||||
addBalance(player.getUniqueId(), amount);
|
||||
}
|
||||
|
||||
public void addBalance(UUID uuid, int amount) {
|
||||
setBalance(uuid, getBalance(uuid) + amount);
|
||||
plugin.logToFile("[Currency] Added " + amount + " to " + uuid.toString());
|
||||
}
|
||||
|
||||
public void subtractBalance(Player player, int amount) {
|
||||
subtractBalance(player.getUniqueId(), amount);
|
||||
}
|
||||
|
||||
public void subtractBalance(UUID uuid, int amount) {
|
||||
setBalance(uuid, getBalance(uuid) - amount);
|
||||
plugin.logToFile("[Currency] Subtracted " + amount + " from " + uuid.toString());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package com.github.krzysiek944.mscrole.services;
|
||||
|
||||
import com.github.krzysiek944.mscrole.MSCROLE;
|
||||
import com.github.krzysiek944.mscrole.utils.ShopDataManager;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class ShopManager {
|
||||
|
||||
private final MSCROLE plugin = MSCROLE.getInstance();
|
||||
private final ShopDataManager shopDataManager;
|
||||
|
||||
public ShopManager(ShopDataManager shopDataManager) {
|
||||
this.shopDataManager = shopDataManager;
|
||||
}
|
||||
|
||||
public void addItem(int slot, int price, List<String> commands, ItemStack item) {
|
||||
String path = "items." + slot;
|
||||
shopDataManager.getConfig().set(path + ".price", price);
|
||||
shopDataManager.getConfig().set(path + ".commands", commands);
|
||||
shopDataManager.getConfig().set(path + ".item", item);
|
||||
shopDataManager.saveConfig();
|
||||
}
|
||||
|
||||
public void removeItem(int slot) {
|
||||
shopDataManager.getConfig().set("items." + slot, null);
|
||||
shopDataManager.saveConfig();
|
||||
}
|
||||
|
||||
public ConfigurationSection getItems() {
|
||||
return shopDataManager.getConfig().getConfigurationSection("items");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package com.github.krzysiek944.mscrole.utils;
|
||||
|
||||
import com.github.krzysiek944.mscrole.MSCROLE;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
public class DataManager {
|
||||
|
||||
private final MSCROLE plugin = MSCROLE.getInstance();
|
||||
private FileConfiguration dataConfig = null;
|
||||
private File configFile = null;
|
||||
|
||||
public void reloadConfig() {
|
||||
if (configFile == null) {
|
||||
configFile = new File(plugin.getDataFolder(), "data.yml");
|
||||
}
|
||||
dataConfig = YamlConfiguration.loadConfiguration(configFile);
|
||||
}
|
||||
|
||||
public FileConfiguration getConfig() {
|
||||
if (dataConfig == null) {
|
||||
reloadConfig();
|
||||
}
|
||||
return dataConfig;
|
||||
}
|
||||
|
||||
public void saveConfig() {
|
||||
if (dataConfig == null || configFile == null) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
getConfig().save(configFile);
|
||||
} catch (IOException e) {
|
||||
plugin.getLogger().severe("Could not save config to " + configFile);
|
||||
}
|
||||
}
|
||||
|
||||
public void saveDefaultConfig() {
|
||||
if (configFile == null) {
|
||||
configFile = new File(plugin.getDataFolder(), "data.yml");
|
||||
}
|
||||
if (!configFile.exists()) {
|
||||
plugin.saveResource("data.yml", false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package com.github.krzysiek944.mscrole.utils;
|
||||
|
||||
import com.github.krzysiek944.mscrole.MSCROLE;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
public class MessageManager {
|
||||
|
||||
private final MSCROLE plugin;
|
||||
private FileConfiguration messageConfig;
|
||||
|
||||
public MessageManager(MSCROLE plugin) {
|
||||
this.plugin = plugin;
|
||||
setupMessages();
|
||||
}
|
||||
|
||||
private void setupMessages() {
|
||||
File messageFile = new File(plugin.getDataFolder(), "message.yml");
|
||||
if (!messageFile.exists()) {
|
||||
plugin.saveResource("message.yml", false);
|
||||
}
|
||||
messageConfig = YamlConfiguration.loadConfiguration(messageFile);
|
||||
}
|
||||
|
||||
public String getMessage(String path) {
|
||||
return ChatColor.translateAlternateColorCodes('&', messageConfig.getString(path, "&cMessage not found: " + path));
|
||||
}
|
||||
|
||||
public void reloadMessages() {
|
||||
File messageFile = new File(plugin.getDataFolder(), "message.yml");
|
||||
messageConfig = YamlConfiguration.loadConfiguration(messageFile);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package com.github.krzysiek944.mscrole.utils;
|
||||
|
||||
import com.github.krzysiek944.mscrole.MSCROLE;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
public class ShopDataManager {
|
||||
|
||||
private final MSCROLE plugin = MSCROLE.getInstance();
|
||||
private FileConfiguration shopConfig = null;
|
||||
private File configFile = null;
|
||||
|
||||
public void reloadConfig() {
|
||||
if (configFile == null) {
|
||||
configFile = new File(plugin.getDataFolder(), "shop.yml");
|
||||
}
|
||||
shopConfig = YamlConfiguration.loadConfiguration(configFile);
|
||||
}
|
||||
|
||||
public FileConfiguration getConfig() {
|
||||
if (shopConfig == null) {
|
||||
reloadConfig();
|
||||
}
|
||||
return shopConfig;
|
||||
}
|
||||
|
||||
public void saveConfig() {
|
||||
if (shopConfig == null || configFile == null) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
getConfig().save(configFile);
|
||||
} catch (IOException e) {
|
||||
plugin.getLogger().severe("Could not save config to " + configFile);
|
||||
}
|
||||
}
|
||||
|
||||
public void saveDefaultConfig() {
|
||||
if (configFile == null) {
|
||||
configFile = new File(plugin.getDataFolder(), "shop.yml");
|
||||
}
|
||||
if (!configFile.exists()) {
|
||||
plugin.saveResource("shop.yml", false);
|
||||
}
|
||||
}
|
||||
}
|
||||
17
src/main/resources/config.yml
Normal file
17
src/main/resources/config.yml
Normal file
@@ -0,0 +1,17 @@
|
||||
# ================================
|
||||
# Konfiguracja MSCROLE v1.2
|
||||
# ================================
|
||||
|
||||
# Prefix wiadomości
|
||||
prefix: "&6[MSCROLE] &7"
|
||||
|
||||
# Nazwa waluty
|
||||
currency-name: "MSCROLE"
|
||||
|
||||
# Startowa ilość waluty dla nowych graczy
|
||||
starting-balance: 1000
|
||||
|
||||
# Uprawnienia
|
||||
permissions:
|
||||
mscrole: "mscrole.command.mscrole"
|
||||
mscroleadmin: "mscrole.command.mscroleadmin"
|
||||
0
src/main/resources/data.yml
Normal file
0
src/main/resources/data.yml
Normal file
66
src/main/resources/message.yml
Normal file
66
src/main/resources/message.yml
Normal file
@@ -0,0 +1,66 @@
|
||||
# {player} - nazwa gracza
|
||||
# {amount} - ilość waluty
|
||||
# {sender} - nazwa nadawcy
|
||||
# {receiver} - nazwa odbiorcy
|
||||
# {usage} - użycie komendy
|
||||
# {material} - nazwa materiału
|
||||
# {slot} - numer slotu
|
||||
# {price} - cena przedmiotu
|
||||
|
||||
only-player: "&cTa komenda może być użyta tylko przez gracza."
|
||||
no-permission: "&cNie masz uprawnień do tego."
|
||||
unknown-command: "&cNieznana komenda. Użyj /mscroll aby zobaczyć pomoc."
|
||||
invalid-usage: "&cNieprawidłowe użycie. Użycie: {usage}"
|
||||
player-not-found: "&cGracz nie znaleziony."
|
||||
cannot-send-to-self: "&cNie możesz wysłać pieniędzy samemu sobie."
|
||||
invalid-amount: "&cNieprawidłowa ilość."
|
||||
amount-must-be-positive: "&cIlość musi być większa od 0."
|
||||
not-enough-currency: "&cNie masz wystarczająco waluty. Posiadasz: {amount}"
|
||||
currency-sent: "&aWysłałeś {amount} do {receiver}."
|
||||
currency-received: "&aOtrzymałeś {amount} od {sender}."
|
||||
currency-check: "&aPosiadasz {amount} waluty."
|
||||
currency-given: "&aDano {amount} do {receiver}."
|
||||
currency-received-from-admin: "&aOtrzymałeś {amount} od administratora."
|
||||
currency-taken: "&aZabrano {amount} od {player}."
|
||||
currency-taken-by-admin: "&cAdministrator zabrał Ci {amount}."
|
||||
balance-set: "&aBalans gracza {player} został ustawiony na {amount}."
|
||||
material-not-found: "&cMateriał {material} nie znaleziony."
|
||||
invalid-slot: "&cSlot musi być pomiędzy 10 a 43."
|
||||
item-added: "&aPrzedmiot został dodany do slotu {slot} za {price}."
|
||||
item-removed: "&aPrzedmiot został usunięty ze slotu {slot}."
|
||||
shop-empty: "&cSklep jest pusty."
|
||||
|
||||
help-header: "&6&l════════ MSCROLE ════════"
|
||||
help-balance: "&e/mscroll balans &7- Sprawdź swój stan konta"
|
||||
help-send: "&e/mscroll wyslij <gracz> <ilość> &7- Wyślij walutę"
|
||||
help-shop: "&e/mscroll sklep &7- Otwórz sklep"
|
||||
help-admin: "&e/mscroll admin &7- Panel administratora"
|
||||
help-footer: "&6&l═══════════════════════"
|
||||
|
||||
admin-help-header: "&c&l════ Panel Administratora ════"
|
||||
admin-help-add: "&e/mscrolladmin add <slot> <price> <item> <amount> <command1;command2;...>
|
||||
&7- Add item with multiple commands"
|
||||
admin-help-remove: "&e/mscrolladmin remove <slot> &7- Usuń przedmiot"
|
||||
admin-help-give: "&e/mscrolladmin give <gracz> <ilość> &7- Daj walutę"
|
||||
admin-help-take: "&e/mscrolladmin take <gracz> <ilość> &7- Zabierz walutę"
|
||||
admin-help-set: "&e/mscrolladmin set <gracz> <ilość> &7- Ustaw balans"
|
||||
admin-help-list: "&e/mscrolladmin list &7- Lista przedmiotów"
|
||||
admin-help-footer: "&c&l══════════════════"
|
||||
|
||||
list-items-header: "&6&l════ Lista Przedmiotów w Sklepie ════"
|
||||
list-items-footer: "&6&l═══════════════════════════════"
|
||||
list-items-format: "&7[Slot {slot}] &e{item} &7- &a{price} {currency}"
|
||||
|
||||
item-purchased: "&aZakupiono przedmiot za &e{price} {currency}!"
|
||||
not-enough-currency-shop: "&cNie masz wystarczająco {currency}! Potrzebujesz: &e{price}"
|
||||
|
||||
admin-add-item-help-header: "&aAby dodać przedmiot do sklepu, użyj:"
|
||||
admin-add-item-help-command: "&e/mscrolladmin add <slot> <cena> <przedmiot> [ilość]"
|
||||
admin-add-item-help-example-command: "&7Przykład: &e/mscrolladmin add 20 500 diamond 1"
|
||||
admin-add-item-help-example-description: "&7To doda diament do slotu 20 za 500 MSCROLE"
|
||||
|
||||
admin-give-currency-help-header: "&aAby dać walutę graczowi, użyj:"
|
||||
admin-give-currency-help-command: "&e/mscrolladmin give <gracz> <ilość>"
|
||||
|
||||
admin-take-currency-help-header: "&aAby zabrać walutę graczowi, użyj:"
|
||||
admin-take-currency-help-command: "&e/mscrolladmin take <gracz> <ilość>"
|
||||
16
src/main/resources/plugin.yml
Normal file
16
src/main/resources/plugin.yml
Normal file
@@ -0,0 +1,16 @@
|
||||
name: MSCROLE
|
||||
version: 1.2
|
||||
main: com.github.krzysiek944.mscrole.MSCROLE
|
||||
api-version: '1.21'
|
||||
author: Gemini
|
||||
commands:
|
||||
mscroll:
|
||||
description: Główna komenda pluginu MSCROLE.
|
||||
aliases: [msc]
|
||||
mscrolladmin:
|
||||
description: Komendy administracyjne dla MSCROLE.
|
||||
permission: mscrole.admin
|
||||
permissions:
|
||||
mscrole.admin:
|
||||
description: Dostęp do komend administracyjnych MSCROLE.
|
||||
default: op
|
||||
35
src/main/resources/shop.yml
Normal file
35
src/main/resources/shop.yml
Normal file
@@ -0,0 +1,35 @@
|
||||
items:
|
||||
'20':
|
||||
price: 500
|
||||
commands:
|
||||
- 'give %player% diamond 1'
|
||||
- 'eco give %player% 100'
|
||||
item:
|
||||
material: DIAMOND
|
||||
amount: 1
|
||||
name: '&bDiament'
|
||||
lore:
|
||||
- '&7Bardzo rzadki diament.'
|
||||
- '&7Kup go już teraz!'
|
||||
'22':
|
||||
price: 100
|
||||
commands:
|
||||
- 'give %player% iron_ingot 16'
|
||||
item:
|
||||
==: org.bukkit.inventory.ItemStack
|
||||
v: 3901
|
||||
type: IRON_INGOT
|
||||
amount: 16
|
||||
name: '&fSztabka Żelaza'
|
||||
lore:
|
||||
- '&7Podstawowy materiał do craftingu.'
|
||||
- '&7Przydatny w wielu przepisach.'
|
||||
'24':
|
||||
price: 1000
|
||||
commands:
|
||||
- 'give %player% netherite_ingot 1'
|
||||
item:
|
||||
==: org.bukkit.inventory.ItemStack
|
||||
v: 3901
|
||||
type: NETHERITE_INGOT
|
||||
amount: 1
|
||||
BIN
target/MSCROLE-1.2.jar
Normal file
BIN
target/MSCROLE-1.2.jar
Normal file
Binary file not shown.
BIN
target/classes/com/github/krzysiek944/mscrole/MSCROLE.class
Normal file
BIN
target/classes/com/github/krzysiek944/mscrole/MSCROLE.class
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
target/classes/com/github/krzysiek944/mscrole/gui/AdminGUI.class
Normal file
BIN
target/classes/com/github/krzysiek944/mscrole/gui/AdminGUI.class
Normal file
Binary file not shown.
BIN
target/classes/com/github/krzysiek944/mscrole/gui/ShopGUI.class
Normal file
BIN
target/classes/com/github/krzysiek944/mscrole/gui/ShopGUI.class
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
17
target/classes/config.yml
Normal file
17
target/classes/config.yml
Normal file
@@ -0,0 +1,17 @@
|
||||
# ================================
|
||||
# Konfiguracja MSCROLE v1.2
|
||||
# ================================
|
||||
|
||||
# Prefix wiadomości
|
||||
prefix: "&6[MSCROLE] &7"
|
||||
|
||||
# Nazwa waluty
|
||||
currency-name: "MSCROLE"
|
||||
|
||||
# Startowa ilość waluty dla nowych graczy
|
||||
starting-balance: 1000
|
||||
|
||||
# Uprawnienia
|
||||
permissions:
|
||||
mscrole: "mscrole.command.mscrole"
|
||||
mscroleadmin: "mscrole.command.mscroleadmin"
|
||||
0
target/classes/data.yml
Normal file
0
target/classes/data.yml
Normal file
66
target/classes/message.yml
Normal file
66
target/classes/message.yml
Normal file
@@ -0,0 +1,66 @@
|
||||
# {player} - nazwa gracza
|
||||
# {amount} - ilość waluty
|
||||
# {sender} - nazwa nadawcy
|
||||
# {receiver} - nazwa odbiorcy
|
||||
# {usage} - użycie komendy
|
||||
# {material} - nazwa materiału
|
||||
# {slot} - numer slotu
|
||||
# {price} - cena przedmiotu
|
||||
|
||||
only-player: "&cTa komenda może być użyta tylko przez gracza."
|
||||
no-permission: "&cNie masz uprawnień do tego."
|
||||
unknown-command: "&cNieznana komenda. Użyj /mscroll aby zobaczyć pomoc."
|
||||
invalid-usage: "&cNieprawidłowe użycie. Użycie: {usage}"
|
||||
player-not-found: "&cGracz nie znaleziony."
|
||||
cannot-send-to-self: "&cNie możesz wysłać pieniędzy samemu sobie."
|
||||
invalid-amount: "&cNieprawidłowa ilość."
|
||||
amount-must-be-positive: "&cIlość musi być większa od 0."
|
||||
not-enough-currency: "&cNie masz wystarczająco waluty. Posiadasz: {amount}"
|
||||
currency-sent: "&aWysłałeś {amount} do {receiver}."
|
||||
currency-received: "&aOtrzymałeś {amount} od {sender}."
|
||||
currency-check: "&aPosiadasz {amount} waluty."
|
||||
currency-given: "&aDano {amount} do {receiver}."
|
||||
currency-received-from-admin: "&aOtrzymałeś {amount} od administratora."
|
||||
currency-taken: "&aZabrano {amount} od {player}."
|
||||
currency-taken-by-admin: "&cAdministrator zabrał Ci {amount}."
|
||||
balance-set: "&aBalans gracza {player} został ustawiony na {amount}."
|
||||
material-not-found: "&cMateriał {material} nie znaleziony."
|
||||
invalid-slot: "&cSlot musi być pomiędzy 10 a 43."
|
||||
item-added: "&aPrzedmiot został dodany do slotu {slot} za {price}."
|
||||
item-removed: "&aPrzedmiot został usunięty ze slotu {slot}."
|
||||
shop-empty: "&cSklep jest pusty."
|
||||
|
||||
help-header: "&6&l════════ MSCROLE ════════"
|
||||
help-balance: "&e/mscroll balans &7- Sprawdź swój stan konta"
|
||||
help-send: "&e/mscroll wyslij <gracz> <ilość> &7- Wyślij walutę"
|
||||
help-shop: "&e/mscroll sklep &7- Otwórz sklep"
|
||||
help-admin: "&e/mscroll admin &7- Panel administratora"
|
||||
help-footer: "&6&l═══════════════════════"
|
||||
|
||||
admin-help-header: "&c&l════ Panel Administratora ════"
|
||||
admin-help-add: "&e/mscrolladmin add <slot> <price> <item> <amount> <command1;command2;...>
|
||||
&7- Add item with multiple commands"
|
||||
admin-help-remove: "&e/mscrolladmin remove <slot> &7- Usuń przedmiot"
|
||||
admin-help-give: "&e/mscrolladmin give <gracz> <ilość> &7- Daj walutę"
|
||||
admin-help-take: "&e/mscrolladmin take <gracz> <ilość> &7- Zabierz walutę"
|
||||
admin-help-set: "&e/mscrolladmin set <gracz> <ilość> &7- Ustaw balans"
|
||||
admin-help-list: "&e/mscrolladmin list &7- Lista przedmiotów"
|
||||
admin-help-footer: "&c&l══════════════════"
|
||||
|
||||
list-items-header: "&6&l════ Lista Przedmiotów w Sklepie ════"
|
||||
list-items-footer: "&6&l═══════════════════════════════"
|
||||
list-items-format: "&7[Slot {slot}] &e{item} &7- &a{price} {currency}"
|
||||
|
||||
item-purchased: "&aZakupiono przedmiot za &e{price} {currency}!"
|
||||
not-enough-currency-shop: "&cNie masz wystarczająco {currency}! Potrzebujesz: &e{price}"
|
||||
|
||||
admin-add-item-help-header: "&aAby dodać przedmiot do sklepu, użyj:"
|
||||
admin-add-item-help-command: "&e/mscrolladmin add <slot> <cena> <przedmiot> [ilość]"
|
||||
admin-add-item-help-example-command: "&7Przykład: &e/mscrolladmin add 20 500 diamond 1"
|
||||
admin-add-item-help-example-description: "&7To doda diament do slotu 20 za 500 MSCROLE"
|
||||
|
||||
admin-give-currency-help-header: "&aAby dać walutę graczowi, użyj:"
|
||||
admin-give-currency-help-command: "&e/mscrolladmin give <gracz> <ilość>"
|
||||
|
||||
admin-take-currency-help-header: "&aAby zabrać walutę graczowi, użyj:"
|
||||
admin-take-currency-help-command: "&e/mscrolladmin take <gracz> <ilość>"
|
||||
16
target/classes/plugin.yml
Normal file
16
target/classes/plugin.yml
Normal file
@@ -0,0 +1,16 @@
|
||||
name: MSCROLE
|
||||
version: 1.2
|
||||
main: com.github.krzysiek944.mscrole.MSCROLE
|
||||
api-version: '1.21'
|
||||
author: Gemini
|
||||
commands:
|
||||
mscroll:
|
||||
description: Główna komenda pluginu MSCROLE.
|
||||
aliases: [msc]
|
||||
mscrolladmin:
|
||||
description: Komendy administracyjne dla MSCROLE.
|
||||
permission: mscrole.admin
|
||||
permissions:
|
||||
mscrole.admin:
|
||||
description: Dostęp do komend administracyjnych MSCROLE.
|
||||
default: op
|
||||
35
target/classes/shop.yml
Normal file
35
target/classes/shop.yml
Normal file
@@ -0,0 +1,35 @@
|
||||
items:
|
||||
'20':
|
||||
price: 500
|
||||
commands:
|
||||
- 'give %player% diamond 1'
|
||||
- 'eco give %player% 100'
|
||||
item:
|
||||
material: DIAMOND
|
||||
amount: 1
|
||||
name: '&bDiament'
|
||||
lore:
|
||||
- '&7Bardzo rzadki diament.'
|
||||
- '&7Kup go już teraz!'
|
||||
'22':
|
||||
price: 100
|
||||
commands:
|
||||
- 'give %player% iron_ingot 16'
|
||||
item:
|
||||
==: org.bukkit.inventory.ItemStack
|
||||
v: 3901
|
||||
type: IRON_INGOT
|
||||
amount: 16
|
||||
name: '&fSztabka Żelaza'
|
||||
lore:
|
||||
- '&7Podstawowy materiał do craftingu.'
|
||||
- '&7Przydatny w wielu przepisach.'
|
||||
'24':
|
||||
price: 1000
|
||||
commands:
|
||||
- 'give %player% netherite_ingot 1'
|
||||
item:
|
||||
==: org.bukkit.inventory.ItemStack
|
||||
v: 3901
|
||||
type: NETHERITE_INGOT
|
||||
amount: 1
|
||||
3
target/maven-archiver/pom.properties
Normal file
3
target/maven-archiver/pom.properties
Normal file
@@ -0,0 +1,3 @@
|
||||
artifactId=MSCROLE
|
||||
groupId=com.github.krzysiek944
|
||||
version=1.2
|
||||
@@ -0,0 +1,13 @@
|
||||
com\github\krzysiek944\mscrole\services\CurrencyManager.class
|
||||
com\github\krzysiek944\mscrole\MSCROLE.class
|
||||
com\github\krzysiek944\mscrole\utils\MessageManager.class
|
||||
com\github\krzysiek944\mscrole\utils\DataManager.class
|
||||
com\github\krzysiek944\mscrole\utils\ShopDataManager.class
|
||||
com\github\krzysiek944\mscrole\gui\ShopGUI.class
|
||||
com\github\krzysiek944\mscrole\listeners\GuiListener$1.class
|
||||
com\github\krzysiek944\mscrole\gui\AdminGUI.class
|
||||
com\github\krzysiek944\mscrole\commands\MscroleAdminCommand.class
|
||||
com\github\krzysiek944\mscrole\commands\MscroleCommand.class
|
||||
com\github\krzysiek944\mscrole\listeners\PlayerJoinListener.class
|
||||
com\github\krzysiek944\mscrole\listeners\GuiListener.class
|
||||
com\github\krzysiek944\mscrole\services\ShopManager.class
|
||||
@@ -0,0 +1,12 @@
|
||||
C:\Users\Krfcm\Documents\visual studio\skript — kopia\src\main\java\com\github\krzysiek944\mscrole\commands\MscroleAdminCommand.java
|
||||
C:\Users\Krfcm\Documents\visual studio\skript — kopia\src\main\java\com\github\krzysiek944\mscrole\commands\MscroleCommand.java
|
||||
C:\Users\Krfcm\Documents\visual studio\skript — kopia\src\main\java\com\github\krzysiek944\mscrole\gui\ShopGUI.java
|
||||
C:\Users\Krfcm\Documents\visual studio\skript — kopia\src\main\java\com\github\krzysiek944\mscrole\utils\DataManager.java
|
||||
C:\Users\Krfcm\Documents\visual studio\skript — kopia\src\main\java\com\github\krzysiek944\mscrole\listeners\PlayerJoinListener.java
|
||||
C:\Users\Krfcm\Documents\visual studio\skript — kopia\src\main\java\com\github\krzysiek944\mscrole\listeners\GuiListener.java
|
||||
C:\Users\Krfcm\Documents\visual studio\skript — kopia\src\main\java\com\github\krzysiek944\mscrole\utils\MessageManager.java
|
||||
C:\Users\Krfcm\Documents\visual studio\skript — kopia\src\main\java\com\github\krzysiek944\mscrole\MSCROLE.java
|
||||
C:\Users\Krfcm\Documents\visual studio\skript — kopia\src\main\java\com\github\krzysiek944\mscrole\utils\ShopDataManager.java
|
||||
C:\Users\Krfcm\Documents\visual studio\skript — kopia\src\main\java\com\github\krzysiek944\mscrole\services\ShopManager.java
|
||||
C:\Users\Krfcm\Documents\visual studio\skript — kopia\src\main\java\com\github\krzysiek944\mscrole\services\CurrencyManager.java
|
||||
C:\Users\Krfcm\Documents\visual studio\skript — kopia\src\main\java\com\github\krzysiek944\mscrole\gui\AdminGUI.java
|
||||
BIN
target/original-MSCROLE-1.2.jar
Normal file
BIN
target/original-MSCROLE-1.2.jar
Normal file
Binary file not shown.
Reference in New Issue
Block a user