测试版

This commit is contained in:
tianyu 2024-07-24 05:40:40 +08:00
commit 3b036e78b1
24 changed files with 2320 additions and 0 deletions

View File

@ -0,0 +1,40 @@
package me.demon.market.Event;
import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
import org.bukkit.inventory.ItemStack;
public class DyhMarketEvent extends Event {
private static HandlerList handlers = new HandlerList();
// 获取玩家
private Player player;
// 获取上架价格
private int Money;
// 获取上架拍卖品物品
private ItemStack items;
@Override
public HandlerList getHandlers() {
return handlers;
}
public static HandlerList getHandlerList() {
return handlers;
}
public DyhMarketEvent(Player player,int Money,ItemStack items) {
this.player = player;
this.Money = Money;
this.items = items;
}
public Player getPlayer() {
return player;
}
public int getMoney() {
return Money;
}
public ItemStack getItems() {
return items;
}
}

View File

@ -0,0 +1,40 @@
package me.demon.market.Event;
import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
import org.bukkit.inventory.ItemStack;
public class MarketTradeEvent extends Event {
private static HandlerList handlers = new HandlerList();
// 获取玩家
private Player player;
// 获取买下商品价格
private int Money;
// 获取买下商品物品
private ItemStack items;
@Override
public HandlerList getHandlers() {
return handlers;
}
public static HandlerList getHandlerList() {
return handlers;
}
public MarketTradeEvent(Player player, int Money, ItemStack items) {
this.player = player;
this.Money = Money;
this.items = items;
}
public Player getPlayer() {
return player;
}
public int getMoney() {
return Money;
}
public ItemStack getItems() {
return items;
}
}

View File

@ -0,0 +1,123 @@
package me.demon.market.Gui;
import me.Demon.DemonPlugin.DemonAPI;
import me.demon.market.MGui.Market_Default;
import me.demon.market.Util.uItems;
import me.demon.market.main;
import org.bukkit.Bukkit;
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.event.inventory.InventoryType;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemFlag;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
public class AdminGui implements Listener {
@EventHandler
public void onclick(InventoryClickEvent e) {
Player p = (Player) e.getWhoClicked();
if (e.getInventory().getType() == InventoryType.CHEST && e.getView().getTitle().contains("§c§l拼刀刀§7[§a§l管理商品§7]")) {
e.setCancelled(true);
if (e.getRawSlot() == 33) {
Market_Default.OpenGui(p, 1);
p.playSound(p.getLocation(), Sound.BLOCK_LEVER_CLICK, 1, 2);
}
if (e.getRawSlot() >= 0 && e.getRawSlot() < 27) {
p.closeInventory();
if (!DemonAPI.itemIsNull(e.getCurrentItem())) {
ItemStack item = e.getCurrentItem();
ItemMeta meta = item.getItemMeta();
String itemName = meta.getDisplayName();
String key = itemName.split("#")[1].replace("§7)", "");
if (main.DataG.getString("Items." + key + ".Item") != null) {
ItemStack items = main.DataG.getItemStack("Items." + key + ".Item");
p.getInventory().addItem(items);
main.DataG.set("Items." + key, null);
main.saveDataStatsConfig();
main.KeyList.remove(key);
p.sendMessage(main.prefix + "成功下架该商品!");
p.playSound(p.getLocation(), Sound.BLOCK_LEVER_CLICK, 1, 2);
} else {
p.closeInventory();
p.sendMessage(main.prefix + "很抱歉,其他玩家抢先一步拍走了这个珍贵的商品!");
p.playSound(p.getLocation(), Sound.BLOCK_LEVER_CLICK, 1, 2);
}
}
}
}
}
public static void OpenGui(Player p) {
Inventory inv = Bukkit.createInventory(null, 36, "§c§l拼刀刀§7[§a§l管理商品§7]");
for (int i = 27; i < 36; i++) {
inv.setItem(i, uItems.glass("§7[[§a▧§c▧§a▧§7]]"));
}
inv.setItem(29, 操作指引());
inv.setItem(33, uItems.返回上一页());
for (int i = 0; i < main.KeyList.size(); i++) {
String key = main.KeyList.get(i);
String str = "Items." + key + ".";
String Seller = main.DataG.getString(str + "Seller");
if (Seller.equalsIgnoreCase(p.getName())) {
int Money = main.DataG.getInt(str + "Money");
String ShelfTime = main.DataG.getString(str + "ShelfTime");
ItemStack items = main.DataG.getItemStack(str + "Item");
inv.addItem(ShopItemsEdit(Seller, items, key, Money, ShelfTime));
}
}
p.openInventory(inv);
}
public static ItemStack ShopItemsEdit(String playName, ItemStack items, String Key, int Price, String ShelfTime) {
String money = "§6$" + Price + "金币";
ItemStack item = items.clone();
ItemMeta meta = item.getItemMeta();
assert meta != null;
if (!DemonAPI.itemIsName(item)) {
meta.setDisplayName(item.getItemMeta().getDisplayName() + "§7(§r§f#" + Key + "§7)");
} else {
String itemName = uItems.getItemName(item);
meta.setDisplayName(itemName + "§7(§r§f#" + Key + "§7)");
}
List<String> lore = new ArrayList<>();
if (!DemonAPI.itemIsLore(item)) {
lore.addAll(Objects.requireNonNull(Objects.requireNonNull(items.getItemMeta()).getLore()));
}
lore.add("§7-------------------------");
lore.add("§a§l★§7出售价格: " + money);
lore.add("§a§l★§7出售数量: §f" + item.getAmount() + "");
lore.add("§a§l★§7物品主人: §f" + playName);
lore.add("§a§l★§7下价时间: §f" + ShelfTime);
lore.add(" ");
lore.add("§e§l★§7左键点击下架此商品");
meta.setLore(lore);
meta.addItemFlags(ItemFlag.HIDE_ATTRIBUTES);
meta.addItemFlags(ItemFlag.HIDE_UNBREAKABLE);
meta.addItemFlags(ItemFlag.HIDE_POTION_EFFECTS);
item.setItemMeta(meta);
return item;
}
public static ItemStack 操作指引() {
ItemStack item = new ItemStack(Material.BOOK_AND_QUILL);
ItemMeta meta = item.getItemMeta();
meta.setDisplayName("§8« §e管理指南 §8»");
List<String> lore = new ArrayList<>();
lore.add("§a§l★ §7点击上方的商品 §a§l★");
lore.add("§a§l★ §7下架后返回背包 §a§l★");
meta.setLore(lore);
item.setItemMeta(meta);
return item;
}
}

View File

@ -0,0 +1,50 @@
package me.demon.market.Gui;
import me.Demon.DemonPlugin.DemonAPI;
import me.demon.market.main;
import org.bukkit.Bukkit;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.inventory.InventoryCloseEvent;
import org.bukkit.event.inventory.InventoryType;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import java.util.ArrayList;
import java.util.List;
public class CategoryCreate implements Listener {
@EventHandler
public void onclose(InventoryCloseEvent e){
Player p = (Player) e.getPlayer();
if(e.getInventory().getType() == InventoryType.CHEST && e.getView().getTitle().contains("§c§l贸易市场§7[§a§l分类§7] §8#")){
FileConfiguration yml = main.CategoryG;
String type = e.getView().getTitle().replace("§c§l贸易市场§7[§a§l分类§7] §8#","");
List<String> list = yml.getStringList(type);
List<String> stringList = new ArrayList<>();
int a = 0;
for (int i = 0;i < e.getInventory().getSize();i++){
ItemStack item = e.getInventory().getItem(i);
if(!DemonAPI.itemIsNull(item)){
String type_name = item.getType().name();
if(!list.contains(type_name) && !stringList.contains(type_name)){
stringList.add(type_name);
a++;
}
}
}
stringList.addAll(list);
yml.set(type,stringList);
main.saveCategoryConfig();
p.sendMessage(main.prefix+"成功存入§e["+a+"件]§f物品至分类库");
}
}
public static void OpenItemsGui(Player p,String type){
Inventory inv = Bukkit.createInventory(null,54,"§c§l贸易市场§7[§a§l分类§7] §8#"+type);
p.openInventory(inv);
}
}

View File

@ -0,0 +1,108 @@
package me.demon.market.Gui;
import me.Demon.DemonPlugin.DemonAPI;
import me.demon.market.MGui.*;
import me.demon.market.Util.uItems;
import org.bukkit.Bukkit;
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.event.inventory.InventoryType;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemFlag;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import java.util.ArrayList;
import java.util.List;
public class ItemTypeGui implements Listener {
public static String inv_Title = "§l拼刀刀 §r| 请选择你要查看的分类";
@EventHandler
public void onclick(InventoryClickEvent e) {
Player p = (Player) e.getWhoClicked();
if (e.getInventory().getType() == InventoryType.CHEST && inv_Title.equalsIgnoreCase(e.getView().getTitle())) {
e.setCancelled(true);
if (e.getRawSlot() >= 0 && e.getRawSlot() < 45) {
ItemStack item = e.getCurrentItem();
if (!DemonAPI.itemIsNull(item)) {
p.playSound(p.getLocation(), Sound.BLOCK_LEVER_CLICK, 1, 2);
if (item.getTypeId() == 160) {
Market_Default.OpenGui(p, 1);
return;
}
if (e.getRawSlot() == 9) {
Market_Default.OpenGui(p, 1);
}
if (e.getRawSlot() == 11) {
Market_武器.OpenGui(p, 1);
}
if (e.getRawSlot() == 13) {
Market_防具.OpenGui(p, 1);
}
if (e.getRawSlot() == 15) {
Market_工具.OpenGui(p, 1);
}
if (e.getRawSlot() == 17) {
Market_食物.OpenGui(p, 1);
}
if (e.getRawSlot() == 27) {
Market_药水.OpenGui(p, 1);
}
if (e.getRawSlot() == 29) {
Market_交通.OpenGui(p, 1);
}
if (e.getRawSlot() == 31) {
Market_红石.OpenGui(p, 1);
}
if (e.getRawSlot() == 33) {
Market_方块.OpenGui(p, 1);
}
if (e.getRawSlot() == 35) {
Market_杂项.OpenGui(p, 1);
}
}
}
}
}
public static void OpenItemsGui(Player p) {
Inventory inv = Bukkit.createInventory(null, 45, inv_Title);
for (int i = 0; i < 9; i++) {
inv.setItem(i, uItems.glass("§7[[§c点击返回§7]]"));
}
for (int i = 36; i < 45; i++) {
inv.setItem(i, uItems.glass("§7[[§c点击返回§7]]"));
}
inv.setItem(9, Show_Item(Material.BRICK, "默认分类"));
inv.setItem(11, Show_Item(Material.GOLD_SWORD, "武器"));
inv.setItem(13, Show_Item(Material.IRON_CHESTPLATE, "防具"));
inv.setItem(15, Show_Item(Material.DIAMOND_AXE, "工具"));
inv.setItem(17, Show_Item(Material.COOKED_BEEF, "食物"));
inv.setItem(27, Show_Item(Material.BREWING_STAND_ITEM, "药水"));
inv.setItem(29, Show_Item(Material.MINECART, "交通"));
inv.setItem(31, Show_Item(Material.REDSTONE_BLOCK, "红石"));
inv.setItem(33, Show_Item(Material.GRASS, "方块"));
inv.setItem(35, Show_Item(Material.LAVA_BUCKET, "杂项"));
p.openInventory(inv);
}
public static ItemStack Show_Item(Material material, String typeName) {
ItemStack item = new ItemStack(material);
ItemMeta meta = item.getItemMeta();
meta.setDisplayName("§e§l" + typeName);
List<String> lore = new ArrayList<>();
lore.add("§a§l★ §7点击选择 §a§l★");
meta.setLore(lore);
meta.addItemFlags(ItemFlag.HIDE_ATTRIBUTES);
meta.addItemFlags(ItemFlag.HIDE_POTION_EFFECTS);
item.setItemMeta(meta);
return item;
}
}

