-
Notifications
You must be signed in to change notification settings - Fork 270
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Don't drop empty items when breaking containers, added ImmutableItemS…
…tack. ImmutableItemStack should be moved to Glowkit as an API. This is temporary and might be broken.
- Loading branch information
Showing
3 changed files
with
92 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
package net.glowstone.util; | ||
|
||
import org.bukkit.Bukkit; | ||
import org.bukkit.Material; | ||
import org.bukkit.inventory.ItemStack; | ||
import org.bukkit.inventory.meta.ItemMeta; | ||
import org.bukkit.material.MaterialData; | ||
|
||
public class ImmutableItemStack extends ItemStack { | ||
|
||
private ItemMeta originalMeta = null; | ||
|
||
public ImmutableItemStack(int type) { | ||
super(type); | ||
originalMeta = Bukkit.getItemFactory().getItemMeta(getType()).clone(); | ||
} | ||
|
||
public ImmutableItemStack(Material type) { | ||
super(type); | ||
} | ||
|
||
public ImmutableItemStack(int type, int amount) { | ||
super(type, amount); | ||
} | ||
|
||
public ImmutableItemStack(Material type, int amount) { | ||
super(type, amount); | ||
} | ||
|
||
public ImmutableItemStack(int type, int amount, short damage) { | ||
super(type, amount, damage); | ||
} | ||
|
||
public ImmutableItemStack(Material type, int amount, short damage) { | ||
super(type, amount, damage); | ||
} | ||
|
||
public ImmutableItemStack(int type, int amount, short damage, Byte data) { | ||
super(type, amount, damage, data); | ||
} | ||
|
||
public ImmutableItemStack(Material type, int amount, short damage, Byte data) { | ||
super(type, amount, damage, data); | ||
} | ||
|
||
public ImmutableItemStack(ItemStack stack) throws IllegalArgumentException { | ||
super(stack); | ||
originalMeta = stack.getItemMeta().clone(); | ||
} | ||
|
||
@Deprecated | ||
@Override | ||
public void setType(Material type) { | ||
} | ||
|
||
@Deprecated | ||
@Override | ||
public void setTypeId(int type) { | ||
} | ||
|
||
@Deprecated | ||
@Override | ||
public boolean setItemMeta(ItemMeta itemMeta) { | ||
return false; | ||
} | ||
|
||
@Deprecated | ||
@Override | ||
public void setAmount(int amount) { | ||
} | ||
|
||
@Deprecated | ||
@Override | ||
public void setData(MaterialData data) { | ||
} | ||
|
||
@Deprecated | ||
@Override | ||
public void setDurability(short durability) { | ||
} | ||
|
||
@Override | ||
public ItemMeta getItemMeta() { | ||
return originalMeta; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters