use of io.github.thebusybiscuit.slimefun4.implementation.Slimefun in project Slimefun4 by Slimefun.
the class TestMonsterJerky method registerSlimefunItem.
@Override
public MonsterJerky registerSlimefunItem(Slimefun plugin, String id) {
SlimefunItemStack item = new SlimefunItemStack(id, Material.ROTTEN_FLESH, "&5Test Monster Jerky");
MonsterJerky jerky = new MonsterJerky(TestUtilities.getItemGroup(plugin, "monster_jerky"), item, RecipeType.NULL, new ItemStack[9]);
jerky.register(plugin);
return jerky;
}
use of io.github.thebusybiscuit.slimefun4.implementation.Slimefun in project Slimefun4 by Slimefun.
the class TestClimbingPick method registerSlimefunItem.
@Override
public ClimbingPick registerSlimefunItem(Slimefun plugin, String id) {
SlimefunItemStack item = new SlimefunItemStack(id, Material.IRON_PICKAXE, "&5Test Pick", id);
ClimbingPick pick = new ClimbingPick(TestUtilities.getItemGroup(plugin, "climbing_pick"), item, RecipeType.NULL, new ItemStack[9]) {
@Override
public boolean isDualWieldingEnabled() {
return false;
}
};
pick.register(plugin);
Assertions.assertFalse(pick.getClimbableSurfaces().isEmpty());
return pick;
}
use of io.github.thebusybiscuit.slimefun4.implementation.Slimefun in project Slimefun4 by Slimefun.
the class TestPortableDustbin method registerSlimefunItem.
@Override
public PortableDustbin registerSlimefunItem(Slimefun plugin, String id) {
SlimefunItemStack item = new SlimefunItemStack(id, Material.BUCKET, "&4Test Dustbin");
PortableDustbin dustbin = new PortableDustbin(TestUtilities.getItemGroup(plugin, "dustbin"), item, RecipeType.NULL, new ItemStack[9]);
dustbin.register(plugin);
return dustbin;
}
use of io.github.thebusybiscuit.slimefun4.implementation.Slimefun in project FN-FAL-s-Amplifications by FN-FAL113.
the class MainStick method transformWeapon.
/**
* transform the weapon back to a stick if player doesn't have enough exp levels
* @param p the player involved
* @param item the weapon used
* @param slimefunItem the item as an slimefun item instance
* @param finalLore the final changes to the persistent lore before transforming the weapon
* @param incrementLevel the value for incrementing the current exp level pdc data
*/
public void transformWeapon(Player p, ItemStack item, SlimefunItemStack slimefunItem, String finalLore, int incrementLevel, int damageAmount, boolean isLevelDeducted) {
CustomItemStack item2 = new CustomItemStack(slimefunItem);
ItemMeta meta = item.getItemMeta();
List<String> lore = meta.getLore();
PersistentDataContainer pdc = meta.getPersistentDataContainer();
int xpAmount = getPdc(pdc, getStorageKey());
int damageInflicted = damageAmount + getPdc(pdc, getStorageKey2());
pdc.set(getStorageKey2(), PersistentDataType.INTEGER, damageInflicted);
if (isLevelDeducted) {
int amount = ++xpAmount + incrementLevel;
pdc.set(getStorageKey(), PersistentDataType.INTEGER, amount);
meta.setLore(loreUpdate(lore, damageInflicted, amount, finalLore));
} else {
meta.setLore(loreUpdate(lore, damageInflicted, xpAmount, finalLore));
}
item.setItemMeta(meta);
if (p.getLevel() <= getRequiredLevel()) {
if (lore.size() >= 4) {
lore.subList(3, lore.size()).clear();
}
meta.setLore(lore);
meta.getEnchants().forEach((enchant, value) -> meta.removeEnchant(enchant));
item.setItemMeta(meta);
item.setType(item2.getType());
}
}
use of io.github.thebusybiscuit.slimefun4.implementation.Slimefun in project InfinityExpansion by Mooy1.
the class SetData method execute.
@Override
protected void execute(@Nonnull CommandSender commandSender, @Nonnull String[] strings) {
if (!(commandSender instanceof Player)) {
commandSender.sendMessage("Only players can use this!");
return;
}
if (strings.length != 2) {
commandSender.sendMessage(ChatColor.RED + "You must specify a key and value to set!");
return;
}
Player p = (Player) commandSender;
Block target = p.getTargetBlockExact(8, FluidCollisionMode.NEVER);
if (target == null || target.getType() == Material.AIR) {
p.sendMessage(ChatColor.RED + "You need to target a block to use this command!");
return;
}
String id = BlockStorage.getLocationInfo(target.getLocation(), "id");
if (id == null) {
p.sendMessage(ChatColor.RED + "You need to target a slimefun block to use this command!");
return;
}
if (strings[0].equals("id")) {
p.sendMessage(ChatColor.RED + "You cannot change the id of this block, it could cause internal issues!");
return;
}
if (strings[1].equals("\\remove")) {
p.sendMessage(ChatColor.GREEN + "Successfully removed value of key '" + strings[0] + "' in " + id);
BlockStorage.addBlockInfo(target, strings[0], null);
} else {
p.sendMessage(ChatColor.GREEN + "Successfully set key '" + strings[0] + "' to value '" + strings[1] + "' in " + id);
BlockStorage.addBlockInfo(target, strings[0], strings[1]);
}
SlimefunItem unit = SlimefunItem.getById(id);
if (unit instanceof StorageUnit) {
((StorageUnit) unit).reloadCache(target);
}
}
Aggregations