mirror of
https://github.com/amalthea-mc/Ore-Market.git
synced 2024-11-09 12:11:08 +00:00
Delete src/main directory
This commit is contained in:
parent
6544b5ddba
commit
8294492cf0
@ -1,17 +0,0 @@
|
|||||||
package com.olliejw.oremarket.Commands;
|
|
||||||
|
|
||||||
import com.olliejw.oremarket.OreMarket;
|
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
import org.bukkit.command.Command;
|
|
||||||
import org.bukkit.command.CommandExecutor;
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
|
|
||||||
public class Reload implements CommandExecutor {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
|
||||||
OreMarket.main().reloadConfig();
|
|
||||||
sender.sendMessage(ChatColor.GREEN + "Reloaded successfully");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,52 +0,0 @@
|
|||||||
package com.olliejw.oremarket;
|
|
||||||
|
|
||||||
import com.olliejw.oremarket.Commands.Reload;
|
|
||||||
import com.olliejw.oremarket.Utils.MarketGUI;
|
|
||||||
import net.milkbowl.vault.economy.Economy;
|
|
||||||
import org.bukkit.plugin.RegisteredServiceProvider;
|
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
|
||||||
|
|
||||||
import java.util.logging.Logger;
|
|
||||||
|
|
||||||
public final class OreMarket extends JavaPlugin {
|
|
||||||
|
|
||||||
private static OreMarket instance;
|
|
||||||
private static final Logger log = Logger.getLogger("Minecraft");
|
|
||||||
private static Economy econ = null;
|
|
||||||
|
|
||||||
public void onEnable() {
|
|
||||||
instance = this;
|
|
||||||
|
|
||||||
saveDefaultConfig();
|
|
||||||
this.getServer().getPluginManager().registerEvents(new MarketGUI(), this);
|
|
||||||
this.getCommand("openmarket").setExecutor(new MarketGUI());
|
|
||||||
this.getCommand("om-reload").setExecutor(new Reload());
|
|
||||||
|
|
||||||
if (!setupEconomy() ) {
|
|
||||||
log.severe(String.format("[%s] - Disabled due to no Vault dependency found!", getDescription().getName()));
|
|
||||||
getServer().getPluginManager().disablePlugin(this);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static OreMarket main(){
|
|
||||||
return instance;
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean setupEconomy() {
|
|
||||||
if (getServer().getPluginManager().getPlugin("Vault") == null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
RegisteredServiceProvider<Economy> rsp = getServer().getServicesManager().getRegistration(Economy.class);
|
|
||||||
if (rsp == null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
econ = rsp.getProvider();
|
|
||||||
return econ != null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Economy getEconomy() {
|
|
||||||
return econ;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,70 +0,0 @@
|
|||||||
package com.olliejw.oremarket.Utils;
|
|
||||||
|
|
||||||
import com.olliejw.oremarket.OreMarket;
|
|
||||||
import net.milkbowl.vault.economy.EconomyResponse;
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
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.event.EventHandler;
|
|
||||||
import org.bukkit.event.Listener;
|
|
||||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
|
||||||
import org.bukkit.event.inventory.InventoryDragEvent;
|
|
||||||
import org.bukkit.inventory.Inventory;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
|
||||||
import org.bukkit.inventory.meta.ItemMeta;
|
|
||||||
|
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
public class MarketGUI implements Listener, CommandExecutor {
|
|
||||||
Inventory inv = Bukkit.createInventory(null, 27, "OreMarket Coming soon!");
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
|
||||||
if (command.getName().equalsIgnoreCase("openmarket")) {
|
|
||||||
Player player = (Player) sender;
|
|
||||||
|
|
||||||
for (String key : OreMarket.main().getConfig().getConfigurationSection("items").getKeys(false)) {
|
|
||||||
ConfigurationSection keySection = OreMarket.main().getConfig().getConfigurationSection("items").getConfigurationSection(key);
|
|
||||||
assert keySection != null;
|
|
||||||
|
|
||||||
ItemStack item = new ItemStack(Material.matchMaterial(keySection.getString("item")));
|
|
||||||
ItemMeta meta = item.getItemMeta();
|
|
||||||
meta.setDisplayName(ChatColor.translateAlternateColorCodes('&', keySection.getString("name")));
|
|
||||||
item.setItemMeta(meta);
|
|
||||||
|
|
||||||
inv.setItem(Integer.parseInt(key), item);
|
|
||||||
player.openInventory(inv);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void dragEvent (InventoryDragEvent event) {
|
|
||||||
if (event.getInventory() == inv) {
|
|
||||||
event.setCancelled(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@EventHandler
|
|
||||||
public void clickEvent (InventoryClickEvent event) {
|
|
||||||
Player player = (Player) event.getWhoClicked();
|
|
||||||
|
|
||||||
int pay = OreMarket.main().getConfig().getInt("items." + event.getSlot() + ".value");
|
|
||||||
EconomyResponse r = OreMarket.getEconomy().depositPlayer(event.getWhoClicked().getName(), pay);
|
|
||||||
|
|
||||||
if(r.transactionSuccess()) {
|
|
||||||
event.getWhoClicked().sendMessage(String.format("You were given %s and now have %s", OreMarket.getEconomy().format(r.amount), OreMarket.getEconomy().format(r.balance)));
|
|
||||||
} else {
|
|
||||||
event.getWhoClicked().sendMessage(String.format("An error occured: %s", r.errorMessage));
|
|
||||||
}
|
|
||||||
|
|
||||||
event.setCancelled(true);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,29 +0,0 @@
|
|||||||
# Cost = Initial cost of ore. (0% change)
|
|
||||||
# Value = Current cost of ore. (With % change)
|
|
||||||
# When adding a new ore make the cost and value to same
|
|
||||||
|
|
||||||
items:
|
|
||||||
0:
|
|
||||||
item: DIAMOND
|
|
||||||
name: '&bDiamond Ore'
|
|
||||||
lore:
|
|
||||||
- '&a$1000'
|
|
||||||
cost: 1000
|
|
||||||
value: 1000
|
|
||||||
|
|
||||||
1:
|
|
||||||
item: GOLD_INGOT
|
|
||||||
name: '&6Gold Ingot'
|
|
||||||
lore:
|
|
||||||
- '&a$500'
|
|
||||||
cost: 500
|
|
||||||
value: 500
|
|
||||||
|
|
||||||
2:
|
|
||||||
item: IRON_INGOT
|
|
||||||
name: '&7Iron Ore'
|
|
||||||
lore:
|
|
||||||
- '&a$250'
|
|
||||||
cost: 250
|
|
||||||
value: 250
|
|
||||||
|
|
@ -1,15 +0,0 @@
|
|||||||
name: OreMarket
|
|
||||||
version: ${project.version}
|
|
||||||
main: com.olliejw.oremarket.OreMarket
|
|
||||||
api-version: 1.16
|
|
||||||
depend: [ Vault ]
|
|
||||||
authors: [ OllieJW ]
|
|
||||||
description: Realistic stock market for ores
|
|
||||||
|
|
||||||
commands:
|
|
||||||
openmarket:
|
|
||||||
description: Opens OreMarket GUI
|
|
||||||
usage: /<command>
|
|
||||||
om-reload:
|
|
||||||
description: Reloads OreMarket
|
|
||||||
usage: /<command>
|
|
Loading…
Reference in New Issue
Block a user