mirror of
https://github.com/CarmJos/UltraDepository.git
synced 2026-06-04 16:48:21 +08:00
添加声音配置
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
package cc.carm.plugin.ultradepository.command;
|
package cc.carm.plugin.ultradepository.command;
|
||||||
|
|
||||||
import cc.carm.plugin.ultradepository.Main;
|
import cc.carm.plugin.ultradepository.Main;
|
||||||
|
import cc.carm.plugin.ultradepository.configuration.PluginConfig;
|
||||||
import cc.carm.plugin.ultradepository.configuration.PluginMessages;
|
import cc.carm.plugin.ultradepository.configuration.PluginMessages;
|
||||||
import cc.carm.plugin.ultradepository.configuration.depository.Depository;
|
import cc.carm.plugin.ultradepository.configuration.depository.Depository;
|
||||||
import cc.carm.plugin.ultradepository.configuration.depository.DepositoryItem;
|
import cc.carm.plugin.ultradepository.configuration.depository.DepositoryItem;
|
||||||
@@ -64,18 +65,21 @@ public class DepositoryCommand implements CommandExecutor, TabCompleter {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!Main.getEconomyManager().isInitialized()) {
|
if (!Main.getEconomyManager().isInitialized()) {
|
||||||
|
PluginConfig.Sounds.SELL_FAIL.play(player);
|
||||||
PluginMessages.NO_ECONOMY.send(player);
|
PluginMessages.NO_ECONOMY.send(player);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (args.length < 4) return helpPlayer(player);
|
if (args.length < 4) return helpPlayer(player);
|
||||||
Depository depository = Main.getDepositoryManager().getDepository(args[1]);
|
Depository depository = Main.getDepositoryManager().getDepository(args[1]);
|
||||||
if (depository == null) {
|
if (depository == null) {
|
||||||
|
PluginConfig.Sounds.SELL_FAIL.play(player);
|
||||||
PluginMessages.NO_DEPOSITORY.send(player);
|
PluginMessages.NO_DEPOSITORY.send(player);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
DepositoryItem item = depository.getItems().get(args[2]);
|
DepositoryItem item = depository.getItems().get(args[2]);
|
||||||
if (item == null) {
|
if (item == null) {
|
||||||
|
PluginConfig.Sounds.SELL_FAIL.play(player);
|
||||||
PluginMessages.NO_ITEM.send(player);
|
PluginMessages.NO_ITEM.send(player);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -86,6 +90,7 @@ public class DepositoryCommand implements CommandExecutor, TabCompleter {
|
|||||||
} catch (Exception ignore) {
|
} catch (Exception ignore) {
|
||||||
}
|
}
|
||||||
if (amount <= 0) {
|
if (amount <= 0) {
|
||||||
|
PluginConfig.Sounds.SELL_FAIL.play(player);
|
||||||
PluginMessages.WRONG_NUMBER.send(player);
|
PluginMessages.WRONG_NUMBER.send(player);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -97,16 +102,18 @@ public class DepositoryCommand implements CommandExecutor, TabCompleter {
|
|||||||
int currentAmount = itemData.getAmount();
|
int currentAmount = itemData.getAmount();
|
||||||
|
|
||||||
if (currentAmount < amount) {
|
if (currentAmount < amount) {
|
||||||
|
PluginConfig.Sounds.SELL_FAIL.play(player);
|
||||||
PluginMessages.NO_ENOUGH_ITEM.send(player);
|
PluginMessages.NO_ENOUGH_ITEM.send(player);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (currentAmount > (limit - sold)) {
|
if (currentAmount > (limit - sold)) {
|
||||||
|
PluginConfig.Sounds.SELL_FAIL.play(player);
|
||||||
PluginMessages.ITEM_SOLD_LIMIT.send(player, new Object[]{(limit - sold), limit});
|
PluginMessages.ITEM_SOLD_LIMIT.send(player, new Object[]{(limit - sold), limit});
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
sellItem(player, userData, itemData, amount);
|
Main.getEconomyManager().sellItem(player, userData, itemData, amount);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
case "sellall": {
|
case "sellall": {
|
||||||
@@ -114,6 +121,7 @@ public class DepositoryCommand implements CommandExecutor, TabCompleter {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!Main.getEconomyManager().isInitialized()) {
|
if (!Main.getEconomyManager().isInitialized()) {
|
||||||
|
PluginConfig.Sounds.SELL_FAIL.play(player);
|
||||||
PluginMessages.NO_ECONOMY.send(player);
|
PluginMessages.NO_ECONOMY.send(player);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -126,15 +134,14 @@ public class DepositoryCommand implements CommandExecutor, TabCompleter {
|
|||||||
if (depositoryID != null) {
|
if (depositoryID != null) {
|
||||||
depository = Main.getDepositoryManager().getDepository(depositoryID);
|
depository = Main.getDepositoryManager().getDepository(depositoryID);
|
||||||
if (depository == null) {
|
if (depository == null) {
|
||||||
|
PluginConfig.Sounds.SELL_FAIL.play(player);
|
||||||
PluginMessages.NO_DEPOSITORY.send(player);
|
PluginMessages.NO_DEPOSITORY.send(player);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (depository == null) {
|
if (depository == null) {
|
||||||
userData.getDepositories().values().stream()
|
Main.getEconomyManager().sellAllItem(player, userData);
|
||||||
.flatMap(depositoryData -> depositoryData.getContents().values().stream())
|
|
||||||
.forEach(itemData -> sellAllItem(player, userData, itemData));
|
|
||||||
sender.sendMessage("Success! " + player.getName() + "'s items had been sold.");
|
sender.sendMessage("Success! " + player.getName() + "'s items had been sold.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -143,18 +150,18 @@ public class DepositoryCommand implements CommandExecutor, TabCompleter {
|
|||||||
if (itemID != null) {
|
if (itemID != null) {
|
||||||
item = depository.getItems().get(itemID);
|
item = depository.getItems().get(itemID);
|
||||||
if (item == null) {
|
if (item == null) {
|
||||||
|
PluginConfig.Sounds.SELL_FAIL.play(player);
|
||||||
PluginMessages.NO_ITEM.send(player);
|
PluginMessages.NO_ITEM.send(player);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (item == null) {
|
if (item == null) {
|
||||||
userData.getDepositoryData(depository).getContents().values()
|
Main.getEconomyManager().sellAllItem(player, userData, userData.getDepositoryData(depositoryID));
|
||||||
.forEach(itemData -> sellAllItem(player, userData, itemData));
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
sellAllItem(player, userData, userData.getItemData(item));
|
Main.getEconomyManager().sellAllItem(player, userData, userData.getItemData(item));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
@@ -334,9 +341,7 @@ public class DepositoryCommand implements CommandExecutor, TabCompleter {
|
|||||||
UserData userData = Main.getUserManager().getData(player);
|
UserData userData = Main.getUserManager().getData(player);
|
||||||
|
|
||||||
if (depository == null) {
|
if (depository == null) {
|
||||||
userData.getDepositories().values().stream()
|
Main.getEconomyManager().sellAllItem(player, userData);
|
||||||
.flatMap(depositoryData -> depositoryData.getContents().values().stream())
|
|
||||||
.forEach(itemData -> sellAllItem(player, userData, itemData));
|
|
||||||
sender.sendMessage("Success! " + player.getName() + "'s items had been sold.");
|
sender.sendMessage("Success! " + player.getName() + "'s items had been sold.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -349,10 +354,8 @@ public class DepositoryCommand implements CommandExecutor, TabCompleter {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (item == null) {
|
if (item == null) {
|
||||||
userData.getDepositoryData(depository).getContents().values()
|
Main.getEconomyManager().sellAllItem(player, userData, userData.getDepositoryData(depository));
|
||||||
.forEach(itemData -> sellAllItem(player, userData, itemData));
|
|
||||||
sender.sendMessage("Success! " + player.getName() + "'s " + depository.getIdentifier() + " had been sold.");
|
sender.sendMessage("Success! " + player.getName() + "'s " + depository.getIdentifier() + " had been sold.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -371,10 +374,11 @@ public class DepositoryCommand implements CommandExecutor, TabCompleter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (amount == null) {
|
if (amount == null) {
|
||||||
sellAllItem(player, userData, userData.getItemData(item));
|
Main.getEconomyManager().sellAllItem(player, userData, userData.getItemData(item));
|
||||||
sender.sendMessage("Success! " + player.getName() + "'s " + item.getTypeID() + " had been sold.");
|
sender.sendMessage("Success! " + player.getName() + "'s " + item.getTypeID() + " had been sold.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
DepositoryItemData itemData = userData.getItemData(item);
|
DepositoryItemData itemData = userData.getItemData(item);
|
||||||
|
|
||||||
int limit = item.getLimit();
|
int limit = item.getLimit();
|
||||||
@@ -391,7 +395,7 @@ public class DepositoryCommand implements CommandExecutor, TabCompleter {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
sellItem(player, userData, userData.getItemData(item), amount);
|
Main.getEconomyManager().sellItem(player, userData, userData.getItemData(item), amount);
|
||||||
sender.sendMessage("Success! " + player.getName() + "'s " + amount + " " + item.getTypeID() + " had been sold.");
|
sender.sendMessage("Success! " + player.getName() + "'s " + amount + " " + item.getTypeID() + " had been sold.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -401,22 +405,6 @@ public class DepositoryCommand implements CommandExecutor, TabCompleter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void sellAllItem(Player player, UserData userData, DepositoryItemData itemData) {
|
|
||||||
int amount = itemData.getAmount();
|
|
||||||
int sold = itemData.getSold();
|
|
||||||
int limit = itemData.getSource().getLimit();
|
|
||||||
int finalAmount = Math.min(amount, (limit - sold));
|
|
||||||
if (finalAmount > 0) {
|
|
||||||
sellItem(player, userData, itemData, finalAmount);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void sellItem(Player player, UserData userData, DepositoryItemData itemData, int amount) {
|
|
||||||
userData.addItemSold(itemData.getOwner().getSource().getIdentifier(), itemData.getSource().getTypeID(), amount);
|
|
||||||
userData.removeItemAmount(itemData.getOwner().getSource().getIdentifier(), itemData.getSource().getTypeID(), amount);
|
|
||||||
double money = Main.getEconomyManager().sell(player, itemData.getSource().getPrice(), amount);
|
|
||||||
PluginMessages.SOLD.send(player, new Object[]{itemData.getSource().getName(), amount, money});
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package cc.carm.plugin.ultradepository.configuration;
|
|||||||
|
|
||||||
import cc.carm.plugin.ultradepository.configuration.message.ConfigMessage;
|
import cc.carm.plugin.ultradepository.configuration.message.ConfigMessage;
|
||||||
import cc.carm.plugin.ultradepository.configuration.message.ConfigMessageList;
|
import cc.carm.plugin.ultradepository.configuration.message.ConfigMessageList;
|
||||||
|
import cc.carm.plugin.ultradepository.configuration.values.ConfigSound;
|
||||||
import cc.carm.plugin.ultradepository.configuration.values.ConfigStringCast;
|
import cc.carm.plugin.ultradepository.configuration.values.ConfigStringCast;
|
||||||
import cc.carm.plugin.ultradepository.configuration.values.ConfigValue;
|
import cc.carm.plugin.ultradepository.configuration.values.ConfigValue;
|
||||||
import cc.carm.plugin.ultradepository.manager.ConfigManager;
|
import cc.carm.plugin.ultradepository.manager.ConfigManager;
|
||||||
@@ -36,6 +37,14 @@ public class PluginConfig {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static class Sounds {
|
||||||
|
|
||||||
|
public static final ConfigSound COLLECT = new ConfigSound("sounds.collect");
|
||||||
|
public static final ConfigSound SELL_SUCCESS = new ConfigSound("sell-success");
|
||||||
|
public static final ConfigSound SELL_FAIL = new ConfigSound("sell-fail");
|
||||||
|
public static final ConfigSound GUI_CLICK = new ConfigSound("gui-click");
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 通用配置
|
* 通用配置
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -0,0 +1,72 @@
|
|||||||
|
package cc.carm.plugin.ultradepository.configuration.values;
|
||||||
|
|
||||||
|
import cc.carm.plugin.ultradepository.Main;
|
||||||
|
import cc.carm.plugin.ultradepository.configuration.file.FileConfig;
|
||||||
|
import cc.carm.plugin.ultradepository.manager.ConfigManager;
|
||||||
|
import org.bukkit.Sound;
|
||||||
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
public class ConfigSound {
|
||||||
|
|
||||||
|
|
||||||
|
FileConfig source;
|
||||||
|
String configSection;
|
||||||
|
|
||||||
|
Sound defaultValue;
|
||||||
|
|
||||||
|
public ConfigSound(String configSection) {
|
||||||
|
this(configSection, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ConfigSound(String configSection, Sound defaultValue) {
|
||||||
|
this(ConfigManager.getPluginConfig(), configSection, defaultValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ConfigSound(FileConfig source, String configSection, Sound defaultValue) {
|
||||||
|
this.source = source;
|
||||||
|
this.configSection = configSection;
|
||||||
|
this.defaultValue = defaultValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public FileConfiguration getConfiguration() {
|
||||||
|
return this.source.getConfig();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void set(Sound value, float volume) {
|
||||||
|
getConfiguration().set(this.configSection, value.name() + ":" + volume);
|
||||||
|
this.save();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void set(Sound value, float volume, float pitch) {
|
||||||
|
getConfiguration().set(this.configSection, value.name() + ":" + volume + ":" + pitch);
|
||||||
|
this.save();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void play(Player player) {
|
||||||
|
Sound finalSound = defaultValue;
|
||||||
|
float pitch = 1;
|
||||||
|
float volume = 1;
|
||||||
|
String soundString = getConfiguration().getString(this.configSection);
|
||||||
|
if (soundString != null) {
|
||||||
|
String[] args = soundString.contains(":") ? soundString.split(":") : new String[]{soundString};
|
||||||
|
try {
|
||||||
|
if (args.length >= 1) finalSound = Sound.valueOf(args[0]);
|
||||||
|
if (args.length >= 2) volume = Float.parseFloat(args[1]);
|
||||||
|
if (args.length >= 3) volume = Float.parseFloat(args[2]);
|
||||||
|
} catch (Exception exception) {
|
||||||
|
Main.log("声音 " + this.configSection + " 配置错误,不存在 " + soundString + " ,请检查。");
|
||||||
|
Main.log("In " + this.configSection + " (" + soundString + ") doesn't match any sound name.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (finalSound != null) {
|
||||||
|
player.playSound(player.getLocation(), finalSound, volume, pitch);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void save() {
|
||||||
|
this.source.save();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
package cc.carm.plugin.ultradepository.manager;
|
package cc.carm.plugin.ultradepository.manager;
|
||||||
|
|
||||||
import cc.carm.plugin.ultradepository.Main;
|
import cc.carm.plugin.ultradepository.Main;
|
||||||
|
import cc.carm.plugin.ultradepository.configuration.PluginConfig;
|
||||||
import cc.carm.plugin.ultradepository.configuration.PluginMessages;
|
import cc.carm.plugin.ultradepository.configuration.PluginMessages;
|
||||||
import cc.carm.plugin.ultradepository.configuration.depository.Depository;
|
import cc.carm.plugin.ultradepository.configuration.depository.Depository;
|
||||||
import cc.carm.plugin.ultradepository.configuration.depository.DepositoryItem;
|
import cc.carm.plugin.ultradepository.configuration.depository.DepositoryItem;
|
||||||
@@ -158,6 +159,7 @@ public class DepositoryManager {
|
|||||||
int itemAmount = item.getAmount();
|
int itemAmount = item.getAmount();
|
||||||
data.addItemAmount(depository.getIdentifier(), typeID, itemAmount);
|
data.addItemAmount(depository.getIdentifier(), typeID, itemAmount);
|
||||||
PluginMessages.COLLECTED.send(player, new Object[]{itemName, itemAmount, depository.getName()});
|
PluginMessages.COLLECTED.send(player, new Object[]{itemName, itemAmount, depository.getName()});
|
||||||
|
PluginConfig.Sounds.COLLECT.play(player);
|
||||||
Main.debug("Item collected successfully.");
|
Main.debug("Item collected successfully.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,10 @@
|
|||||||
package cc.carm.plugin.ultradepository.manager;
|
package cc.carm.plugin.ultradepository.manager;
|
||||||
|
|
||||||
|
import cc.carm.plugin.ultradepository.configuration.PluginConfig;
|
||||||
|
import cc.carm.plugin.ultradepository.configuration.PluginMessages;
|
||||||
|
import cc.carm.plugin.ultradepository.data.DepositoryData;
|
||||||
|
import cc.carm.plugin.ultradepository.data.DepositoryItemData;
|
||||||
|
import cc.carm.plugin.ultradepository.data.UserData;
|
||||||
import cc.carm.plugin.ultradepository.hooker.VaultHooker;
|
import cc.carm.plugin.ultradepository.hooker.VaultHooker;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@@ -31,4 +36,49 @@ public class EconomyManager {
|
|||||||
return money;
|
return money;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void sellAllItem(Player player, UserData userData) {
|
||||||
|
sellAllItem(player, userData, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void sellAllItem(Player player, UserData userData, boolean playSound) {
|
||||||
|
userData.getDepositories().values().forEach(depositoryData -> sellAllItem(player, userData, depositoryData, false));
|
||||||
|
if (playSound) PluginConfig.Sounds.SELL_SUCCESS.play(player);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void sellAllItem(Player player, UserData userData, DepositoryData depositoryData) {
|
||||||
|
sellAllItem(player, userData, depositoryData, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void sellAllItem(Player player, UserData userData, DepositoryData depositoryData, boolean playSound) {
|
||||||
|
depositoryData.getContents().values().forEach(value -> sellAllItem(player, userData, value, false));
|
||||||
|
if (playSound) PluginConfig.Sounds.SELL_SUCCESS.play(player);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void sellAllItem(Player player, UserData userData, DepositoryItemData itemData) {
|
||||||
|
sellAllItem(player, userData, itemData, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void sellAllItem(Player player, UserData userData, DepositoryItemData itemData, boolean playSound) {
|
||||||
|
int amount = itemData.getAmount();
|
||||||
|
int sold = itemData.getSold();
|
||||||
|
int limit = itemData.getSource().getLimit();
|
||||||
|
int finalAmount = Math.min(amount, (limit - sold));
|
||||||
|
if (finalAmount > 0) sellItem(player, userData, itemData, finalAmount, false);
|
||||||
|
if (playSound) PluginConfig.Sounds.SELL_SUCCESS.play(player);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void sellItem(Player player, UserData userData, DepositoryItemData itemData, int amount) {
|
||||||
|
sellItem(player, userData, itemData, amount, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void sellItem(Player player, UserData userData, DepositoryItemData itemData, int amount, boolean playSound) {
|
||||||
|
userData.addItemSold(itemData.getOwner().getSource().getIdentifier(), itemData.getSource().getTypeID(), amount);
|
||||||
|
userData.removeItemAmount(itemData.getOwner().getSource().getIdentifier(), itemData.getSource().getTypeID(), amount);
|
||||||
|
double money = sell(player, itemData.getSource().getPrice(), amount);
|
||||||
|
PluginMessages.SOLD.send(player, new Object[]{itemData.getSource().getName(), amount, money});
|
||||||
|
if (playSound) PluginConfig.Sounds.SELL_SUCCESS.play(player);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ package cc.carm.plugin.ultradepository.ui;
|
|||||||
|
|
||||||
import cc.carm.plugin.ultradepository.Main;
|
import cc.carm.plugin.ultradepository.Main;
|
||||||
import cc.carm.plugin.ultradepository.configuration.PluginConfig;
|
import cc.carm.plugin.ultradepository.configuration.PluginConfig;
|
||||||
import cc.carm.plugin.ultradepository.configuration.PluginMessages;
|
|
||||||
import cc.carm.plugin.ultradepository.configuration.depository.Depository;
|
import cc.carm.plugin.ultradepository.configuration.depository.Depository;
|
||||||
import cc.carm.plugin.ultradepository.configuration.depository.DepositoryItem;
|
import cc.carm.plugin.ultradepository.configuration.depository.DepositoryItem;
|
||||||
import cc.carm.plugin.ultradepository.data.DepositoryItemData;
|
import cc.carm.plugin.ultradepository.data.DepositoryItemData;
|
||||||
@@ -11,7 +10,6 @@ import cc.carm.plugin.ultradepository.util.ItemStackFactory;
|
|||||||
import cc.carm.plugin.ultradepository.util.gui.GUI;
|
import cc.carm.plugin.ultradepository.util.gui.GUI;
|
||||||
import cc.carm.plugin.ultradepository.util.gui.GUIItem;
|
import cc.carm.plugin.ultradepository.util.gui.GUIItem;
|
||||||
import cc.carm.plugin.ultradepository.util.gui.GUIType;
|
import cc.carm.plugin.ultradepository.util.gui.GUIType;
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.inventory.ClickType;
|
import org.bukkit.event.inventory.ClickType;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
@@ -85,6 +83,7 @@ public class SellItemGUI extends GUI {
|
|||||||
return new GUIItem(factory.toItemStack()) {
|
return new GUIItem(factory.toItemStack()) {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(ClickType type) {
|
public void onClick(ClickType type) {
|
||||||
|
PluginConfig.Sounds.GUI_CLICK.play(player);
|
||||||
load(getCurrentAmount() + amount);
|
load(getCurrentAmount() + amount);
|
||||||
updateView();
|
updateView();
|
||||||
}
|
}
|
||||||
@@ -103,6 +102,7 @@ public class SellItemGUI extends GUI {
|
|||||||
return new GUIItem(factory.toItemStack()) {
|
return new GUIItem(factory.toItemStack()) {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(ClickType type) {
|
public void onClick(ClickType type) {
|
||||||
|
PluginConfig.Sounds.GUI_CLICK.play(player);
|
||||||
load(getCurrentAmount() - amount);
|
load(getCurrentAmount() - amount);
|
||||||
updateView();
|
updateView();
|
||||||
}
|
}
|
||||||
@@ -122,14 +122,7 @@ public class SellItemGUI extends GUI {
|
|||||||
@Override
|
@Override
|
||||||
public void onClick(ClickType type) {
|
public void onClick(ClickType type) {
|
||||||
int amount = Math.min(getCurrentAmount(), Math.min(getRemainAmount(), getSellLimit() - getSoldAmount()));
|
int amount = Math.min(getCurrentAmount(), Math.min(getRemainAmount(), getSellLimit() - getSoldAmount()));
|
||||||
if (amount > 0) {
|
if (amount > 0) Main.getEconomyManager().sell(player, getItemPrice(), amount);
|
||||||
userData.removeItemAmount(item.getDepository().getIdentifier(), item.getTypeID(), amount);
|
|
||||||
userData.addItemSold(item.getDepository().getIdentifier(), item.getTypeID(), amount);
|
|
||||||
double money = Main.getEconomyManager().sell(player, getItemPrice(), amount);
|
|
||||||
PluginMessages.SOLD.send(player, new Object[]{
|
|
||||||
getItemName(), amount, money
|
|
||||||
});
|
|
||||||
}
|
|
||||||
player.closeInventory();
|
player.closeInventory();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -143,6 +136,7 @@ public class SellItemGUI extends GUI {
|
|||||||
return new GUIItem(factory.toItemStack()) {
|
return new GUIItem(factory.toItemStack()) {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(ClickType type) {
|
public void onClick(ClickType type) {
|
||||||
|
PluginConfig.Sounds.SELL_FAIL.play(player);
|
||||||
player.closeInventory();
|
player.closeInventory();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -35,6 +35,13 @@ collect:
|
|||||||
kill: true #杀死动物
|
kill: true #杀死动物
|
||||||
break: true #破坏方块
|
break: true #破坏方块
|
||||||
|
|
||||||
|
|
||||||
|
sounds:
|
||||||
|
collect: ENTITY_EXPERIENCE_ORB_PICKUP
|
||||||
|
sell-success: ENTITY_VILLAGER_TRADE
|
||||||
|
sell-fail: ENTITY_VILLAGER_NO
|
||||||
|
gui-click: UI_BUTTON_CLICK
|
||||||
|
|
||||||
# 通用配置
|
# 通用配置
|
||||||
general:
|
general:
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user