mirror of
https://github.com/PaperMC/Paper.git
synced 2025-08-09 00:22:08 -07:00
[Bleeding] Implementation of inventory framework. Addresses BUKKIT-856
See the corresponding Bukkit commit for details. Implementation details: - Any packets that include an itemstack will send air stacks as null; maybe this will even eliminate the client crash that occurs if the client receives an air stack - Better handling of null itemstacks in general (ie less converting them to air stacks) - Inventory.setContents() can now take an array smaller than the inventory without error - Player.updateInventory() should now correctly update the result slot in a crafting inventory Some small credit goes to Afforess (initial implementation of openInventory() methods) and Drakia (initial implementation of InventoryOpenEvent and InventoryCloseEvent).
This commit is contained in:
committed by
EvilSeph
parent
10e593649c
commit
0842bab48b
@@ -59,6 +59,7 @@ import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.configuration.serialization.ConfigurationSerialization;
|
||||
import org.bukkit.craftbukkit.inventory.CraftFurnaceRecipe;
|
||||
import org.bukkit.craftbukkit.inventory.CraftInventoryCustom;
|
||||
import org.bukkit.craftbukkit.inventory.CraftRecipe;
|
||||
import org.bukkit.craftbukkit.inventory.CraftShapedRecipe;
|
||||
import org.bukkit.craftbukkit.inventory.CraftShapelessRecipe;
|
||||
@@ -74,6 +75,7 @@ import org.bukkit.craftbukkit.updater.BukkitDLUpdaterService;
|
||||
import org.bukkit.craftbukkit.util.DatFileFilter;
|
||||
import org.bukkit.craftbukkit.util.Versioning;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.InventoryType;
|
||||
import org.bukkit.event.world.WorldInitEvent;
|
||||
import org.bukkit.event.world.WorldLoadEvent;
|
||||
import org.bukkit.event.world.WorldSaveEvent;
|
||||
@@ -81,6 +83,8 @@ import org.bukkit.event.world.WorldUnloadEvent;
|
||||
import org.bukkit.generator.ChunkGenerator;
|
||||
import org.bukkit.inventory.FurnaceRecipe;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.InventoryHolder;
|
||||
import org.bukkit.inventory.Recipe;
|
||||
import org.bukkit.inventory.ShapedRecipe;
|
||||
import org.bukkit.inventory.ShapelessRecipe;
|
||||
@@ -105,6 +109,7 @@ import org.yaml.snakeyaml.Yaml;
|
||||
import org.yaml.snakeyaml.constructor.SafeConstructor;
|
||||
import org.yaml.snakeyaml.error.MarkedYAMLException;
|
||||
|
||||
import org.apache.commons.lang.Validate;
|
||||
import com.avaje.ebean.config.DataSourceConfig;
|
||||
import com.avaje.ebean.config.ServerConfig;
|
||||
import com.avaje.ebean.config.dbplatform.SQLitePlatform;
|
||||
@@ -1102,4 +1107,19 @@ public final class CraftServer implements Server {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Inventory createInventory(InventoryHolder owner, InventoryType type) {
|
||||
// TODO: Create the appropriate type, rather than Custom?
|
||||
return new CraftInventoryCustom(owner, type);
|
||||
}
|
||||
|
||||
public Inventory createInventory(InventoryHolder owner, int size) throws IllegalArgumentException {
|
||||
Validate.isTrue(size % 9 == 0, "Chests must have a size that is a multiple of 9!");
|
||||
return new CraftInventoryCustom(owner, size);
|
||||
}
|
||||
|
||||
public Inventory createInventory(InventoryHolder owner, int size, String title) throws IllegalArgumentException {
|
||||
Validate.isTrue(size % 9 == 0, "Chests must have a size that is a multiple of 9!");
|
||||
return new CraftInventoryCustom(owner, size, title);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user