View File

@ -0,0 +1,137 @@
package me.demon.market.MGui;
import me.Demon.DemonPlugin.DemonAPI;
import me.demon.market.Gui.AdminGui;
import me.demon.market.Gui.ItemTypeGui;
import me.demon.market.MarketAPI;
import me.demon.market.Util.uItems;
import me.demon.market.main;
import org.bukkit.Bukkit;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.inventory.ClickType;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.inventory.InventoryType;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import java.util.List;
public class Market_Default implements Listener {
public static String inventory_Title = "§m§r§r§l拼刀刀市场 §r| §4谨防铁砧改名假货! §8#";
@EventHandler
public void onclick(InventoryClickEvent e) {
Player p = (Player) e.getWhoClicked();
if (e.getInventory().getType() == InventoryType.CHEST && e.getView().getTitle().contains(inventory_Title)) {
e.setCancelled(true);
int Pages = Integer.parseInt(e.getView().getTitle().replace(inventory_Title, ""));
if (e.getRawSlot() == 48) {
p.playSound(p.getLocation(), Sound.BLOCK_LEVER_CLICK, 1, 2);
if (Pages >= 2 && Pages <= 10) {
Market_Default.OpenGui(p, Pages - 1);
} else {
p.sendMessage(main.prefix + "§c已经是第一页了");
}
}
if (e.getRawSlot() == 50) {
p.playSound(p.getLocation(), Sound.BLOCK_LEVER_CLICK, 1, 2);
if (Pages >= 1 && Pages <= 9) {
Market_Default.OpenGui(p, Pages + 1);
} else {
p.sendMessage(main.prefix + "§c已经是最后一页了");
}
}
// 查看交易日志
if (e.getRawSlot() == 45) {
p.sendMessage(main.prefix + "§c暂不支持查看日志。");
p.playSound(p.getLocation(), Sound.BLOCK_LEVER_CLICK, 1, 2);
}
// 打开管理商品
if (e.getRawSlot() == 46) {
AdminGui.OpenGui(p);
p.playSound(p.getLocation(), Sound.BLOCK_LEVER_CLICK, 1, 2);
}
// 刷新页面
if (e.getRawSlot() == 49) {
Market_Default.OpenGui(p, Pages);
p.playSound(p.getLocation(), Sound.BLOCK_LEVER_CLICK, 1, 2);
}
// 打开分类
if (e.getRawSlot() == 52) {
ItemTypeGui.OpenItemsGui(p);
p.playSound(p.getLocation(), Sound.BLOCK_LEVER_CLICK, 1, 2);
}
if (e.getRawSlot() >= 0 && e.getRawSlot() < 36) {
if (!DemonAPI.itemIsNull(e.getCurrentItem()) && !DemonAPI.itemIsLore(e.getCurrentItem())) {
if (e.getClick() == ClickType.DOUBLE_CLICK) {
ItemStack item = e.getCurrentItem();
ItemMeta meta = item.getItemMeta();
String itemName = meta.getDisplayName();
String key = itemName.split("#")[1].replace("§7)", "");
MarketAPI.BuyItemEvent(p, key);
}
if (e.getClick() == ClickType.SHIFT_RIGHT && p.isOp()) {
ItemStack item = e.getCurrentItem();
ItemMeta meta = item.getItemMeta();
String itemName = meta.getDisplayName();
String key = itemName.split("#")[1].replace("§7)", "");
MarketAPI.DeleteItemEvent(p, key);
}
}
}
}
}
public static void OpenGui(Player p, int Paper) {
Inventory inv = Bukkit.createInventory(null, 54, inventory_Title + Paper);
for (int i = 36; i < 53; i++) {
inv.setItem(i, uItems.glass("§7[[§a▧§c▧§a▧§7]]"));
}
inv.setItem(45, uItems.贸易日志());
inv.setItem(46, uItems.管理商品());
inv.setItem(48, uItems.Paper_Butt("§a上一页"));
inv.setItem(49, uItems.排序方式(p));
inv.setItem(50, uItems.Paper_Butt("§a下一页"));
inv.setItem(52, uItems.商品分类());
inv.setItem(53, uItems.出售商品());
List<String> New_KeyList = main.KeyList;
if (New_KeyList.size() >= 1) {
int amount = New_KeyList.size() - 1;
int addamount = Paper * 36;
if (Paper == 1) {
for (int i = amount; i > -1; i--) {
if (New_KeyList.get(i) == null) {
break;
}
String key = New_KeyList.get(i);
String str = "Items." + key + ".";
String Type = main.DataG.getString(str + "Type");
int Money = main.DataG.getInt(str + "Money");
String Seller = main.DataG.getString(str + "Seller");
int ShelfTime = main.DataG.getInt(str + "ShelfTime");
ItemStack items = main.DataG.getItemStack(str + "Item");
inv.addItem(uItems.ShopItemsSell(Seller, items, key, Type, Money, ShelfTime));
}
} else {
for (int i = amount - (addamount - 36); i > (amount - addamount); i--) {
if (i >= 0) {
String key = New_KeyList.get(i);
String str = "Items." + key + ".";
String Type = main.DataG.getString(str + "Type");
int Money = main.DataG.getInt(str + "Money");
String Seller = main.DataG.getString(str + "Seller");
int ShelfTime = main.DataG.getInt(str + "ShelfTime");
ItemStack items = main.DataG.getItemStack(str + "Item");
inv.addItem(uItems.ShopItemsSell(Seller, items, key, Type, Money, ShelfTime));
}
}
}
}
p.openInventory(inv);
}
}

View File

@ -0,0 +1,130 @@
package me.demon.market.MGui;
import me.Demon.DemonPlugin.DemonAPI;
import me.demon.market.Gui.AdminGui;
import me.demon.market.Gui.ItemTypeGui;
import me.demon.market.MarketAPI;
import me.demon.market.Util.uItems;
import me.demon.market.main;
import org.bukkit.Bukkit;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.inventory.ClickType;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.inventory.InventoryType;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import java.util.List;
public class Market_交通 implements Listener {
public static String inventory_Title = "§j§t§r§l拼刀刀市场 §r| §4谨防铁砧改名假货! §8#";
@EventHandler
public void onclick(InventoryClickEvent e) {
Player p = (Player) e.getWhoClicked();
if (e.getInventory().getType() == InventoryType.CHEST && e.getView().getTitle().contains(inventory_Title)) {
e.setCancelled(true);
int Pages = Integer.parseInt(e.getView().getTitle().replace(inventory_Title, ""));
if (e.getRawSlot() == 48) {
p.playSound(p.getLocation(), Sound.BLOCK_LEVER_CLICK, 1, 2);
if (Pages >= 2 && Pages <= 5) {
Market_交通.OpenGui(p, Pages - 1);
} else {
p.sendMessage(main.prefix + "§c已经是第一页了");
}
}
if (e.getRawSlot() == 50) {
p.playSound(p.getLocation(), Sound.BLOCK_LEVER_CLICK, 1, 2);
if (Pages >= 1 && Pages <= 4) {
Market_交通.OpenGui(p, Pages + 1);
} else {
p.sendMessage(main.prefix + "§c已经是最后一页了");
}
}
// 查看交易日志
if (e.getRawSlot() == 45) {
p.sendMessage(main.prefix + "§c暂不支持查看日志。");
p.playSound(p.getLocation(), Sound.BLOCK_LEVER_CLICK, 1, 2);
}
// 打开管理商品
if (e.getRawSlot() == 46) {
AdminGui.OpenGui(p);
p.playSound(p.getLocation(), Sound.BLOCK_LEVER_CLICK, 1, 2);
}
// 刷新页面
if (e.getRawSlot() == 49) {
Market_交通.OpenGui(p, Pages);
p.playSound(p.getLocation(), Sound.BLOCK_LEVER_CLICK, 1, 2);
}
// 打开分类
if (e.getRawSlot() == 52) {
ItemTypeGui.OpenItemsGui(p);
p.playSound(p.getLocation(), Sound.BLOCK_LEVER_CLICK, 1, 2);
}
if (e.getRawSlot() >= 0 && e.getRawSlot() < 36) {
if (!DemonAPI.itemIsNull(e.getCurrentItem()) && !DemonAPI.itemIsLore(e.getCurrentItem())) {
if (e.getClick() == ClickType.DOUBLE_CLICK) {
ItemStack item = e.getCurrentItem();
ItemMeta meta = item.getItemMeta();
String itemName = meta.getDisplayName();
String key = itemName.split("#")[1].replace("§7)", "");
MarketAPI.BuyItemEvent(p, key);
}
}
}
}
}
public static void OpenGui(Player p, int Paper) {
Inventory inv = Bukkit.createInventory(null, 54, inventory_Title + Paper);
for (int i = 36; i < 53; i++) {
inv.setItem(i, uItems.glass("§7[[§a▧§c▧§a▧§7]]"));
}
inv.setItem(45, uItems.贸易日志());
inv.setItem(46, uItems.管理商品());
inv.setItem(48, uItems.Paper_Butt("§a上一页"));
inv.setItem(49, uItems.排序方式(p));
inv.setItem(50, uItems.Paper_Butt("§a下一页"));
inv.setItem(52, uItems.商品分类());
inv.setItem(53, uItems.出售商品());
List<String> New_KeyList = MarketAPI.New_KeyList("交通");
if (New_KeyList.size() >= 1) {
int amount = New_KeyList.size() - 1;
int addamount = Paper * 36;
if (Paper == 1) {
for (int i = amount; i > -1; i--) {
if (New_KeyList.get(i) == null) {
break;
}
String key = New_KeyList.get(i);
String str = "Items." + key + ".";
String Type = main.DataG.getString(str + "Type");
int Money = main.DataG.getInt(str + "Money");
String Seller = main.DataG.getString(str + "Seller");
int ShelfTime = main.DataG.getInt(str + "ShelfTime");
ItemStack items = main.DataG.getItemStack(str + "Item");
inv.addItem(uItems.ShopItemsSell(Seller, items, key, Type, Money, ShelfTime));
}
} else {
for (int i = amount - (addamount - 36); i > (amount - addamount); i--) {
if (i >= 0) {
String key = New_KeyList.get(i);
String str = "Items." + key + ".";
String Type = main.DataG.getString(str + "Type");
int Money = main.DataG.getInt(str + "Money");
String Seller = main.DataG.getString(str + "Seller");
int ShelfTime = main.DataG.getInt(str + "ShelfTime");
ItemStack items = main.DataG.getItemStack(str + "Item");
inv.addItem(uItems.ShopItemsSell(Seller, items, key, Type, Money, ShelfTime));
}
}
}
}
p.openInventory(inv);
}
}

View File

@ -0,0 +1,131 @@
package me.demon.market.MGui;
import me.Demon.DemonPlugin.DemonAPI;
import me.demon.market.Gui.AdminGui;
import me.demon.market.Gui.ItemTypeGui;
import me.demon.market.MarketAPI;
import me.demon.market.Util.uItems;
import me.demon.market.main;
import org.bukkit.Bukkit;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.inventory.ClickType;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.inventory.InventoryType;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import java.util.List;
public class Market_工具 implements Listener {
public static String inventory_Title = "§g§j§r§l拼刀刀市场 §r| §4谨防铁砧改名假货! §8#";
@EventHandler
public void onclick(InventoryClickEvent e) {
Player p = (Player) e.getWhoClicked();
if (e.getInventory().getType() == InventoryType.CHEST && e.getView().getTitle().contains(inventory_Title)) {
e.setCancelled(true);
int Pages = Integer.parseInt(e.getView().getTitle().replace(inventory_Title, ""));
if (e.getRawSlot() == 48) {
p.playSound(p.getLocation(), Sound.BLOCK_LEVER_CLICK, 1, 2);
if (Pages >= 2 && Pages <= 5) {
Market_工具.OpenGui(p, Pages - 1);
} else {
p.sendMessage(main.prefix + "§c已经是第一页了");
}
}
if (e.getRawSlot() == 50) {
p.playSound(p.getLocation(), Sound.BLOCK_LEVER_CLICK, 1, 2);
if (Pages >= 1 && Pages <= 4) {
Market_工具.OpenGui(p, Pages + 1);
} else {
p.sendMessage(main.prefix + "§c已经是最后一页了");
}
}
// 查看交易日志
if (e.getRawSlot() == 45) {
p.sendMessage(main.prefix + "§c暂不支持查看日志。");
p.playSound(p.getLocation(), Sound.BLOCK_LEVER_CLICK, 1, 2);
}
// 打开管理商品
if (e.getRawSlot() == 46) {
AdminGui.OpenGui(p);
p.playSound(p.getLocation(), Sound.BLOCK_LEVER_CLICK, 1, 2);
}
// 刷新页面
if (e.getRawSlot() == 49) {
Market_工具.OpenGui(p, Pages);
p.playSound(p.getLocation(), Sound.BLOCK_LEVER_CLICK, 1, 2);
}
// 打开分类
if (e.getRawSlot() == 52) {
ItemTypeGui.OpenItemsGui(p);
p.playSound(p.getLocation(), Sound.BLOCK_LEVER_CLICK, 1, 2);
}
if (e.getRawSlot() >= 0 && e.getRawSlot() < 36) {
if (!DemonAPI.itemIsNull(e.getCurrentItem()) && !DemonAPI.itemIsLore(e.getCurrentItem())) {
if (e.getClick() == ClickType.DOUBLE_CLICK) {
ItemStack item = e.getCurrentItem();
ItemMeta meta = item.getItemMeta();
String itemName = meta.getDisplayName();
String key = itemName.split("#")[1].replace("§7)", "");
MarketAPI.BuyItemEvent(p, key);
}
}
}
}
}
public static void OpenGui(Player p, int Paper) {
Inventory inv = Bukkit.createInventory(null, 54, inventory_Title + Paper);
for (int i = 36; i < 53; i++) {
inv.setItem(i, uItems.glass("§7[[§a▧§c▧§a▧§7]]"));
}
inv.setItem(45, uItems.贸易日志());
inv.setItem(46, uItems.管理商品());
inv.setItem(48, uItems.Paper_Butt("§a上一页"));
inv.setItem(49, uItems.排序方式(p));
inv.setItem(50, uItems.Paper_Butt("§a下一页"));
inv.setItem(52, uItems.商品分类());
inv.setItem(53, uItems.出售商品());
List<String> New_KeyList = MarketAPI.New_KeyList("工具");
if (New_KeyList.size() >= 1) {
int amount = New_KeyList.size() - 1;
int addamount = Paper * 36;
if (Paper == 1) {
for (int i = amount; i > -1; i--) {
if (New_KeyList.get(i) == null) {
break;
}
String key = New_KeyList.get(i);
String str = "Items." + key + ".";
String Type = main.DataG.getString(str + "Type");
int Money = main.DataG.getInt(str + "Money");
String Seller = main.DataG.getString(str + "Seller");
int ShelfTime = main.DataG.getInt(str + "ShelfTime");
ItemStack items = main.DataG.getItemStack(str + "Item");
inv.addItem(uItems.ShopItemsSell(Seller, items, key, Type, Money, ShelfTime));
}
} else {
for (int i = amount - (addamount - 36); i > (amount - addamount); i--) {
if (i >= 0) {
String key = New_KeyList.get(i);
String str = "Items." + key + ".";
String Type = main.DataG.getString(str + "Type");
int Money = main.DataG.getInt(str + "Money");
String Seller = main.DataG.getString(str + "Seller");
int ShelfTime = main.DataG.getInt(str + "ShelfTime");
ItemStack items = main.DataG.getItemStack(str + "Item");
inv.addItem(uItems.ShopItemsSell(Seller, items, key, Type, Money, ShelfTime));
}
}
}
}
p.openInventory(inv);
}
}

View File

@ -0,0 +1,123 @@
package me.demon.market.MGui;
import me.Demon.DemonPlugin.DemonAPI;
import me.demon.market.Gui.AdminGui;
import me.demon.market.Gui.ItemTypeGui;
import me.demon.market.MarketAPI;
import me.demon.market.Util.uItems;
import me.demon.market.main;
import org.bukkit.Bukkit;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.inventory.ClickType;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.inventory.InventoryType;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import java.util.List;
public class Market_方块 implements Listener {
public static String inventory_Title = "§f§k§r§l拼刀刀市场 §r| §4谨防铁砧改名假货! §8#";
@EventHandler
public void onclick(InventoryClickEvent e){
Player p = (Player) e.getWhoClicked();
if(e.getInventory().getType() == InventoryType.CHEST && e.getView().getTitle().contains(inventory_Title)){
e.setCancelled(true);
int Pages = Integer.parseInt(e.getView().getTitle().replace(inventory_Title,""));
if(e.getRawSlot() == 48){p.playSound(p.getLocation(), Sound.BLOCK_LEVER_CLICK,1,2);
if(Pages >= 2 && Pages <= 5){
Market_方块.OpenGui(p,Pages - 1);} else {p.sendMessage(main.prefix+"§c已经是第一页了");}
}
if(e.getRawSlot() == 50){p.playSound(p.getLocation(), Sound.BLOCK_LEVER_CLICK,1,2);
if(Pages >= 1 && Pages <= 4){
Market_方块.OpenGui(p,Pages+1);} else {p.sendMessage(main.prefix+"§c已经是最后一页了");}
}
// 查看交易日志
if(e.getRawSlot() == 45){
p.sendMessage(main.prefix+"§c暂不支持查看日志。");
p.playSound(p.getLocation(), Sound.BLOCK_LEVER_CLICK,1,2);
}
// 打开管理商品
if(e.getRawSlot() == 46){
AdminGui.OpenGui(p);
p.playSound(p.getLocation(), Sound.BLOCK_LEVER_CLICK,1,2);
}
// 刷新页面
if(e.getRawSlot() == 49){
Market_方块.OpenGui(p,Pages);
p.playSound(p.getLocation(), Sound.BLOCK_LEVER_CLICK,1,2);
}
// 打开分类
if(e.getRawSlot() == 52){
ItemTypeGui.OpenItemsGui(p);
p.playSound(p.getLocation(), Sound.BLOCK_LEVER_CLICK,1,2);
}
if(e.getRawSlot() >= 0 && e.getRawSlot() < 36){
if (!DemonAPI.itemIsNull(e.getCurrentItem()) && !DemonAPI.itemIsLore(e.getCurrentItem())) {
if(e.getClick() == ClickType.DOUBLE_CLICK) {
ItemStack item = e.getCurrentItem();
ItemMeta meta = item.getItemMeta();
String itemName = meta.getDisplayName();
String key = itemName.split("#")[1].replace("§7)","");
MarketAPI.BuyItemEvent(p, key);
}
}
}
}
}
public static void OpenGui(Player p,int Paper){
Inventory inv = Bukkit.createInventory(null,54,inventory_Title+Paper);
for (int i = 36;i<53;i++){
inv.setItem(i, uItems.glass("§7[[§a▧§c▧§a▧§7]]"));
}
inv.setItem(45,uItems.贸易日志());
inv.setItem(46,uItems.管理商品());
inv.setItem(48,uItems.Paper_Butt("§a上一页"));
inv.setItem(49,uItems.排序方式(p));
inv.setItem(50,uItems.Paper_Butt("§a下一页"));
inv.setItem(52,uItems.商品分类());
inv.setItem(53,uItems.出售商品());
List<String> New_KeyList = MarketAPI.New_KeyList("方块");
if(New_KeyList.size() >= 1) {
int amount = New_KeyList.size()-1;
int addamount = Paper * 36;
if(Paper == 1) {
for (int i = amount; i > -1; i--) {
if(New_KeyList.get(i) == null){
break;
}
String key = New_KeyList.get(i);
String str = "Items."+key+".";
String Type = main.DataG.getString(str+"Type");
int Money = main.DataG.getInt(str+"Money");
String Seller = main.DataG.getString(str+"Seller");
int ShelfTime = main.DataG.getInt(str+"ShelfTime");
ItemStack items = main.DataG.getItemStack(str+"Item");
inv.addItem(uItems.ShopItemsSell(Seller,items,key,Type,Money,ShelfTime));
}
}else {
for (int i = amount - (addamount - 36); i > (amount - addamount); i--) {
if(i >= 0) {
String key = New_KeyList.get(i);
String str = "Items."+key+".";
String Type = main.DataG.getString(str+"Type");
int Money = main.DataG.getInt(str+"Money");
String Seller = main.DataG.getString(str+"Seller");
int ShelfTime = main.DataG.getInt(str+"ShelfTime");
ItemStack items = main.DataG.getItemStack(str+"Item");
inv.addItem(uItems.ShopItemsSell(Seller,items,key,Type,Money,ShelfTime));
}
}
}
}
p.openInventory(inv);
}
}

View File

