Drop the correct level farm items.

This commit is contained in:
Brianna 2020-05-12 16:17:51 -04:00
parent f33e9eb40d
commit 9df3564d12
2 changed files with 6 additions and 12 deletions

View File

@ -11,6 +11,7 @@ import com.songoda.core.hooks.EntityStackerManager;
import com.songoda.core.nms.NmsManager; import com.songoda.core.nms.NmsManager;
import com.songoda.core.nms.nbt.NBTCore; import com.songoda.core.nms.nbt.NBTCore;
import com.songoda.core.nms.nbt.NBTItem; import com.songoda.core.nms.nbt.NBTItem;
import com.songoda.core.utils.TextUtils;
import com.songoda.epicfarming.boost.BoostData; import com.songoda.epicfarming.boost.BoostData;
import com.songoda.epicfarming.boost.BoostManager; import com.songoda.epicfarming.boost.BoostManager;
import com.songoda.epicfarming.commands.*; import com.songoda.epicfarming.commands.*;
@ -45,10 +46,7 @@ import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.plugin.PluginManager; import org.bukkit.plugin.PluginManager;
import java.io.File; import java.io.File;
import java.util.ArrayList; import java.util.*;
import java.util.Arrays;
import java.util.List;
import java.util.UUID;
/** /**
* Created by songoda on 1/23/2018. * Created by songoda on 1/23/2018.
@ -297,9 +295,9 @@ public class EpicFarming extends SongodaPlugin {
public ItemStack makeFarmItem(Level level) { public ItemStack makeFarmItem(Level level) {
ItemStack item = Settings.FARM_BLOCK_MATERIAL.getMaterial().getItem(); ItemStack item = Settings.FARM_BLOCK_MATERIAL.getMaterial().getItem();
ItemMeta meta = item.getItemMeta(); ItemMeta meta = item.getItemMeta();
meta.setDisplayName(Methods.formatText(Methods.formatName(level.getLevel()))); meta.setDisplayName(TextUtils.formatText(Methods.formatName(level.getLevel())));
String line = getLocale().getMessage("general.nametag.lore").getMessage(); String line = getLocale().getMessage("general.nametag.lore").getMessage();
if (!line.equals("")) meta.setLore(Arrays.asList(line)); if (!line.equals("")) meta.setLore(Collections.singletonList(line));
item.setItemMeta(meta); item.setItemMeta(meta);
NBTItem nbtItem = NmsManager.getNbt().of(item); NBTItem nbtItem = NmsManager.getNbt().of(item);

View File

@ -88,15 +88,11 @@ public class BlockListeners implements Listener {
instance.getLocale().getMessage("event.warning.noauto").sendPrefixedMessage(e.getPlayer()); instance.getLocale().getMessage("event.warning.noauto").sendPrefixedMessage(e.getPlayer());
} }
} }
int level = instance.getLevelFromItem(e.getItemInHand());
Bukkit.getScheduler().runTaskLater(instance, () -> { Bukkit.getScheduler().runTaskLater(instance, () -> {
int level = 1;
if (instance.getLevelFromItem(e.getItemInHand()) != 0) {
level = instance.getLevelFromItem(e.getItemInHand());
}
if (location.getBlock().getType() != farmBlock) return; if (location.getBlock().getType() != farmBlock) return;
Farm farm = new Farm(location, instance.getLevelManager().getLevel(level), e.getPlayer().getUniqueId()); Farm farm = new Farm(location, instance.getLevelManager().getLevel(level == 0 ? 1 : 0), e.getPlayer().getUniqueId());
instance.getFarmManager().addFarm(location, farm); instance.getFarmManager().addFarm(location, farm);
farm.tillLand(); farm.tillLand();