mirror of
https://gitlab.com/phoenix-dvpmt/mmoitems.git
synced 2024-12-22 04:37:42 +01:00
%player% issue is no more
This commit is contained in:
parent
2447957d15
commit
c4228d62a9
@ -1,7 +1,7 @@
|
||||
package net.Indyuce.mmoitems.api.crafting.trigger;
|
||||
|
||||
import net.Indyuce.mmoitems.api.player.PlayerData;
|
||||
import io.lumine.mythic.lib.api.MMOLineConfig;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerData;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@ -26,20 +26,20 @@ public class CommandTrigger extends Trigger {
|
||||
private void dispatchCommand(Player player, boolean console, boolean op) {
|
||||
|
||||
// Adds back using "%player%" in the command trigger string.
|
||||
command = command.replaceAll("(?i)%player%", player.getName());
|
||||
String parsed = command.replaceAll("(?i)%player%", player.getName());
|
||||
|
||||
if (console) {
|
||||
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), command);
|
||||
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), parsed);
|
||||
return;
|
||||
}
|
||||
|
||||
if (op && !player.isOp()) {
|
||||
player.setOp(true);
|
||||
try {
|
||||
Bukkit.dispatchCommand(player, command);
|
||||
Bukkit.dispatchCommand(player, parsed);
|
||||
} catch (Exception ignored) {}
|
||||
player.setOp(false);
|
||||
} else
|
||||
Bukkit.dispatchCommand(player, command);
|
||||
Bukkit.dispatchCommand(player, parsed);
|
||||
}
|
||||
}
|
||||
|
@ -54,7 +54,7 @@ public class CraftingStationView extends PluginInventory {
|
||||
}
|
||||
|
||||
void updateData() {
|
||||
ingredients = new IngredientInventory(getPlayer());
|
||||
ingredients = new IngredientInventory(player);
|
||||
recipes = station.getAvailableRecipes(playerData, ingredients);
|
||||
}
|
||||
|
||||
@ -187,13 +187,18 @@ public class CraftingStationView extends PluginInventory {
|
||||
return;
|
||||
|
||||
playerData.getCrafting().getQueue(station).remove(recipeInfo);
|
||||
|
||||
recipe.getTriggers().forEach(trigger -> trigger.whenCrafting(playerData));
|
||||
|
||||
ItemStack craftedItem = recipe.getOutput().generate(playerData.getRPG());
|
||||
CustomSoundListener.stationCrafting(craftedItem, getPlayer());
|
||||
|
||||
CustomSoundListener.stationCrafting(craftedItem, player);
|
||||
|
||||
if (!recipe.hasOption(Recipe.RecipeOption.SILENT_CRAFT))
|
||||
getPlayer().playSound(getPlayer().getLocation(), station.getSound(), 1, 1);
|
||||
player.playSound(player.getLocation(), station.getSound(), 1, 1);
|
||||
|
||||
if (recipe.hasOption(Recipe.RecipeOption.OUTPUT_ITEM))
|
||||
new SmartGive(getPlayer()).give(craftedItem);
|
||||
new SmartGive(player).give(craftedItem);
|
||||
|
||||
/*
|
||||
* If the recipe is not ready, cancel the recipe and give the
|
||||
@ -207,9 +212,9 @@ public class CraftingStationView extends PluginInventory {
|
||||
return;
|
||||
|
||||
playerData.getCrafting().getQueue(station).remove(recipeInfo);
|
||||
getPlayer().playSound(getPlayer().getLocation(), station.getSound(), 1, 1);
|
||||
player.playSound(player.getLocation(), station.getSound(), 1, 1);
|
||||
for (Ingredient ingredient : recipeInfo.getRecipe().getIngredients())
|
||||
new SmartGive(getPlayer()).give(ingredient.generateItemStack(playerData.getRPG()));
|
||||
new SmartGive(player).give(ingredient.generateItemStack(playerData.getRPG()));
|
||||
}
|
||||
|
||||
updateData();
|
||||
@ -219,14 +224,14 @@ public class CraftingStationView extends PluginInventory {
|
||||
|
||||
public void processRecipe(CheckedRecipe recipe) {
|
||||
if (!recipe.areConditionsMet()) {
|
||||
Message.CONDITIONS_NOT_MET.format(ChatColor.RED).send(getPlayer());
|
||||
getPlayer().playSound(getPlayer().getLocation(), Sound.ENTITY_VILLAGER_NO, 1, 1);
|
||||
Message.CONDITIONS_NOT_MET.format(ChatColor.RED).send(player);
|
||||
player.playSound(player.getLocation(), Sound.ENTITY_VILLAGER_NO, 1, 1);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!recipe.allIngredientsHad()) {
|
||||
Message.NOT_ENOUGH_MATERIALS.format(ChatColor.RED).send(getPlayer());
|
||||
getPlayer().playSound(getPlayer().getLocation(), Sound.ENTITY_VILLAGER_NO, 1, 1);
|
||||
Message.NOT_ENOUGH_MATERIALS.format(ChatColor.RED).send(player);
|
||||
player.playSound(player.getLocation(), Sound.ENTITY_VILLAGER_NO, 1, 1);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -122,7 +122,7 @@ public class ItemBrowser extends PluginInventory {
|
||||
Inventory inv = Bukkit.createInventory(this, 54, (deleteMode ? ("Delete Mode: ") : ("Item Explorer: ")) + type.getName());
|
||||
for (int j = min; j < Math.min(max, templates.size()); j++) {
|
||||
MMOItemTemplate template = templates.get(j);
|
||||
ItemStack item = template.newBuilder(getPlayerData().getRPG()).build().newBuilder().build();
|
||||
ItemStack item = template.newBuilder(playerData.getRPG()).build().newBuilder().build();
|
||||
if (item == null || item.getType() == Material.AIR) {
|
||||
cached.put(template.getId(), error);
|
||||
inv.setItem(slots[n++], error);
|
||||
|
@ -1,14 +1,13 @@
|
||||
package net.Indyuce.mmoitems.gui;
|
||||
|
||||
import net.Indyuce.mmoitems.MMOItems;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerData;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.InventoryHolder;
|
||||
|
||||
import net.Indyuce.mmoitems.MMOItems;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerData;
|
||||
|
||||
public abstract class PluginInventory implements InventoryHolder {
|
||||
protected final PlayerData playerData;
|
||||
protected final Player player;
|
||||
@ -47,8 +46,8 @@ public abstract class PluginInventory implements InventoryHolder {
|
||||
*/
|
||||
public void open() {
|
||||
if (Bukkit.isPrimaryThread())
|
||||
getPlayer().openInventory(getInventory());
|
||||
player.openInventory(getInventory());
|
||||
else
|
||||
Bukkit.getScheduler().runTask(MMOItems.plugin, () -> getPlayer().openInventory(getInventory()));
|
||||
Bukkit.getScheduler().runTask(MMOItems.plugin, () -> player.openInventory(getInventory()));
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user