@ -0,0 +1,130 @@
package me.demon.market.MGui;
import me.Demon.DemonPlugin.DemonAPI;
import me.demon.market.Gui.AdminGui;
import me.demon.market.Gui.ItemTypeGui;
import me.demon.market.MarketAPI;
import me.demon.market.Util.uItems;
import me.demon.market.main;
import org.bukkit.Bukkit;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.inventory.ClickType;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.inventory.InventoryType;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import java.util.List;
public class Market_杂项 implements Listener {
public static String inventory_Title = "§z§x§r§l拼刀刀市场 §r| §4谨防铁砧改名假货! §8#";
@EventHandler
public void onclick(InventoryClickEvent e) {
Player p = (Player) e.getWhoClicked();
if (e.getInventory().getType() == InventoryType.CHEST && e.getView().getTitle().contains(inventory_Title)) {
e.setCancelled(true);
int Pages = Integer.parseInt(e.getView().getTitle().replace(inventory_Title, ""));
if (e.getRawSlot() == 48) {
p.playSound(p.getLocation(), Sound.BLOCK_LEVER_CLICK, 1, 2);
if (Pages >= 2 && Pages <= 5) {
Market_杂项.OpenGui(p, Pages - 1);
} else {
p.sendMessage(main.prefix + "§c已经是第一页了");
}
}
if (e.getRawSlot() == 50) {
p.playSound(p.getLocation(), Sound.BLOCK_LEVER_CLICK, 1, 2);
if (Pages >= 1 && Pages <= 4) {
Market_杂项.OpenGui(p, Pages + 1);
} else {
p.sendMessage(main.prefix + "§c已经是最后一页了");
}
}
// 查看交易日志
if (e.getRawSlot() == 45) {
p.sendMessage(main.prefix + "§c暂不支持查看日志。");
p.playSound(p.getLocation(), Sound.BLOCK_LEVER_CLICK, 1, 2);
}
// 打开管理商品
if (e.getRawSlot() == 46) {
AdminGui.OpenGui(p);
p.playSound(p.getLocation(), Sound.BLOCK_LEVER_CLICK, 1, 2);
}
// 刷新页面
if (e.getRawSlot() == 49) {
Market_杂项.OpenGui(p, Pages);
p.playSound(p.getLocation(), Sound.BLOCK_LEVER_CLICK, 1, 2);
}
// 打开分类
if (e.getRawSlot() == 52) {
ItemTypeGui.OpenItemsGui(p);
p.playSound(p.getLocation(), Sound.BLOCK_LEVER_CLICK, 1, 2);
}
if (e.getRawSlot() >= 0 && e.getRawSlot() < 36) {
if (!DemonAPI.itemIsNull(e.getCurrentItem()) && !DemonAPI.itemIsLore(e.getCurrentItem())) {
if (e.getClick() == ClickType.DOUBLE_CLICK) {
ItemStack item = e.getCurrentItem();
ItemMeta meta = item.getItemMeta();
String itemName = meta.getDisplayName();
String key = itemName.split("#")[1].replace("§7)", "");
MarketAPI.BuyItemEvent(p, key);
}
}
}
}
}
public static void OpenGui(Player p, int Paper) {
Inventory inv = Bukkit.createInventory(null, 54, inventory_Title + Paper);
for (int i = 36; i < 53; i++) {
inv.setItem(i, uItems.glass("§7[[§a▧§c▧§a▧§7]]"));
}
inv.setItem(45, uItems.贸易日志());
inv.setItem(46, uItems.管理商品());
inv.setItem(48, uItems.Paper_Butt("§a上一页"));
inv.setItem(49, uItems.排序方式(p));
inv.setItem(50, uItems.Paper_Butt("§a下一页"));
inv.setItem(52, uItems.商品分类());
inv.setItem(53, uItems.出售商品());
List<String> New_KeyList = MarketAPI.New_KeyList("杂项");
if (New_KeyList.size() >= 1) {
int amount = New_KeyList.size() - 1;
int addamount = Paper * 36;
if (Paper == 1) {
for (int i = amount; i > -1; i--) {
if (New_KeyList.get(i) == null) {
break;
}
String key = New_KeyList.get(i);
String str = "Items." + key + ".";
String Type = main.DataG.getString(str + "Type");
int Money = main.DataG.getInt(str + "Money");
String Seller = main.DataG.getString(str + "Seller");
int ShelfTime = main.DataG.getInt(str + "ShelfTime");
ItemStack items = main.DataG.getItemStack(str + "Item");
inv.addItem(uItems.ShopItemsSell(Seller, items, key, Type, Money, ShelfTime));
}
} else {
for (int i = amount - (addamount - 36); i > (amount - addamount); i--) {
if (i >= 0) {
String key = New_KeyList.get(i);
String str = "Items." + key + ".";
String Type = main.DataG.getString(str + "Type");
int Money = main.DataG.getInt(str + "Money");
String Seller = main.DataG.getString(str + "Seller");
int ShelfTime = main.DataG.getInt(str + "ShelfTime");
ItemStack items = main.DataG.getItemStack(str + "Item");
inv.addItem(uItems.ShopItemsSell(Seller, items, key, Type, Money, ShelfTime));
}
}
}
}
p.openInventory(inv);
}
}

View File

@ -0,0 +1,130 @@
package me.demon.market.MGui;
import me.Demon.DemonPlugin.DemonAPI;
import me.demon.market.Gui.AdminGui;
import me.demon.market.Gui.ItemTypeGui;
import me.demon.market.MarketAPI;
import me.demon.market.Util.uItems;
import me.demon.market.main;
import org.bukkit.Bukkit;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.inventory.ClickType;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.inventory.InventoryType;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import java.util.List;
public class Market_武器 implements Listener {
public static String inventory_Title = "§w§q§r§l拼刀刀市场 §r| §4谨防铁砧改名假货! §8#";
@EventHandler
public void onclick(InventoryClickEvent e) {
Player p = (Player) e.getWhoClicked();
if (e.getInventory().getType() == InventoryType.CHEST && e.getView().getTitle().contains(inventory_Title)) {
e.setCancelled(true);
int Pages = Integer.parseInt(e.getView().getTitle().replace(inventory_Title, ""));
if (e.getRawSlot() == 48) {
p.playSound(p.getLocation(), Sound.BLOCK_LEVER_CLICK, 1, 2);
if (Pages >= 2 && Pages <= 5) {
Market_武器.OpenGui(p, Pages - 1);
} else {
p.sendMessage(main.prefix + "§c已经是第一页了");
}
}
if (e.getRawSlot() == 50) {
p.playSound(p.getLocation(), Sound.BLOCK_LEVER_CLICK, 1, 2);
if (Pages >= 1 && Pages <= 4) {
Market_武器.OpenGui(p, Pages + 1);
} else {
p.sendMessage(main.prefix + "§c已经是最后一页了");
}
}
// 查看交易日志
if (e.getRawSlot() == 45) {
p.sendMessage(main.prefix + "§c暂不支持查看日志。");
p.playSound(p.getLocation(), Sound.BLOCK_LEVER_CLICK, 1, 2);
}
// 打开管理商品
if (e.getRawSlot() == 46) {
AdminGui.OpenGui(p);
p.playSound(p.getLocation(), Sound.BLOCK_LEVER_CLICK, 1, 2);
}
// 刷新页面
if (e.getRawSlot() == 49) {
Market_武器.OpenGui(p, Pages);
p.playSound(p.getLocation(), Sound.BLOCK_LEVER_CLICK, 1, 2);
}
// 打开分类
if (e.getRawSlot() == 52) {
ItemTypeGui.OpenItemsGui(p);
p.playSound(p.getLocation(), Sound.BLOCK_LEVER_CLICK, 1, 2);
}
if (e.getRawSlot() >= 0 && e.getRawSlot() < 36) {
if (!DemonAPI.itemIsNull(e.getCurrentItem()) && !DemonAPI.itemIsLore(e.getCurrentItem())) {
if (e.getClick() == ClickType.DOUBLE_CLICK) {
ItemStack item = e.getCurrentItem();
ItemMeta meta = item.getItemMeta();
String itemName = meta.getDisplayName();
String key = itemName.split("#")[1].replace("§7)", "");
MarketAPI.BuyItemEvent(p, key);
}
}
}
}
}
public static void OpenGui(Player p, int Paper) {
Inventory inv = Bukkit.createInventory(null, 54, inventory_Title + Paper);
for (int i = 36; i < 53; i++) {
inv.setItem(i, uItems.glass("§7[[§a▧§c▧§a▧§7]]"));
}
inv.setItem(45, uItems.贸易日志());
inv.setItem(46, uItems.管理商品());
inv.setItem(48, uItems.Paper_Butt("§a上一页"));
inv.setItem(49, uItems.排序方式(p));
inv.setItem(50, uItems.Paper_Butt("§a下一页"));
inv.setItem(52, uItems.商品分类());
inv.setItem(53, uItems.出售商品());
List<String> New_KeyList = MarketAPI.New_KeyList("武器");
if (New_KeyList.size() >= 1) {
int amount = New_KeyList.size() - 1;
int addamount = Paper * 36;
if (Paper == 1) {
for (int i = amount; i > -1; i--) {
if (New_KeyList.get(i) == null) {
break;
}
String key = New_KeyList.get(i);
String str = "Items." + key + ".";
String Type = main.DataG.getString(str + "Type");
int Money = main.DataG.getInt(str + "Money");
String Seller = main.DataG.getString(str + "Seller");
int ShelfTime = main.DataG.getInt(str + "ShelfTime");
ItemStack items = main.DataG.getItemStack(str + "Item");
inv.addItem(uItems.ShopItemsSell(Seller, items, key, Type, Money, ShelfTime));
}
} else {
for (int i = amount - (addamount - 36); i > (amount - addamount); i--) {
if (i >= 0) {
String key = New_KeyList.get(i);
String str = "Items." + key + ".";
String Type = main.DataG.getString(str + "Type");
int Money = main.DataG.getInt(str + "Money");
String Seller = main.DataG.getString(str + "Seller");
int ShelfTime = main.DataG.getInt(str + "ShelfTime");
ItemStack items = main.DataG.getItemStack(str + "Item");
inv.addItem(uItems.ShopItemsSell(Seller, items, key, Type, Money, ShelfTime));
}
}
}
}
p.openInventory(inv);
}
}

View File

