本文整理汇总了Java中org.bukkit.event.inventory.FurnaceSmeltEvent类的典型用法代码示例。如果您正苦于以下问题:Java FurnaceSmeltEvent类的具体用法?Java FurnaceSmeltEvent怎么用?Java FurnaceSmeltEvent使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
FurnaceSmeltEvent类属于org.bukkit.event.inventory包,在下文中一共展示了FurnaceSmeltEvent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onSmelt
import org.bukkit.event.inventory.FurnaceSmeltEvent; //导入依赖的package包/类
public void onSmelt(FurnaceSmeltEvent e)
{
if(BlockStorage.check(e.getBlock()) != null && (BlockStorage.check(e.getBlock()) instanceof EnhancedFurnace))
{
EnhancedFurnace furnace = (EnhancedFurnace)BlockStorage.check(e.getBlock());
Furnace f = (Furnace)e.getBlock().getState();
int amount = f.getInventory().getSmelting().getType().toString().endsWith("_ORE") ? furnace.getOutput() : 1;
ItemStack output = RecipeCalculator.getSmeltedOutput(f.getInventory().getSmelting().getType());
ItemStack result = f.getInventory().getResult();
if(result != null)
result = result.clone();
f.getInventory().setResult(null);
if(result != null)
f.getInventory().setResult(new CustomItem(result, result.getAmount() + amount <= result.getMaxStackSize() ? result.getAmount() + amount : result.getMaxStackSize()));
else
f.getInventory().setResult(new CustomItem(output, output.getAmount() + amount <= output.getType().getMaxStackSize() ? output.getAmount() + amount : output.getType().getMaxStackSize()));
}
}
示例2: onFurnaceSmelt
import org.bukkit.event.inventory.FurnaceSmeltEvent; //导入依赖的package包/类
/**
* Handles the action of smelting all items at once, exploding the furnace, and dropping the smelted items on the
* ground.
*
* @param event The event
*/
@EventHandler(ignoreCancelled = true)
public void onFurnaceSmelt(FurnaceSmeltEvent event) {
ItemStack resultItem = event.getResult();
final Material result = resultItem.getType();
//TODO: Verify that the "smelting amount" contains any extra ingredients
final int amount = ((Furnace) event.getBlock().getState()).getInventory().getSmelting().getAmount();
event.getSource().setType(Material.AIR);
resultItem.setType(Material.AIR);
Block block = event.getBlock();
block.setType(Material.AIR);
Location location = block.getLocation().add(0.5, 0.5, 0.5);
World world = location.getWorld();
world.createExplosion(location, 7);
world.dropItem(location, new ItemStack(result, amount));
}
示例3: get
import org.bukkit.event.inventory.FurnaceSmeltEvent; //导入依赖的package包/类
@Override
protected Slot[] get(final Event e, final Block[] source) {
return get(source, new Getter<Slot, Block>() {
@SuppressWarnings("null")
@Override
@Nullable
public Slot get(final Block b) {
if (b.getType() != Material.FURNACE && b.getType() != Material.BURNING_FURNACE)
return null;
if (getTime() >= 0 && (e instanceof FurnaceSmeltEvent && b.equals(((FurnaceSmeltEvent) e).getBlock()) || e instanceof FurnaceBurnEvent && b.equals(((FurnaceBurnEvent) e).getBlock())) && !Delay.isDelayed(e)) {
return new FurnaceEventSlot(e, ((Furnace) b.getState()).getInventory());
} else {
return new InventorySlot(((Furnace) b.getState()).getInventory(), slot);
}
}
});
}
示例4: onFurnaceSmelt
import org.bukkit.event.inventory.FurnaceSmeltEvent; //导入依赖的package包/类
@EventHandler(ignoreCancelled = false)
public void onFurnaceSmelt(cn.nukkit.event.inventory.FurnaceSmeltEvent event) {
if (canIgnore(FurnaceSmeltEvent.getHandlerList())) {
return;
}
Block furnace = PokkitBlock.toBukkit(event.getBlock());
ItemStack source = PokkitItemStack.toBukkitCopy(event.getSource());
ItemStack result = PokkitItemStack.toBukkitCopy(event.getResult());
FurnaceSmeltEvent bukkitEvent = new FurnaceSmeltEvent(furnace, source, result);
callCancellable(event, bukkitEvent);
PokkitItemStack.overwriteNukkit(bukkitEvent.getSource(), event.getSource());
PokkitItemStack.overwriteNukkit(bukkitEvent.getResult(), event.getResult());
}
示例5: onFurnaceSmeltEvent
import org.bukkit.event.inventory.FurnaceSmeltEvent; //导入依赖的package包/类
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onFurnaceSmeltEvent(FurnaceSmeltEvent event) {
Block furnaceBlock = event.getBlock();
ItemStack smelting = event.getSource();
if (!ItemUtils.isSmeltable(smelting)) {
return;
}
Player player = getPlayerFromFurnace(furnaceBlock);
if (!UserManager.hasPlayerDataKey(player) || !SkillType.SMELTING.getPermissions(player)) {
return;
}
event.setResult(UserManager.getPlayer(player).getSmeltingManager().smeltProcessing(smelting, event.getResult()));
}
示例6: onEvent
import org.bukkit.event.inventory.FurnaceSmeltEvent; //导入依赖的package包/类
@EventHandler(priority = EventPriority.LOWEST)
private void onEvent(FurnaceSmeltEvent event) {
for (PlayerModel model : DGData.PLAYER_R.fromAspect(Aspects.CRAFTING_ASPECT_I)) {
try {
if (model.getOnline() && model.getLocation().getWorld().equals(event.getBlock().getWorld()) &&
model.getLocation().distance(event.getBlock().getLocation()) <
(int) Math.round(20 * Math.pow(model.getExperience(Aspects.CRAFTING_ASPECT_I), 0.15))) {
int amount = event.getResult().getAmount() * 2;
ItemStack out = event.getResult();
out.setAmount(amount);
event.setResult(out);
}
} catch (Exception oops) {
oops.printStackTrace();
}
}
}
示例7: onFurnaceSmelt
import org.bukkit.event.inventory.FurnaceSmeltEvent; //导入依赖的package包/类
@EventHandler(priority = EventPriority.HIGH)
public void onFurnaceSmelt(FurnaceSmeltEvent event) {
final List<FXRecipe> recipes = registry.get().getRecipes(event.getResult());
// Check custom items not used in non-plugin recipes
if (recipes.isEmpty()) {
if (registry.get().getDefinition(event.getSource()).isPresent()) {
event.setCancelled(true);
}
}
// Check if valid furnace recipe
else if (!recipes.stream().filter(r -> r instanceof FXFurnaceRecipe)
.map(r -> (FXFurnaceRecipe) r)
// Check input matches the recipe
.filter(r -> registry.get().isSimilar(r.getInput(), event.getSource()))
.findAny().isPresent()) {
event.setCancelled(true);
}
}
示例8: OnFurnaceSmelt
import org.bukkit.event.inventory.FurnaceSmeltEvent; //导入依赖的package包/类
@EventHandler
public void OnFurnaceSmelt(FurnaceSmeltEvent event){
if(!EpicSystem.furnaceList.containsKey(event.getBlock().getLocation())) return;
EpicPlayer epicPlayer = EpicSystem.furnaceList.get(event.getBlock().getLocation());
List<EpicQuestTask> taskList = epicPlayer.getTasksByType(TaskTypes.SMELT_ITEM);
for(EpicQuestTask task : taskList){
Material itemID = event.getSource().getType();
Material itemNeeded = Material.matchMaterial(task.getTaskID());
if(itemID == itemNeeded){
task.ProgressTask(1, epicPlayer, true);
}
}
}
示例9: setItem
import org.bukkit.event.inventory.FurnaceSmeltEvent; //导入依赖的package包/类
@SuppressWarnings("synthetic-access")
@Override
public void setItem(final @Nullable ItemStack item) {
if (e instanceof FurnaceSmeltEvent) {
if (slot == RESULT && getTime() >= 0) {
if (item == null || item.getType() == Material.AIR) { // null/air crashes the server on account of a NPE if using event.setResult(...)
Bukkit.getScheduler().scheduleSyncDelayedTask(Skript.getInstance(), new Runnable() {
@Override
public void run() {
FurnaceEventSlot.super.setItem(null);
}
});
} else {
((FurnaceSmeltEvent) e).setResult(item);
}
} else if (slot == ORE && getTime() >= 0) {
Bukkit.getScheduler().scheduleSyncDelayedTask(Skript.getInstance(), new Runnable() {
@Override
public void run() {
FurnaceEventSlot.super.setItem(item);
}
});
} else {
super.setItem(item);
}
} else {
if (slot == FUEL && getTime() >= 0) {
Bukkit.getScheduler().scheduleSyncDelayedTask(Skript.getInstance(), new Runnable() {
@Override
public void run() {
FurnaceEventSlot.super.setItem(item);
}
});
} else {
super.setItem(item);
}
}
}
示例10: burn
import org.bukkit.event.inventory.FurnaceSmeltEvent; //导入依赖的package包/类
public void burn() {
if (this.canBurn()) {
ItemStack itemstack = RecipesFurnace.getInstance().getResult(this.items[0]);
// CraftBukkit start - fire FurnaceSmeltEvent
CraftItemStack source = CraftItemStack.asCraftMirror(this.items[0]);
org.bukkit.inventory.ItemStack result = CraftItemStack.asBukkitCopy(itemstack);
FurnaceSmeltEvent furnaceSmeltEvent = new FurnaceSmeltEvent(this.world.getWorld().getBlockAt(this.x, this.y, this.z), source, result);
this.world.getServer().getPluginManager().callEvent(furnaceSmeltEvent);
if (furnaceSmeltEvent.isCancelled()) {
return;
}
result = furnaceSmeltEvent.getResult();
itemstack = CraftItemStack.asNMSCopy(result);
if (itemstack != null) {
if (this.items[2] == null) {
this.items[2] = itemstack;
} else if (CraftItemStack.asCraftMirror(this.items[2]).isSimilar(result)) {
this.items[2].count += itemstack.count;
} else {
return;
}
}
// CraftBukkit end
--this.items[0].count;
if (this.items[0].count <= 0) {
this.items[0] = null;
}
}
}
示例11: onSmelt
import org.bukkit.event.inventory.FurnaceSmeltEvent; //导入依赖的package包/类
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onSmelt(FurnaceSmeltEvent e) {
if (BlockStorage.check(e.getBlock()) != null && BlockStorage.check(e.getBlock()) instanceof EnhancedFurnace) {
EnhancedFurnace furnace = (EnhancedFurnace) BlockStorage.check(e.getBlock());
Furnace f = (Furnace) e.getBlock().getState();
int amount = f.getInventory().getSmelting().getType().toString().endsWith("_ORE") ? furnace.getOutput(): 1;
ItemStack output = RecipeCalculator.getSmeltedOutput(f.getInventory().getSmelting().getType());
ItemStack result = f.getInventory().getResult();
if (result != null) result = result.clone();
f.getInventory().setResult(null);
if (result != null) f.getInventory().setResult(new CustomItem(result, result.getAmount() + amount > result.getMaxStackSize() ? result.getMaxStackSize(): result.getAmount() + amount));
else f.getInventory().setResult(new CustomItem(output, output.getAmount() + amount > output.getType().getMaxStackSize() ? output.getType().getMaxStackSize(): output.getAmount() + amount));
}
}
示例12: burn
import org.bukkit.event.inventory.FurnaceSmeltEvent; //导入依赖的package包/类
public void burn() {
if (this.canBurn()) {
ItemStack itemstack = RecipesFurnace.getInstance().getResult(this.items[0].getItem().id);
// CraftBukkit start
CraftItemStack source = CraftItemStack.asCraftMirror(this.items[0]);
CraftItemStack result = CraftItemStack.asCraftMirror(itemstack.cloneItemStack());
FurnaceSmeltEvent furnaceSmeltEvent = new FurnaceSmeltEvent(this.world.getWorld().getBlockAt(this.x, this.y, this.z), source, result);
this.world.getServer().getPluginManager().callEvent(furnaceSmeltEvent);
if (furnaceSmeltEvent.isCancelled()) {
return;
}
itemstack = CraftItemStack.asNMSCopy(furnaceSmeltEvent.getResult());
if (this.items[2] == null) {
this.items[2] = itemstack.cloneItemStack();
} else if (this.items[2].id == itemstack.id) {
// CraftBukkit - compare damage too
if (this.items[2].getData() == itemstack.getData()) {
this.items[2].count += itemstack.count;
}
// CraftBukkit end
}
--this.items[0].count;
if (this.items[0].count <= 0) {
this.items[0] = null;
}
}
}
示例13: smeltFast
import org.bukkit.event.inventory.FurnaceSmeltEvent; //导入依赖的package包/类
@EventHandler
public void smeltFast(FurnaceSmeltEvent e) {
if (!(e.getBlock().getState() instanceof Furnace)) return;
Furnace f = (Furnace) e.getBlock().getState();
if (!RUtils.isInInfectedWorld(f.getLocation())) return;
ConfManager cm = ConfManager.getConfManager("otherdata.yml");
Location l = f.getLocation();
String path = "furnaces." + l.getWorld().getName() + "," + l.getBlockX() + "," + l.getBlockY() + "," + l.getBlockZ();
if (!cm.getBoolean(path, false)) return;
f.setCookTime((short) 140); // 7 seconds in = 3 seconds left
}
示例14: setTime
import org.bukkit.event.inventory.FurnaceSmeltEvent; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public boolean setTime(final int time) {
return super.setTime(time, getExpr(), FurnaceSmeltEvent.class, FurnaceBurnEvent.class);
}
示例15: onItemSmelt
import org.bukkit.event.inventory.FurnaceSmeltEvent; //导入依赖的package包/类
@EventHandler
public void onItemSmelt(FurnaceSmeltEvent e) {
if (e.getBlock().getLocation().equals(furnace.getLocation())) {
e.setCancelled(true);
}
}