Skip to content

Commit

Permalink
Fix issue with essentialsx sending OfflinePlayer object with null name.
Browse files Browse the repository at this point in the history
  • Loading branch information
creatorfromhell committed Nov 23, 2023
1 parent 04cd3ed commit f883f7d
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 22 deletions.
4 changes: 4 additions & 0 deletions Bukkit/src/net/tnemc/bukkit/hook/economy/TNEVault.java
Original file line number Diff line number Diff line change
Expand Up @@ -560,6 +560,10 @@ public boolean createPlayerAccount(String name, String world) {
*/
public boolean createPlayerAccount(OfflinePlayer player, String world) {
TNECore.log().debug("Vault Method: Create Player Account!", DebugLevel.STANDARD);
if(player.getName() == null) {
TNECore.log().error("Error from plugin accessing vault createPlayerAccount! Name provided is null!(probably EssentialsX)");
return false;
}
return TNECore.eco().account().createAccount(player.getUniqueId().toString(), player.getName()).getResponse().success();
}

Expand Down
8 changes: 4 additions & 4 deletions Bukkit/src/net/tnemc/bukkit/impl/BukkitServerProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -260,15 +260,15 @@ public BukkitScheduler scheduler() {
@Override
public void registerCrafting(@NotNull CraftingRecipe recipe) {
if(recipe.isShaped()) {
final ShapedRecipe shaped = new ShapedRecipe(denominationToStack(recipe.getResult()).locale());
final ShapedRecipe shaped = new ShapedRecipe(denominationToStack(recipe.getResult(), recipe.getAmount()).locale());
shaped.shape(recipe.getRows());

for(Map.Entry<Character, String> ingredient : recipe.getIngredients().entrySet()) {
shaped.setIngredient(ingredient.getKey(), Material.valueOf(ingredient.getValue()));
}
Bukkit.getServer().addRecipe(shaped);
} else {
final ShapelessRecipe shapeless = new ShapelessRecipe(denominationToStack(recipe.getResult()).locale());
final ShapelessRecipe shapeless = new ShapelessRecipe(denominationToStack(recipe.getResult(), recipe.getAmount()).locale());
for(Map.Entry<Character, String> ingredient : recipe.getIngredients().entrySet()) {
shapeless.addIngredient(1, Material.valueOf(ingredient.getValue()));
}
Expand All @@ -277,8 +277,8 @@ public void registerCrafting(@NotNull CraftingRecipe recipe) {
}

@Override
public BukkitItemStack denominationToStack(ItemDenomination denomination) {
return new BukkitItemStack().of(denomination.getMaterial(), 1)
public BukkitItemStack denominationToStack(ItemDenomination denomination, int amount) {
return new BukkitItemStack().of(denomination.getMaterial(), amount)
.enchant(denomination.getEnchantments())
.lore(denomination.getLore())
.flags(denomination.getFlags())
Expand Down
6 changes: 5 additions & 1 deletion Core/src/net/tnemc/core/compatibility/ServerConnector.java
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,11 @@ default boolean pluginClassAvailable(final String classPath) {

<S, T extends AbstractItemStack<S>, INV> CalculationsProvider<T, S, INV> calculations();

<S> AbstractItemStack<S> denominationToStack(final ItemDenomination denomination);
default <S> AbstractItemStack<S> denominationToStack(final ItemDenomination denomination) {
return denominationToStack(denomination, 1);
}

<S> AbstractItemStack<S> denominationToStack(final ItemDenomination denomination, final int amount);

<INV> ItemCalculations<INV> itemCalculations();

Expand Down
20 changes: 10 additions & 10 deletions Folia/src/net/tnemc/folia/impl/FoliaServerProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -262,15 +262,15 @@ public FoliaScheduler scheduler() {
@Override
public void registerCrafting(@NotNull CraftingRecipe recipe) {
if(recipe.isShaped()) {
final ShapedRecipe shaped = new ShapedRecipe(denominationToStack(recipe.getResult()).locale());
final ShapedRecipe shaped = new ShapedRecipe(denominationToStack(recipe.getResult(), recipe.getAmount()).locale());
shaped.shape(recipe.getRows());

for(Map.Entry<Character, String> ingredient : recipe.getIngredients().entrySet()) {
shaped.setIngredient(ingredient.getKey(), Material.valueOf(ingredient.getValue()));
}
Bukkit.getServer().addRecipe(shaped);
} else {
final ShapelessRecipe shapeless = new ShapelessRecipe(denominationToStack(recipe.getResult()).locale());
final ShapelessRecipe shapeless = new ShapelessRecipe(denominationToStack(recipe.getResult(), recipe.getAmount()).locale());
for(Map.Entry<Character, String> ingredient : recipe.getIngredients().entrySet()) {
shapeless.addIngredient(1, Material.valueOf(ingredient.getValue()));
}
Expand All @@ -279,14 +279,14 @@ public void registerCrafting(@NotNull CraftingRecipe recipe) {
}

@Override
public BukkitItemStack denominationToStack(ItemDenomination denomination) {
return new BukkitItemStack().of(denomination.getMaterial(), 1)
.enchant(denomination.getEnchantments())
.lore(denomination.getLore())
.flags(denomination.getFlags())
.damage(denomination.getDamage())
.display(denomination.getName())
.modelData(denomination.getCustomModel());
public BukkitItemStack denominationToStack(ItemDenomination denomination, int amount) {
return new BukkitItemStack().of(denomination.getMaterial(), amount)
.enchant(denomination.getEnchantments())
.lore(denomination.getLore())
.flags(denomination.getFlags())
.damage(denomination.getDamage())
.display(denomination.getName())
.modelData(denomination.getCustomModel());
}

@Override
Expand Down
8 changes: 4 additions & 4 deletions PaperCore/src/net/tnemc/paper/impl/PaperServerProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -260,15 +260,15 @@ public PaperScheduler scheduler() {
@Override
public void registerCrafting(@NotNull CraftingRecipe recipe) {
if(recipe.isShaped()) {
final ShapedRecipe shaped = new ShapedRecipe(denominationToStack(recipe.getResult()).locale());
final ShapedRecipe shaped = new ShapedRecipe(denominationToStack(recipe.getResult(), recipe.getAmount()).locale());
shaped.shape(recipe.getRows());

for(Map.Entry<Character, String> ingredient : recipe.getIngredients().entrySet()) {
shaped.setIngredient(ingredient.getKey(), Material.valueOf(ingredient.getValue()));
}
Bukkit.getServer().addRecipe(shaped);
} else {
final ShapelessRecipe shapeless = new ShapelessRecipe(denominationToStack(recipe.getResult()).locale());
final ShapelessRecipe shapeless = new ShapelessRecipe(denominationToStack(recipe.getResult(), recipe.getAmount()).locale());
for(Map.Entry<Character, String> ingredient : recipe.getIngredients().entrySet()) {
shapeless.addIngredient(1, Material.valueOf(ingredient.getValue()));
}
Expand All @@ -277,8 +277,8 @@ public void registerCrafting(@NotNull CraftingRecipe recipe) {
}

@Override
public BukkitItemStack denominationToStack(ItemDenomination denomination) {
return new BukkitItemStack().of(denomination.getMaterial(), 1)
public BukkitItemStack denominationToStack(ItemDenomination denomination, int amount) {
return new BukkitItemStack().of(denomination.getMaterial(), amount)
.enchant(denomination.getEnchantments())
.lore(denomination.getLore())
.flags(denomination.getFlags())
Expand Down
2 changes: 1 addition & 1 deletion Sponge/src/net/tnemc/sponge/impl/SpongeServerProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ public <S, T extends AbstractItemStack<S>, INV> CalculationsProvider<T, S, INV>
}

@Override
public <S> AbstractItemStack<S> denominationToStack(ItemDenomination denomination) {
public <S> AbstractItemStack<S> denominationToStack(ItemDenomination denomination, final int amount) {
return null;
}

Expand Down
4 changes: 2 additions & 2 deletions Sponge8/src/net/tnemc/sponge/impl/SpongeServerProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -294,8 +294,8 @@ public SpongeItemCalculationsProvider calculations() {
}

@Override
public SpongeItemStack denominationToStack(ItemDenomination denomination) {
return new SpongeItemStack().of(denomination.getMaterial(), 1)
public SpongeItemStack denominationToStack(ItemDenomination denomination, int amount) {
return new SpongeItemStack().of(denomination.getMaterial(), amount)
.enchant(denomination.getEnchantments())
.lore(denomination.getLore())
.flags(denomination.getFlags())
Expand Down

0 comments on commit f883f7d

Please sign in to comment.