@ -0,0 +1,130 @@
package me.demon.market.MGui;
import me.Demon.DemonPlugin.DemonAPI;
import me.demon.market.Gui.AdminGui;
import me.demon.market.Gui.ItemTypeGui;
import me.demon.market.MarketAPI;
import me.demon.market.Util.uItems;
import me.demon.market.main;
import org.bukkit.Bukkit;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.inventory.ClickType;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.inventory.InventoryType;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import java.util.List;
public class Market_红石 implements Listener {
public static String inventory_Title = "§h§s§r§l拼刀刀市场 §r| §4谨防铁砧改名假货! §8#";
@EventHandler
public void onclick(InventoryClickEvent e) {
Player p = (Player) e.getWhoClicked();
if (e.getInventory().getType() == InventoryType.CHEST && e.getView().getTitle().contains(inventory_Title)) {
e.setCancelled(true);
int Pages = Integer.parseInt(e.getView().getTitle().replace(inventory_Title, ""));
if (e.getRawSlot() == 48) {
p.playSound(p.getLocation(), Sound.BLOCK_LEVER_CLICK, 1, 2);
if (Pages >= 2 && Pages <= 5) {
Market_红石.OpenGui(p, Pages - 1);
} else {
p.sendMessage(main.prefix + "§c已经是第一页了");
}
}
if (e.getRawSlot() == 50) {
p.playSound(p.getLocation(), Sound.BLOCK_LEVER_CLICK, 1, 2);
if (Pages >= 1 && Pages <= 4) {
Market_红石.OpenGui(p, Pages + 1);
} else {
p.sendMessage(main.prefix + "§c已经是最后一页了");
}
}
// 查看交易日志
if (e.getRawSlot() == 45) {
p.sendMessage(main.prefix + "§c暂不支持查看日志。");
p.playSound(p.getLocation(), Sound.BLOCK_LEVER_CLICK, 1, 2);
}
// 打开管理商品
if (e.getRawSlot() == 46) {
AdminGui.OpenGui(p);
p.playSound(p.getLocation(), Sound.BLOCK_LEVER_CLICK, 1, 2);
}
// 刷新页面
if (e.getRawSlot() == 49) {
Market_红石.OpenGui(p, Pages);
p.playSound(p.getLocation(), Sound.BLOCK_LEVER_CLICK, 1, 2);
}
// 打开分类
if (e.getRawSlot() == 52) {
ItemTypeGui.OpenItemsGui(p);
p.playSound(p.getLocation(), Sound.BLOCK_LEVER_CLICK, 1, 2);
}
if (e.getRawSlot() >= 0 && e.getRawSlot() < 36) {
if (!DemonAPI.itemIsNull(e.getCurrentItem()) && !DemonAPI.itemIsLore(e.getCurrentItem())) {
if (e.getClick() == ClickType.DOUBLE_CLICK) {
ItemStack item = e.getCurrentItem();
ItemMeta meta = item.getItemMeta();
String itemName = meta.getDisplayName();
String key = itemName.split("#")[1].replace("§7)", "");
MarketAPI.BuyItemEvent(p, key);
}
}
}
}
}
public static void OpenGui(Player p, int Paper) {
Inventory inv = Bukkit.createInventory(null, 54, inventory_Title + Paper);
for (int i = 36; i < 53; i++) {
inv.setItem(i, uItems.glass("§7[[§a▧§c▧§a▧§7]]"));
}
inv.setItem(45, uItems.贸易日志());
inv.setItem(46, uItems.管理商品());
inv.setItem(48, uItems.Paper_Butt("§a上一页"));
inv.setItem(49, uItems.排序方式(p));
inv.setItem(50, uItems.Paper_Butt("§a下一页"));
inv.setItem(52, uItems.商品分类());
inv.setItem(53, uItems.出售商品());
List<String> New_KeyList = MarketAPI.New_KeyList("红石");
if (New_KeyList.size() >= 1) {
int amount = New_KeyList.size() - 1;
int addamount = Paper * 36;
if (Paper == 1) {
for (int i = amount; i > -1; i--) {
if (New_KeyList.get(i) == null) {
break;
}
String key = New_KeyList.get(i);
String str = "Items." + key + ".";
String Type = main.DataG.getString(str + "Type");
int Money = main.DataG.getInt(str + "Money");
String Seller = main.DataG.getString(str + "Seller");
int ShelfTime = main.DataG.getInt(str + "ShelfTime");
ItemStack items = main.DataG.getItemStack(str + "Item");
inv.addItem(uItems.ShopItemsSell(Seller, items, key, Type, Money, ShelfTime));
}
} else {
for (int i = amount - (addamount - 36); i > (amount - addamount); i--) {
if (i >= 0) {
String key = New_KeyList.get(i);
String str = "Items." + key + ".";
String Type = main.DataG.getString(str + "Type");
int Money = main.DataG.getInt(str + "Money");
String Seller = main.DataG.getString(str + "Seller");
int ShelfTime = main.DataG.getInt(str + "ShelfTime");
ItemStack items = main.DataG.getItemStack(str + "Item");
inv.addItem(uItems.ShopItemsSell(Seller, items, key, Type, Money, ShelfTime));
}
}
}
}
p.openInventory(inv);
}
}

View File

@ -0,0 +1,130 @@
package me.demon.market.MGui;
import me.Demon.DemonPlugin.DemonAPI;
import me.demon.market.Gui.AdminGui;
import me.demon.market.Gui.ItemTypeGui;
import me.demon.market.MarketAPI;
import me.demon.market.Util.uItems;
import me.demon.market.main;
import org.bukkit.Bukkit;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.inventory.ClickType;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.inventory.InventoryType;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import java.util.List;
public class Market_药水 implements Listener {
public static String inventory_Title = "§y§s§r§l拼刀刀市场 §r| §4谨防铁砧改名假货! §8#";
@EventHandler
public void onclick(InventoryClickEvent e) {
Player p = (Player) e.getWhoClicked();
if (e.getInventory().getType() == InventoryType.CHEST && e.getView().getTitle().contains(inventory_Title)) {
e.setCancelled(true);
int Pages = Integer.parseInt(e.getView().getTitle().replace(inventory_Title, ""));
if (e.getRawSlot() == 48) {
p.playSound(p.getLocation(), Sound.BLOCK_LEVER_CLICK, 1, 2);
if (Pages >= 2 && Pages <= 5) {
Market_药水.OpenGui(p, Pages - 1);
} else {
p.sendMessage(main.prefix + "§c已经是第一页了");
}
}
if (e.getRawSlot() == 50) {
p.playSound(p.getLocation(), Sound.BLOCK_LEVER_CLICK, 1, 2);
if (Pages >= 1 && Pages <= 4) {
Market_药水.OpenGui(p, Pages + 1);
} else {
p.sendMessage(main.prefix + "§c已经是最后一页了");
}
}
// 查看交易日志
if (e.getRawSlot() == 45) {
p.sendMessage(main.prefix + "§c暂不支持查看日志。");
p.playSound(p.getLocation(), Sound.BLOCK_LEVER_CLICK, 1, 2);
}
// 打开管理商品
if (e.getRawSlot() == 46) {
AdminGui.OpenGui(p);
p.playSound(p.getLocation(), Sound.BLOCK_LEVER_CLICK, 1, 2);
}
// 刷新页面
if (e.getRawSlot() == 49) {
Market_药水.OpenGui(p, Pages);
p.playSound(p.getLocation(), Sound.BLOCK_LEVER_CLICK, 1, 2);
}
// 打开分类
if (e.getRawSlot() == 52) {
ItemTypeGui.OpenItemsGui(p);
p.playSound(p.getLocation(), Sound.BLOCK_LEVER_CLICK, 1, 2);
}
if (e.getRawSlot() >= 0 && e.getRawSlot() < 36) {
if (!DemonAPI.itemIsNull(e.getCurrentItem()) && !DemonAPI.itemIsLore(e.getCurrentItem())) {
if (e.getClick() == ClickType.DOUBLE_CLICK) {
ItemStack item = e.getCurrentItem();
ItemMeta meta = item.getItemMeta();
String itemName = meta.getDisplayName();
String key = itemName.split("#")[1].replace("§7)", "");
MarketAPI.BuyItemEvent(p, key);
}
}
}
}
}
public static void OpenGui(Player p, int Paper) {
Inventory inv = Bukkit.createInventory(null, 54, inventory_Title + Paper);
for (int i = 36; i < 53; i++) {
inv.setItem(i, uItems.glass("§7[[§a▧§c▧§a▧§7]]"));
}
inv.setItem(45, uItems.贸易日志());
inv.setItem(46, uItems.管理商品());
inv.setItem(48, uItems.Paper_Butt("§a上一页"));
inv.setItem(49, uItems.排序方式(p));
inv.setItem(50, uItems.Paper_Butt("§a下一页"));
inv.setItem(52, uItems.商品分类());
inv.setItem(53, uItems.出售商品());
List<String> New_KeyList = MarketAPI.New_KeyList("药水");
if (New_KeyList.size() >= 1) {
int amount = New_KeyList.size() - 1;
int addamount = Paper * 36;
if (Paper == 1) {
for (int i = amount; i > -1; i--) {
if (New_KeyList.get(i) == null) {
break;
}
String key = New_KeyList.get(i);
String str = "Items." + key + ".";
String Type = main.DataG.getString(str + "Type");
int Money = main.DataG.getInt(str + "Money");
String Seller = main.DataG.getString(str + "Seller");
int ShelfTime = main.DataG.getInt(str + "ShelfTime");
ItemStack items = main.DataG.getItemStack(str + "Item");
inv.addItem(uItems.ShopItemsSell(Seller, items, key, Type, Money, ShelfTime));
}
} else {
for (int i = amount - (addamount - 36); i > (amount - addamount); i--) {
if (i >= 0) {
String key = New_KeyList.get(i);
String str = "Items." + key + ".";
String Type = main.DataG.getString(str + "Type");
int Money = main.DataG.getInt(str + "Money");
String Seller = main.DataG.getString(str + "Seller");
int ShelfTime = main.DataG.getInt(str + "ShelfTime");
ItemStack items = main.DataG.getItemStack(str + "Item");
inv.addItem(uItems.ShopItemsSell(Seller, items, key, Type, Money, ShelfTime));
}
}
}
}
p.openInventory(inv);
}
}

View File

