<commit_before>package io.xchris6041x.devin.gui;

import java.util.ArrayList;
import java.util.List;

import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;

import io.xchris6041x.devin.gui.controls.Button;

/**
 * An abstract class for the pagination of containers
 * with automatic next and previous page controls. Those
 * controls are only shown when there are multiple pages.
 * 
 * @author <NAME>
 */
public abstract class PageableContainer extends Container {
	
	private Button next;
	private Button prev;
	
	private int page = 0;
	
	private List<PageContainer> pages;
	
	/**
	 * @param material - The material of the previous and next buttons.
	 * @param durability - The durability of the previous and next buttons.
	 */
	public PageableContainer(Material material, short durability) {
		this.pages = new ArrayList<PageContainer>();
		
		next = new Button(new ItemStack(material, 1, durability), -1, "Next", (holder, e) -> {
			setPageNumber(++page);
			holder.refresh();
			
			return true;
		});
		prev = new Button(new ItemStack(material, 1, durability), -1, "Previous", (holder, e) -> {
			setPageNumber(--page);
			holder.refresh();
			
			return true;
		});
	}
	
	protected List<PageContainer> getPages() {
		return pages;
	}
	
	/**
	 * Add a static page to this container.
	 * @return the page that was created.
	 */
	public StaticPageContainer addPage() {
		StaticPageContainer page = new StaticPageContainer(this);
		return page;
	}
	
	/**
	 * Add a scrollable page to this container.
	 * @param material - The material of scroll up and down buttons.
	 * @param durability - The durability of the scroll up and down buttons.
	 * @return the page that was created.
	 */
	public ScrollablePageContainer addScrollablePage(Material material, short durability) {
		ScrollablePageContainer page = new ScrollablePageContainer(this, material, durability);
		return page;
	}
	
	/**
	 * Remove a {@code page} from this container.
	 * @param page
	 */
	public void removePage(PageContainer page) {
		pages.remove(page);
		page.setParent(null);
	}
	
	/**
	 * @return the page number that this container is on.
	 */
	public int getPageNumber() {
		return page;
	}
	
	/**
	 * Set the page number of the page being rendered.
	 * @param page - The page to be set too.
	 */
	public void setPageNumber(int page) {
		if(page < 0) page = 0;
		else if(page >= pages.size()) page = pages.size() - 1;
		
		this.page = page;
	}

	/**
	 * @return whether this container has multiple pages.
	 */
	public boolean isMultiPaged() {
		return pages.size() > 1;
	}
	
	/**
	 * {@inheritDoc}
	 */
	@Override
	public void render(Inventory inventory, Player p) {
		if(next.getPosition() < 0) next.setPosition(getSize() - 1);
		if(prev.getPosition() < 0) prev.setPosition(getSize() - Container.WIDTH);
		
		pages.get(page).render(inventory, p);

		if(isMultiPaged()) {
			prev.render(inventory, p, 0, getSize());
			next.render(inventory, p, 0, getSize());
		}
	}
	
	/**
	 * {@inheritDoc}
	 */
	@Override
	public boolean click(FrameHolder holder, InventoryClickEvent e) {
		if(isMultiPaged()) {
			if(next.click(holder, e, 0)) return true;
			if(prev.click(holder, e, 0)) return true;
		}
		
		return pages.get(page).click(holder, e);
	}
	
}
<commit_msg>Removed addPage and removePage methods.<commit_after>package io.xchris6041x.devin.gui;

import java.util.ArrayList;
import java.util.List;

import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;

import io.xchris6041x.devin.gui.controls.Button;

/**
 * An abstract class for the pagination of containers
 * with automatic next and previous page controls. Those
 * controls are only shown when there are multiple pages.
 * 
 * @author <NAME>
 */
public abstract class PageableContainer extends Container {
	
	private Button next;
	private Button prev;
	
	private int page = 0;
	private List<PageContainer> pages;
	
	/**
	 * @param material - The material of the previous and next buttons.
	 * @param durability - The durability of the previous and next buttons.
	 */
	public PageableContainer(Material material, short durability) {
		this.pages = new ArrayList<PageContainer>();
		
		next = new Button(new ItemStack(material, 1, durability), -1, "Next", (holder, e) -> {
			setPageNumber(++page);
			holder.refresh();
			
			return true;
		});
		prev = new Button(new ItemStack(material, 1, durability), -1, "Previous", (holder, e) -> {
			setPageNumber(--page);
			holder.refresh();
			
			return true;
		});
	}
	
	protected List<PageContainer> getPages() {
		return pages;
	}
	
	/**
	 * @return the page number that this container is on.
	 */
	public int getPageNumber() {
		return page;
	}
	
	/**
	 * Set the page number of the page being rendered.
	 * @param page - The page to be set too.
	 */
	public void setPageNumber(int page) {
		if(page < 0) page = 0;
		else if(page >= pages.size()) page = pages.size() - 1;
		
		this.page = page;
	}

	/**
	 * @return whether this container has multiple pages.
	 */
	public boolean isMultiPaged() {
		return pages.size() > 1;
	}
	
	/**
	 * {@inheritDoc}
	 */
	@Override
	public void render(Inventory inventory, Player p) {
		if(next.getPosition() < 0) next.setPosition(getSize() - 1);
		if(prev.getPosition() < 0) prev.setPosition(getSize() - Container.WIDTH);
		
		pages.get(page).render(inventory, p);

		if(isMultiPaged()) {
			prev.render(inventory, p, 0, getSize());
			next.render(inventory, p, 0, getSize());
		}
	}
	
	/**
	 * {@inheritDoc}
	 */
	@Override
	public boolean click(FrameHolder holder, InventoryClickEvent e) {
		if(isMultiPaged()) {
			if(next.click(holder, e, 0)) return true;
			if(prev.click(holder, e, 0)) return true;
		}
		
		return pages.get(page).click(holder, e);
	}
	
}

{'fraction_non_alphanumeric': 0.12720255076355094, 'fraction_numerical': 0.008055042792414835, 'mean_word_length': 3.5810914681014605, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2136110', 'n_tokens_mistral': 2104, 'n_tokens_neox': 1830, 'n_words': 557}