use of io.github.bananapuncher714.crafters.implementation.api.PublicCraftingInventory in project PublicCrafters by BananaPuncher714.
the class CustomInventoryCrafting method move.
@Override
public PublicCraftingInventory move(Location location) {
display.stop();
if (manager.get(bloc) == this) {
manager.benches.remove(bloc);
}
bloc = location;
CustomInventoryCrafting whatsHere = manager.put(location, this);
display = new CraftDisplay(this);
display.update();
return whatsHere;
}
use of io.github.bananapuncher714.crafters.implementation.api.PublicCraftingInventory in project PublicCrafters by BananaPuncher714.
the class CustomInventoryCrafting method move.
@Override
public PublicCraftingInventory move(Location location) {
display.stop();
if (manager.get(bloc) == this) {
manager.benches.remove(bloc);
}
bloc = location;
CustomInventoryCrafting whatsHere = manager.put(location, this);
display = new CraftDisplay(this);
display.update();
return whatsHere;
}
use of io.github.bananapuncher714.crafters.implementation.api.PublicCraftingInventory in project PublicCrafters by BananaPuncher714.
the class ContainerManager_v1_11_R1 method remove.
@Override
public void remove(Location location) {
if (benches.containsKey(location)) {
PublicCraftingInventory bench = benches.get(location);
bench.remove();
benches.remove(location);
}
}
use of io.github.bananapuncher714.crafters.implementation.api.PublicCraftingInventory in project PublicCrafters by BananaPuncher714.
the class CraftBlockListener method onPistonRetractEvent.
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
private void onPistonRetractEvent(BlockPistonRetractEvent event) {
BlockFace face = event.getDirection();
Set<PublicCraftingInventory> moveThese = new HashSet<PublicCraftingInventory>();
Set<Location> newLocations = new HashSet<Location>();
for (Block block : event.getBlocks()) {
PublicCraftingInventory crafting = plugin.getManager().get(block.getLocation());
if (crafting != null) {
moveThese.add(crafting);
}
if (plugin.getAdminTables().remove(block.getLocation())) {
newLocations.add(block.getRelative(face).getLocation());
}
}
plugin.getAdminTables().addAll(newLocations);
for (PublicCraftingInventory crafting : moveThese) {
crafting.move(crafting.getLocation().getBlock().getRelative(face).getLocation());
}
}
use of io.github.bananapuncher714.crafters.implementation.api.PublicCraftingInventory in project PublicCrafters by BananaPuncher714.
the class CraftBlockListener method onPistonExtendEvent.
/**
* These are a bit more complicated; First, get all the blocks BEFORE moving them
* Then, you can safely move them; This is to prevent overwriting crafting tables at their new location
* @param event
* The BlockPistonExtendEvent
*/
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
private void onPistonExtendEvent(BlockPistonExtendEvent event) {
BlockFace face = event.getDirection();
Set<PublicCraftingInventory> moveThese = new HashSet<PublicCraftingInventory>();
Set<Location> newLocations = new HashSet<Location>();
for (Block block : event.getBlocks()) {
PublicCraftingInventory crafting = plugin.getManager().get(block.getLocation());
if (crafting != null) {
moveThese.add(crafting);
}
if (plugin.getAdminTables().remove(block.getLocation())) {
newLocations.add(block.getRelative(face).getLocation());
}
}
plugin.getAdminTables().addAll(newLocations);
for (PublicCraftingInventory crafting : moveThese) {
crafting.move(crafting.getLocation().getBlock().getRelative(face).getLocation());
}
}
Aggregations