@ -0,0 +1,130 @@
package me.demon.market.MGui;
import me.Demon.DemonPlugin.DemonAPI;
import me.demon.market.Gui.AdminGui;
import me.demon.market.Gui.ItemTypeGui;
import me.demon.market.MarketAPI;
import me.demon.market.Util.uItems;
import me.demon.market.main;
import org.bukkit.Bukkit;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.inventory.ClickType;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.inventory.InventoryType;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import java.util.List;
public class Market_防具 implements Listener {
public static String inventory_Title = "§f§j§r§l拼刀刀市场 §r| §4谨防铁砧改名假货! §8#";
@EventHandler
public void onclick(InventoryClickEvent e) {
Player p = (Player) e.getWhoClicked();
if (e.getInventory().getType() == InventoryType.CHEST && e.getView().getTitle().contains(inventory_Title)) {
e.setCancelled(true);
int Pages = Integer.parseInt(e.getView().getTitle().replace(inventory_Title, ""));
if (e.getRawSlot() == 48) {
p.playSound(p.getLocation(), Sound.BLOCK_LEVER_CLICK, 1, 2);
if (Pages >= 2 && Pages <= 5) {
Market_防具.OpenGui(p, Pages - 1);
} else {
p.sendMessage(main.prefix + "§c已经是第一页了");
}
}
if (e.getRawSlot() == 50) {
p.playSound(p.getLocation(), Sound.BLOCK_LEVER_CLICK, 1, 2);
if (Pages >= 1 && Pages <= 4) {
Market_防具.OpenGui(p, Pages + 1);
} else {
p.sendMessage(main.prefix + "§c已经是最后一页了");
}
}
// 查看交易日志
if (e.getRawSlot() == 45) {
p.sendMessage(main.prefix + "§c暂不支持查看日志。");
p.playSound(p.getLocation(), Sound.BLOCK_LEVER_CLICK, 1, 2);
}
// 打开管理商品
if (e.getRawSlot() == 46) {
AdminGui.OpenGui(p);
p.playSound(p.getLocation(), Sound.BLOCK_LEVER_CLICK, 1, 2);
}
// 刷新页面
if (e.getRawSlot() == 49) {
Market_防具.OpenGui(p, Pages);
p.playSound(p.getLocation(), Sound.BLOCK_LEVER_CLICK, 1, 2);
}
// 打开分类
if (e.getRawSlot() == 52) {
ItemTypeGui.OpenItemsGui(p);
p.playSound(p.getLocation(), Sound.BLOCK_LEVER_CLICK, 1, 2);
}
if (e.getRawSlot() >= 0 && e.getRawSlot() < 36) {
if (!DemonAPI.itemIsNull(e.getCurrentItem()) && !DemonAPI.itemIsLore(e.getCurrentItem())) {
if (e.getClick() == ClickType.DOUBLE_CLICK) {
ItemStack item = e.getCurrentItem();
ItemMeta meta = item.getItemMeta();
String itemName = meta.getDisplayName();
String key = itemName.split("#")[1].replace("§7)", "");
MarketAPI.BuyItemEvent(p, key);
}
}
}
}
}
public static void OpenGui(Player p, int Paper) {
Inventory inv = Bukkit.createInventory(null, 54, inventory_Title + Paper);
for (int i = 36; i < 53; i++) {
inv.setItem(i, uItems.glass("§7[[§a▧§c▧§a▧§7]]"));
}
inv.setItem(45, uItems.贸易日志());
inv.setItem(46, uItems.管理商品());
inv.setItem(48, uItems.Paper_Butt("§a上一页"));
inv.setItem(49, uItems.排序方式(p));
inv.setItem(50, uItems.Paper_Butt("§a下一页"));
inv.setItem(52, uItems.商品分类());
inv.setItem(53, uItems.出售商品());
List<String> New_KeyList = MarketAPI.New_KeyList("防具");
if (New_KeyList.size() >= 1) {
int amount = New_KeyList.size() - 1;
int addamount = Paper * 36;
if (Paper == 1) {
for (int i = amount; i > -1; i--) {
if (New_KeyList.get(i) == null) {
break;
}
String key = New_KeyList.get(i);
String str = "Items." + key + ".";
String Type = main.DataG.getString(str + "Type");
int Money = main.DataG.getInt(str + "Money");
String Seller = main.DataG.getString(str + "Seller");
int ShelfTime = main.DataG.getInt(str + "ShelfTime");
ItemStack items = main.DataG.getItemStack(str + "Item");
inv.addItem(uItems.ShopItemsSell(Seller, items, key, Type, Money, ShelfTime));
}
} else {
for (int i = amount - (addamount - 36); i > (amount - addamount); i--) {
if (i >= 0) {
String key = New_KeyList.get(i);
String str = "Items." + key + ".";
String Type = main.DataG.getString(str + "Type");
int Money = main.DataG.getInt(str + "Money");
String Seller = main.DataG.getString(str + "Seller");
int ShelfTime = main.DataG.getInt(str + "ShelfTime");
ItemStack items = main.DataG.getItemStack(str + "Item");
inv.addItem(uItems.ShopItemsSell(Seller, items, key, Type, Money, ShelfTime));
}
}
}
}
p.openInventory(inv);
}
}

View File

@ -0,0 +1,130 @@
package me.demon.market.MGui;
import me.Demon.DemonPlugin.DemonAPI;
import me.demon.market.Gui.AdminGui;
import me.demon.market.Gui.ItemTypeGui;
import me.demon.market.MarketAPI;
import me.demon.market.Util.uItems;
import me.demon.market.main;
import org.bukkit.Bukkit;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.inventory.ClickType;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.inventory.InventoryType;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import java.util.List;
public class Market_食物 implements Listener {
public static String inventory_Title = "§s§w§r§l拼刀刀市场 §r| §4谨防铁、砧改名假货! §8#";
@EventHandler
public void onclick(InventoryClickEvent e) {
Player p = (Player) e.getWhoClicked();
if (e.getInventory().getType() == InventoryType.CHEST && e.getView().getTitle().contains(inventory_Title)) {
e.setCancelled(true);
int Pages = Integer.parseInt(e.getView().getTitle().replace(inventory_Title, ""));
if (e.getRawSlot() == 48) {
p.playSound(p.getLocation(), Sound.BLOCK_LEVER_CLICK, 1, 2);
if (Pages >= 2 && Pages <= 5) {
Market_食物.OpenGui(p, Pages - 1);
} else {
p.sendMessage(main.prefix + "§c已经是第一页了");
}
}
if (e.getRawSlot() == 50) {
p.playSound(p.getLocation(), Sound.BLOCK_LEVER_CLICK, 1, 2);
if (Pages >= 1 && Pages <= 4) {
Market_食物.OpenGui(p, Pages + 1);
} else {
p.sendMessage(main.prefix + "§c已经是最后一页了");
}
}
// 查看交易日志
if (e.getRawSlot() == 45) {
p.sendMessage(main.prefix + "§c暂不支持查看日志。");
p.playSound(p.getLocation(), Sound.BLOCK_LEVER_CLICK, 1, 2);
}
// 打开管理商品
if (e.getRawSlot() == 46) {
AdminGui.OpenGui(p);
p.playSound(p.getLocation(), Sound.BLOCK_LEVER_CLICK, 1, 2);
}
// 刷新页面
if (e.getRawSlot() == 49) {
Market_食物.OpenGui(p, Pages);
p.playSound(p.getLocation(), Sound.BLOCK_LEVER_CLICK, 1, 2);
}
// 打开分类
if (e.getRawSlot() == 52) {
ItemTypeGui.OpenItemsGui(p);
p.playSound(p.getLocation(), Sound.BLOCK_LEVER_CLICK, 1, 2);
}
if (e.getRawSlot() >= 0 && e.getRawSlot() < 36) {
if (!DemonAPI.itemIsNull(e.getCurrentItem()) && !DemonAPI.itemIsLore(e.getCurrentItem())) {
if (e.getClick() == ClickType.DOUBLE_CLICK) {
ItemStack item = e.getCurrentItem();
ItemMeta meta = item.getItemMeta();
String itemName = meta.getDisplayName();
String key = itemName.split("#")[1].replace("§7)", "");
MarketAPI.BuyItemEvent(p, key);
}
}
}
}
}
public static void OpenGui(Player p, int Paper) {
Inventory inv = Bukkit.createInventory(null, 54, inventory_Title + Paper);
for (int i = 36; i < 53; i++) {
inv.setItem(i, uItems.glass("§7[[§a▧§c▧§a▧§7]]"));
}
inv.setItem(45, uItems.贸易日志());
inv.setItem(46, uItems.管理商品());
inv.setItem(48, uItems.Paper_Butt("§a上一页"));
inv.setItem(49, uItems.排序方式(p));
inv.setItem(50, uItems.Paper_Butt("§a下一页"));
inv.setItem(52, uItems.商品分类());
inv.setItem(53, uItems.出售商品());
List<String> New_KeyList = MarketAPI.New_KeyList("食物");
if (New_KeyList.size() >= 1) {
int amount = New_KeyList.size() - 1;
int addamount = Paper * 36;
if (Paper == 1) {
for (int i = amount; i > -1; i--) {
if (New_KeyList.get(i) == null) {
break;
}
String key = New_KeyList.get(i);
String str = "Items." + key + ".";
String Type = main.DataG.getString(str + "Type");
int Money = main.DataG.getInt(str + "Money");
String Seller = main.DataG.getString(str + "Seller");
int ShelfTime = main.DataG.getInt(str + "ShelfTime");
ItemStack items = main.DataG.getItemStack(str + "Item");
inv.addItem(uItems.ShopItemsSell(Seller, items, key, Type, Money, ShelfTime));
}
} else {
for (int i = amount - (addamount - 36); i > (amount - addamount); i--) {
if (i >= 0) {
String key = New_KeyList.get(i);
String str = "Items." + key + ".";
String Type = main.DataG.getString(str + "Type");
int Money = main.DataG.getInt(str + "Money");
String Seller = main.DataG.getString(str + "Seller");
int ShelfTime = main.DataG.getInt(str + "ShelfTime");
ItemStack items = main.DataG.getItemStack(str + "Item");
inv.addItem(uItems.ShopItemsSell(Seller, items, key, Type, Money, ShelfTime));
}
}
}
}
p.openInventory(inv);
}
}

View File

@ -0,0 +1,95 @@
package me.demon.market;
import me.Demon.DemonPlugin.DemonAPI;
import me.demon.market.Event.MarketTradeEvent;
import org.bukkit.Bukkit;
import org.bukkit.Sound;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.List;
public abstract class MarketAPI {
//拍下物品
public static void BuyItemEvent(Player p, String key) {
if (main.DataG.getString("Items." + key + ".Item") == null) {
p.sendMessage(main.prefix + "很抱歉,其他玩家抢先一步拍走了这个珍贵的商品!");
p.playSound(p.getLocation(), Sound.BLOCK_LEVER_CLICK, 1, 2);
return;
}
FileConfiguration yml = main.DataG;
String str = "Items." + key + ".";
String playName = yml.getString(str + "Seller");
if (p.getName().equalsIgnoreCase(playName)) {
p.sendMessage(main.prefix + "很抱歉,您不能拍下自己的商品!");
return;
}
String Type = yml.getString(str + "Type");
int Money = yml.getInt(str + "Money");
if (DemonAPI.hasMoney(p, Money)) {
DemonAPI.takeMoney(p, Money);
ItemStack items = yml.getItemStack(str + "Item").clone();
p.getInventory().addItem(items);
p.sendMessage(main.prefix + "当前金币余额为: §6$" + (int) DemonAPI.seeMoney(p) + ".0");
p.sendMessage(main.prefix + "购买成功! 你获得了: " + items.getItemMeta().getDisplayName() + "§7§lx§f" + items.getAmount());
p.playSound(p.getLocation(), Sound.BLOCK_LEVER_CLICK, 1, 2);
yml.set("Items." + key, null);
main.KeyList.remove(key);
main.saveDataStatsConfig();
//储存收益数据
// BankAPI.addMoney(playName, Money);
Player dj_player = Bukkit.getPlayer(playName);
if (dj_player != null) {
dj_player.sendMessage(main.prefix + "玩家 §a" + p.getName() + " §f拍下了您上架的 §r" + items.getItemMeta().getDisplayName() + "§7§lx§f" + items.getAmount());
}
// 买下拍卖品的事件监听
MarketTradeEvent event = new MarketTradeEvent(p, Money, items);
Bukkit.getPluginManager().callEvent(event);
} else {
p.sendMessage(main.prefix + "你需要§6$" + new DecimalFormat(",###.##").format(Money) + "金币§f才能拍下此商品");
p.playSound(p.getLocation(), Sound.ENTITY_VILLAGER_NO, 1, 2);
}
}
//拍下物品
public static void DeleteItemEvent(Player p, String key) {
if (main.DataG.getString("Items." + key + ".Item") == null) {
p.sendMessage(main.prefix + "很抱歉,其他玩家抢先一步拍走了这个珍贵的商品!");
p.playSound(p.getLocation(), Sound.BLOCK_LEVER_CLICK, 1, 2);
return;
}
FileConfiguration yml = main.DataG;
String str = "Items." + key + ".";
ItemStack items = yml.getItemStack(str + "Item").clone();
p.getInventory().addItem(items);
p.playSound(p.getLocation(), Sound.BLOCK_LEVER_CLICK, 1, 2);
yml.set("Items." + key, null);
main.KeyList.remove(key);
main.saveDataStatsConfig();
}
public static List<String> New_KeyList(String type) {
List<String> stringList = new ArrayList<>();
for (String key : main.KeyList) {
ItemStack items = main.DataG.getItemStack("Items." + key + ".Item");
String typeName = items.getType().name();
if (type.equalsIgnoreCase("方块")) {
if (items.getType().isBlock()) {
stringList.add(key);
}
} else if (main.getItemType.get(type) != null && main.getItemType.get(type).contains(typeName)) {
stringList.add(key);
} else {
String item_Type = main.DataG.getString("Items." + key + ".ItemType");
if (item_Type.equalsIgnoreCase(type)) {
stringList.add(key);
}
}
}
return stringList;
}
}

View File

@ -0,0 +1,39 @@
package me.demon.market;
import org.bukkit.Bukkit;
import org.bukkit.inventory.ItemStack;
public class TimeCheckRunnable {
//拍卖行倒计时
public static void Check_Market_Time(){
int amount = 0;
for (String key : main.DataG.getConfigurationSection("Items").getKeys(false)) {
String str = "Items." + key + ".";
//获取剩余下架时间
int ShelfTime = main.DataG.getInt(str + "ShelfTime");
//如果下架时间小于10分钟则进行下架处理
if(ShelfTime >= 1){
//时间扣除1分钟
main.DataG.set(str+"ShelfTime",(ShelfTime-1));
main.saveDataStatsConfig();
}else{
amount = amount + 1;
//获取出售玩家名
String playName = main.DataG.getString(str + "Seller");
//获取这个物品
ItemStack items = main.DataG.getItemStack(str+"Item");
// 将玩家物品退回邮箱
// DMailAPI.GiveItem(playName,items);
// 将玩家物品退回邮箱
//清理全球市场的价格
main.DataG.set("Items." + key, null);
//清理KeyList中的数据
main.KeyList.remove(key);
main.saveDataStatsConfig();
}
}
if(amount >= 1) {
Bukkit.getConsoleSender().sendMessage("§e[DemonMarket] §r本次总计 §6" + amount + "个 §r拍卖品被自动下架。");
}
}
}

View File

@ -0,0 +1,54 @@
package me.demon.market.Util;
import me.Demon.DemonPlugin.DemonAPI;
import me.demon.market.Event.DyhMarketEvent;
import me.demon.market.main;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import java.util.List;
public class MkEvant {
public static void CreateShopItems(Player p, ItemStack item, int Price) {
int Key = DemonAPI.getRandomInt(900000, 100000);
FileConfiguration yml = main.DataG;
if (main.KeyList.contains(String.valueOf(Key))) {
p.sendMessage(main.prefix + "§c上架時出現了點錯誤,請重新上架.");
return;
}
ItemStack items = item.clone();
yml.set("Items." + Key + ".Money", Price);
yml.set("Items." + Key + ".ItemType", getItemType(items));
yml.set("Items." + Key + ".Seller", p.getName());
int time = 7200;
yml.set("Items." + Key + ".ShelfTime", time);
yml.set("Items." + Key + ".Item", items);
main.saveDataStatsConfig();
main.KeyList.add(String.valueOf(Key));
p.getInventory().setItemInHand(new ItemStack(Material.AIR));
p.sendMessage(main.prefix + "成功將手持物品以§6$" + Price + "金幣§f的價格上架到§6全球貿易行§f中.");
p.playSound(p.getLocation(), Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1, 2);
// 上架拍卖品的事件监听
DyhMarketEvent event = new DyhMarketEvent(p, Price, items);
Bukkit.getPluginManager().callEvent(event);
}
public static String getItemType(ItemStack item) {
for (String Type_Name : main.getItemType.keySet()) {
List<String> list = main.getItemType.get(Type_Name);
if (list.contains(item.getType().name())) {
return Type_Name;
}
}
if (item.getType().isBlock()) {
return "方块";
}
return "杂项";
}
}

View File

@ -0,0 +1,149 @@
package me.demon.market.Util;
import me.Demon.DemonPlugin.DemonAPI;
import me.Demon.DemonPlugin.Util.ItemNameUtil;
import me.demon.market.main;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemFlag;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
public class uItems {
public static ItemStack glass(String name) {
ItemStack item = new ItemStack(160, 1, (short) 15);
ItemMeta meta = item.getItemMeta();
meta.setDisplayName(name);
item.setItemMeta(meta);
return item;
}
public static String getItemName(ItemStack item) {
ItemStack items = item.clone();
String name = "AIR";
ItemMeta meta = items.getItemMeta();
if (meta.getDisplayName() == null) {
name = ItemNameUtil.getChineseName(items);
} else {
name = meta.getDisplayName();
}
return name;
}
public static ItemStack ShopItemsSell(String playName, ItemStack items, String Key, String Type, int Price, int ShelfTime) {
String money = "§6$" + new DecimalFormat(",###.##").format(Price) + "金币";
ItemStack item = items.clone();
ItemMeta meta = item.getItemMeta();
String itemName = getItemName(item);
meta.setDisplayName("§b" + itemName + "§7(§r§f#" + Key + "§7)");
List<String> lore = new ArrayList<>();
if (!DemonAPI.itemIsLore(item)) {
lore.addAll(Objects.requireNonNull(Objects.requireNonNull(items.getItemMeta()).getLore()));
}
lore.add("§7-------------------------");
lore.add("§a§l* §7出售价格: " + money);
lore.add("§a§l* §7出售数量: §f" + item.getAmount() + "");
lore.add("§a§l* §7物品主人: §f" + playName);
lore.add("§a§l* §7下架时间: §f" + main.MinutesToCountdown(ShelfTime));
lore.add(" ");
lore.add("§e§l* §b左键双击 §7拍下此商品");
meta.setLore(lore);
meta.addItemFlags(ItemFlag.HIDE_ATTRIBUTES);
meta.addItemFlags(ItemFlag.HIDE_UNBREAKABLE);
meta.addItemFlags(ItemFlag.HIDE_POTION_EFFECTS);
item.setItemMeta(meta);
return item;
}
public static ItemStack 管理商品() {
ItemStack item = new ItemStack(Material.CHEST);
ItemMeta meta = item.getItemMeta();
meta.setDisplayName("§8« §b管理上架物品 §8»");
List<String> lore = new ArrayList<>();
lore.add(" §a§l★ §7点击打开 §a§l★");
meta.setLore(lore);
item.setItemMeta(meta);
return item;
}
public static ItemStack 出售商品() {
ItemStack item = new ItemStack(Material.COOKED_FISH);
ItemMeta meta = item.getItemMeta();
meta.setDisplayName("§c如何在§6贸易市场§c上架商品");
List<String> lore = new ArrayList<>();
lore.add("§7将物品拿在手上");
lore.add("§f输入命令§7“§e/pdd sell 价格§7”");
lore.add("§8上架手续费: §72%");
lore.add("§c如何将商品下架");
lore.add("§7点击左下角§b管理按钮§7即可下架商品");
meta.setLore(lore);
item.setItemMeta(meta);
return item;
}
public static ItemStack 排序方式(Player p) {
ItemStack item = new ItemStack(Material.NETHER_STAR);
ItemMeta meta = item.getItemMeta();
meta.setDisplayName("§8« §e刷新市场 §8»");
List<String> lore = new ArrayList<>();
lore.add("§a§l★§7已上架: §6" + main.getUpMarketAmount(p.getName()) + "");
lore.add("§b§l★§7可上架: §c" + (main.getupSellAmount(p) - main.getUpMarketAmount(p.getName())) + "");
lore.add("§e§l★§7物品总数: §6" + main.KeyList.size() + "");
lore.add("§a§l★ §7点击刷新 §a§l★");
meta.setLore(lore);
item.setItemMeta(meta);
return item;
}
public static ItemStack 商品分类() {
ItemStack item = new ItemStack(Material.REDSTONE);
ItemMeta meta = item.getItemMeta();
meta.setDisplayName("§8« §d商品分类 §8»");
List<String> lore = new ArrayList<>();
lore.add("§a§l★ §7点击打开 §a§l★");
meta.setLore(lore);
item.setItemMeta(meta);
return item;
}
public static ItemStack 贸易日志() {
ItemStack item = new ItemStack(Material.BOOK_AND_QUILL);
ItemMeta meta = item.getItemMeta();
meta.setDisplayName(" §8« §e市场交易日志 §8»");
List<String> lore = new ArrayList<>();
lore.add("§a§l★ §7左键查看购买记录 §a§l★");
lore.add("§a§l★ §7右键查看出售记录 §a§l★");
meta.setLore(lore);
item.setItemMeta(meta);
return item;
}
public static ItemStack Paper_Butt(String name) {
ItemStack item = new ItemStack(Material.ARROW);
ItemMeta meta = item.getItemMeta();
meta.setDisplayName(name);
List<String> lore = new ArrayList<>();
lore.add("§a§l★ §7点击翻页 §a§l★");
meta.setLore(lore);
item.setItemMeta(meta);
return item;
}
public static ItemStack 返回上一页() {
ItemStack item = new ItemStack(Material.IRON_DOOR);
ItemMeta meta = item.getItemMeta();
meta.setDisplayName("§8« §a返回上一页 §8»");
List<String> lore = new ArrayList<>();
lore.add("§a§l★ §7点击返回主页 §a§l★");
meta.setLore(lore);
item.setItemMeta(meta);
return item;
}
}

View File

@ -0,0 +1,276 @@
package me.demon.market;
import me.Demon.DemonPlugin.DemonAPI;
import me.demon.market.Gui.AdminGui;
import me.demon.market.Gui.CategoryCreate;
import me.demon.market.Gui.ItemTypeGui;
import me.demon.market.MGui.*;
import me.demon.market.Util.MkEvant;
import org.bukkit.Bukkit;
import org.bukkit.Sound;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.event.Listener;
import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.java.JavaPlugin;
import java.io.File;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.*;
public class main extends JavaPlugin implements Listener {
public static String pluginName = "魂式市场";
public static main plugin;
public static String prefix = "§7[§6拼刀刀§7] §f";
public static HashMap<String, List<String>> getItemType = new HashMap<>();
public static List<String> KeyList = new ArrayList<>();
public static List<String> BlackNoItemList = new ArrayList<>();
@Override
public void onEnable() {
plugin = this;
saveDefaultConfig();
BlackNoItemList.addAll(getConfig().getStringList("Settings.BlackNoItemList"));
if (main.DataG.getConfigurationSection("Items") != null) {
KeyList.addAll(Objects.requireNonNull(main.DataG.getConfigurationSection("Items")).getKeys(false));
Bukkit.getConsoleSender().sendMessage("§6[" + pluginName + "] §f载入市场物品: " + KeyList.size() + "");
}
int type_a = 0;
for (String Type_Name : CategoryG.getKeys(false)) {
List<String> item_list = CategoryG.getStringList(Type_Name);
type_a = type_a + item_list.size();
getItemType.put(Type_Name, item_list);
}
Bukkit.getConsoleSender().sendMessage("§6[" + pluginName + "] §f载入分类物品: " + type_a + "");
Bukkit.getServer().getPluginManager().registerEvents(new Market_Default(), plugin);
Bukkit.getServer().getPluginManager().registerEvents(new Market_方块(), plugin);
Bukkit.getServer().getPluginManager().registerEvents(new Market_防具(), plugin);
Bukkit.getServer().getPluginManager().registerEvents(new Market_武器(), plugin);
Bukkit.getServer().getPluginManager().registerEvents(new Market_食物(), plugin);
Bukkit.getServer().getPluginManager().registerEvents(new Market_工具(), plugin);
Bukkit.getServer().getPluginManager().registerEvents(new Market_交通(), plugin);
Bukkit.getServer().getPluginManager().registerEvents(new Market_药水(), plugin);
Bukkit.getServer().getPluginManager().registerEvents(new Market_杂项(), plugin);
Bukkit.getServer().getPluginManager().registerEvents(new Market_红石(), plugin);
Bukkit.getServer().getPluginManager().registerEvents(new AdminGui(), plugin);
Bukkit.getServer().getPluginManager().registerEvents(new ItemTypeGui(), plugin);
Bukkit.getServer().getPluginManager().registerEvents(new CategoryCreate(), plugin);
Bukkit.getConsoleSender().sendMessage("§6[" + pluginName + "] §f插件加载成功");
Bukkit.getConsoleSender().sendMessage("§6[" + pluginName + "] §f作者QQ:1763917516");
Bukkit.getScheduler().scheduleSyncRepeatingTask(this, new Runnable() {
@Override
public void run() {
TimeCheckRunnable.Check_Market_Time();
}
}, 0, 1200L);
}
public void onDisable() {
KeyList.clear();
Bukkit.getConsoleSender().sendMessage("§6[" + pluginName + "] §f市场数据已保存。");
Bukkit.getConsoleSender().sendMessage("§6[" + pluginName + "] §f插件已安全卸载");
}
public static String MinutesToCountdown(int Minutes) {
if (Minutes == 0) {
return "0天0时0分";
}
int day = 24 * 60;
int hour = 60;
int remainder = 0;
int integer = 0;
StringBuilder sb = new StringBuilder();
integer = Minutes / day;
remainder = Minutes % day;
sb.append(integer).append("");
integer = remainder / hour;
remainder = remainder % hour;
sb.append(integer).append("").append(remainder).append("");
return sb.toString();
}
public boolean onCommand(CommandSender sender, Command cmd, String Command, String[] args) {
if (Command.equalsIgnoreCase("gsitem") && sender.isOp()) {
if (args.length == 0) {
sender.sendMessage("");
sender.sendMessage("§e------- ======= §6全球贸易市场 §e======= -------");
sender.sendMessage("§2/gsitem [分类名] §f- §2设置物品分类");
sender.sendMessage("§e------- ======= §6全球贸易市场 §e======= -------");
}
if (args.length == 1) {
Player p = (Player) sender;
CategoryCreate.OpenItemsGui(p, args[0]);
}
return true;
}
if (Command.equalsIgnoreCase("pdd")) {
if (args.length == 0) {
Player p = (Player) sender;
Market_Default.OpenGui(p, 1);
p.playSound(p.getLocation(), Sound.BLOCK_CHEST_OPEN, 0.5F, 1.0F);
/*sender.sendMessage("§8====================§b§l全球贸易市场§8====================");
sender.sendMessage("§a/gs open §8§l-----§c打开全球贸易市场");
sender.sendMessage("§a/gs amount §8§l-----§c查看当前最多上架多少个物品");
sender.sendMessage("§a/gs sell <价格> §8§l-----§c将手持物品以金币形式上架");
sender.sendMessage("§c价格:§a上架商品的出售价格");
sender.sendMessage("§c手续费说明:§a免手续费");*/
}
if (args.length == 1) {
if (args[0].equalsIgnoreCase("amount")) {
Player p = (Player) sender;
sender.sendMessage(prefix + "当前已上架 §e" + getUpMarketAmount(p.getName()) + " §f个物品");
sender.sendMessage(prefix + "还可以上架 §e" + (getupSellAmount(p) - getUpMarketAmount(p.getName())) + " §f个物品");
}
if (args[0].equalsIgnoreCase("open")) {
Player p = (Player) sender;
Market_Default.OpenGui(p, 1);
p.playSound(p.getLocation(), Sound.BLOCK_CHEST_OPEN, 0.5F, 1.0F);
}
if (args[0].equalsIgnoreCase("ceshi") && sender.isOp()) {
TimeCheckRunnable.Check_Market_Time();
}
if (args[0].equalsIgnoreCase("sell")) {
sender.sendMessage(prefix + "正确用法: §a/pdd sell [价格]");
return true;
}
}
if (args.length == 2) {
Player p = (Player) sender;
ItemStack item = p.getInventory().getItemInHand();
if (args[0].equalsIgnoreCase("sell")) {
if (!DemonAPI.itemIsNull(item)) {
if (itemIsBind(item)) {
p.sendMessage(prefix + "§c当前物品无法进行交易,请检查是否存在绑定.");
return true;
}
if (item.getAmount() >= 1) {
int money = Integer.parseInt(args[1]);
if (money < 10) {
p.sendMessage(prefix + "商品价格不能低于§6$10金币§f请重新设置价格.");
return true;
}
if (money >= 100000000) {
p.sendMessage(prefix + "上架物品不能高于§6$10,000万§f请重新设置价格.");
return true;
}
int amount = getupSellAmount(p);
if (amount <= 0) {
p.sendMessage(prefix + "你需要成为 §2【领域农民】 §f才能使用此命令.");
return true;
}
if (getUpMarketAmount(p.getName()) <= amount) {
int tax = (int) (money * 0.02);
if (!DemonAPI.hasMoney(p, tax)) {
p.sendMessage(prefix + "你需要先支付§6$" + tax + "§f手续费才能上架.");
return true;
}
DemonAPI.takeMoney(p, tax);
MkEvant.CreateShopItems(p, item, money);
} else {
sender.sendMessage(prefix + "§c你最多可以在全球贸易行上架 §e" + amount + " §c件商品。§7(提升阶级可增加数量)");
}
}
} else {
sender.sendMessage(prefix + "§c请手持物品后再尝试上架。");
}
}
}
}
return false;
}
public static int getupSellAmount(Player p) {
int amount = -1;
if (p.hasPermission("vip2.use")) {
amount = 10;
} else if (p.hasPermission("vip1.use")) {
amount = 8;
} else if (p.hasPermission("yuanzu.use")) {
amount = 8;
} else if (p.hasPermission("lianjinshi.use")) {
amount = 6;
} else if (p.hasPermission("shangren.use")) {
amount = 4;
} else if (p.hasPermission("nongmin.use")) {
amount = 2;
}
return amount;
}
public static boolean itemIsBind(ItemStack item) {
boolean butt = false;
if (!DemonAPI.itemIsLore(item)) {
for (int i = 0; i < BlackNoItemList.size(); i++) {
if (item.getItemMeta().getLore().contains(BlackNoItemList.get(i))) {
butt = true;
}
}
for (String str : item.getItemMeta().getLore()) {
if (str.startsWith("§c装备绑定: §e")) {
butt = true;
}
}
}
return butt;
}
public static boolean isInt(String s) {
try {
Integer.parseInt(s);
} catch (NumberFormatException nfe) {
return false;
}
return true;
}
public static String getTime(String format) {
Date date = Calendar.getInstance().getTime();
SimpleDateFormat datatime = new SimpleDateFormat(format);
return datatime.format(date);
}
//获取玩家已上架数量
public static int getUpMarketAmount(String playName) {
int amount = 0;
for (String key : Objects.requireNonNull(main.DataG.getConfigurationSection("Items")).getKeys(false)) {
String pName = main.DataG.getString("Items." + key + ".Seller");
assert pName != null;
if (pName.equalsIgnoreCase(playName)) {
amount = amount + 1;
}
}
return amount;
}
public static File Datafile = new File("plugins/DemonMarket", "Data.yml");
public static FileConfiguration DataG = YamlConfiguration.loadConfiguration(Datafile);
public static void saveDataStatsConfig() {
try {
main.DataG.save(Datafile);
} catch (IOException e) {
e.printStackTrace();
}
}
// 分类管理
public static File Categoryfile = new File("plugins/DemonMarket", "Category.yml");
public static FileConfiguration CategoryG = YamlConfiguration.loadConfiguration(Categoryfile);
public static void saveCategoryConfig() {
try {
main.CategoryG.save(Categoryfile);
} catch (IOException e) {
e.printStackTrace();
}
}
}

View File

@ -0,0 +1 @@
ItemType: {}

View File

@ -0,0 +1,20 @@
Items:
'635255':
Type: Points
Money: 50
Seller: 大炒面制造者cen
ShelfTime: '2021-11-20'
Item:
==: org.bukkit.inventory.ItemStack
type: PRISMARINE_SHARD
amount: 8
meta:
==: ItemMeta
meta-type: UNSPECIFIC
display-name: §e§l魂环核心
lore:
- §a§l★§7用于打造装备的材料
- §r
- '§7获取方式:'
- §7通过分解§b[十、百、千]§7年魂环获得
internal: H4sIAAAAAAAAAONiYOBgYCkuSa1g4Hm5tul53/pnC3Y83d/MAABR4lU0GQAAAA==

View File

@ -0,0 +1,17 @@
Settings:
MoneyItemList:
- "§e§l精§b§l美§e§l时§b§l装§e§l币"
- "§7§l厄运之戒"
- "§e§l斗罗封号§c§l宝典"
- "§6随机武魂抽奖箱"
- "§9双生武魂抽奖箱"
BlackNoItemList:
- "§7§o食物"
- "§e服务器赠送给初级魂师的装备"
- "§a§l✔§7手持右键使用此券"
- "§7斗罗帝国通用货币"
- "§a§l★§7通过§6集字挑战§7活动获得"
MarketLog:
虎牙妖魂吖:
- §7[§c贸易日志§7] §e02:41§f玩家§aYao_Hun_Ya§f拍下了§b§l钻石甲§7(§9价值:250000.0金币§7)
- §7[§c贸易日志§7] §e02:46§f玩家§aYao_Hun_Ya§f拍下了§b§l钻石甲§7(§9价值:250000.0金币§7)

View File

@ -0,0 +1,7 @@
name: DemonMarket
main: me.Demon.DemonMarket.Main
version: 1.0.1
depend: [DemonAPI , DemonBanK , DemonPlayerMail]
commands:
pdd:
gsitem: