diff --git a/src/main/java/fr/zcraft/zsorter/ZSorter.java b/src/main/java/fr/zcraft/zsorter/ZSorter.java index 92865da..7cd3474 100644 --- a/src/main/java/fr/zcraft/zsorter/ZSorter.java +++ b/src/main/java/fr/zcraft/zsorter/ZSorter.java @@ -36,7 +36,7 @@ import fr.zcraft.zsorter.events.ItemMoveEvent; import fr.zcraft.zsorter.events.LeftClickEvent; import fr.zcraft.zsorter.model.SorterManager; -import fr.zcraft.zsorter.model.serializer.InventoryAdapter; +import fr.zcraft.zsorter.model.serializer.InventoryHolderAdapter; import fr.zcraft.zsorter.model.serializer.PostProcessAdapterFactory; import fr.zcraft.zsorter.model.serializer.SorterManagerAdapter; import fr.zcraft.zsorter.tasks.SortTask; @@ -159,7 +159,7 @@ private void save() { try { GsonBuilder gsonBuilder = new GsonBuilder(); gsonBuilder.registerTypeAdapterFactory(new PostProcessAdapterFactory()); - gsonBuilder.registerTypeHierarchyAdapter(InventoryHolder.class, new InventoryAdapter()); + gsonBuilder.registerTypeHierarchyAdapter(InventoryHolder.class, new InventoryHolderAdapter()); gsonBuilder.registerTypeAdapter(SorterManager.class, new SorterManagerAdapter()); Gson customGson = gsonBuilder.create(); FileWriter fr = new FileWriter(dataPath); @@ -180,7 +180,7 @@ private boolean load() { try { GsonBuilder gsonBuilder = new GsonBuilder(); gsonBuilder.registerTypeAdapterFactory(new PostProcessAdapterFactory()); - gsonBuilder.registerTypeHierarchyAdapter(InventoryHolder.class, new InventoryAdapter()); + gsonBuilder.registerTypeHierarchyAdapter(InventoryHolder.class, new InventoryHolderAdapter()); gsonBuilder.registerTypeAdapter(SorterManager.class, new SorterManagerAdapter()); Gson customGson = gsonBuilder.create(); BufferedReader br = new BufferedReader(new FileReader(dataFile)); diff --git a/src/main/java/fr/zcraft/zsorter/events/HolderBreakEvent.java b/src/main/java/fr/zcraft/zsorter/events/HolderBreakEvent.java index 00e1a2d..019722c 100644 --- a/src/main/java/fr/zcraft/zsorter/events/HolderBreakEvent.java +++ b/src/main/java/fr/zcraft/zsorter/events/HolderBreakEvent.java @@ -27,7 +27,7 @@ public class HolderBreakEvent implements Listener{ public void onBlockBreak(BlockBreakEvent e) { if(ZSorter.getInstance().isEnable()) { //If the plugin is not enable try { - InventoryHolder inventory = InventoryUtils.findInventoryFromBlock(e.getBlock()); //Get the inventory + InventoryHolder inventory = InventoryUtils.findInventoryFromBlock(e.getBlock()); //Get the holder Sorter sorter = ZSorter.getInstance().getSorterManager().getInventoryToSorter().get(inventory); //Get the associated sorter if(sorter != null) { //If a sorter has been found if(sorter.removeInput(inventory) != null){ //Try to remove the input inventory diff --git a/src/main/java/fr/zcraft/zsorter/events/InventoryEvent.java b/src/main/java/fr/zcraft/zsorter/events/InventoryEvent.java index a785b68..c63a908 100644 --- a/src/main/java/fr/zcraft/zsorter/events/InventoryEvent.java +++ b/src/main/java/fr/zcraft/zsorter/events/InventoryEvent.java @@ -22,8 +22,8 @@ public class InventoryEvent implements Listener{ @EventHandler public void onInventoryCloseEvent(InventoryCloseEvent e) { if(ZSorter.getInstance().isEnable()) { //If the plugin is not enable - InventoryHolder holder = InventoryUtils.doubleHolderToSimpleHolder(e.getInventory().getHolder()); //Get the inventory if double chest - ZSorter.getInstance().getSorterManager().computeSorter(holder, true); //Try to compute the sorter with this inventory + InventoryHolder holder = InventoryUtils.doubleHolderToSimpleHolder(e.getInventory().getHolder()); //Get the holder if double chest + ZSorter.getInstance().getSorterManager().computeSorter(holder, true); //Try to compute the sorter with this holder } } } diff --git a/src/main/java/fr/zcraft/zsorter/events/ItemMoveEvent.java b/src/main/java/fr/zcraft/zsorter/events/ItemMoveEvent.java index 1bd0b53..2124d31 100644 --- a/src/main/java/fr/zcraft/zsorter/events/ItemMoveEvent.java +++ b/src/main/java/fr/zcraft/zsorter/events/ItemMoveEvent.java @@ -22,10 +22,10 @@ public class ItemMoveEvent implements Listener{ @EventHandler public void onInventoryMoveItem(InventoryMoveItemEvent e) { if(ZSorter.getInstance().isEnable()) { //If the plugin is not enable - InventoryHolder inputInventory = InventoryUtils.doubleHolderToSimpleHolder(e.getDestination().getHolder()); //Get the inventory if double chest + InventoryHolder inputInventory = InventoryUtils.doubleHolderToSimpleHolder(e.getDestination().getHolder()); //Get the holder if double chest boolean computed = ZSorter.getInstance().getSorterManager().computeSorter(inputInventory, true); //Try to compute the sorter with this input if(!computed) { //If no computed - InventoryHolder outputInventory = InventoryUtils.doubleHolderToSimpleHolder(e.getSource().getHolder()); //Get the inventory if double chest + InventoryHolder outputInventory = InventoryUtils.doubleHolderToSimpleHolder(e.getSource().getHolder()); //Get the holder if double chest ZSorter.getInstance().getSorterManager().computeSorter(outputInventory, false); //Try to compute the sorter with this output } } diff --git a/src/main/java/fr/zcraft/zsorter/events/LeftClickEvent.java b/src/main/java/fr/zcraft/zsorter/events/LeftClickEvent.java index ae61e52..ca422d4 100644 --- a/src/main/java/fr/zcraft/zsorter/events/LeftClickEvent.java +++ b/src/main/java/fr/zcraft/zsorter/events/LeftClickEvent.java @@ -27,16 +27,16 @@ public class LeftClickEvent implements Listener{ */ @EventHandler public void onPlayerInteractEvent(PlayerInteractEvent e) { - if(ZSorter.getInstance().isEnable()) { //If the plugin is not enable + if(ZSorter.getInstance().isEnable()) { //If the plugin is not enable if(e.getAction() == Action.LEFT_CLICK_BLOCK) { //The player left click on a block Sorter sorter = ZSorter.getInstance().getSorterManager().getPlayerToSorter().get(e.getPlayer()); //Get the sorter the player if(sorter != null){ //If sorter found int priority = 1; //Defines the priority of the output try { - InventoryHolder inventory = InventoryUtils.findInventoryFromBlock(e.getClickedBlock()); + InventoryHolder holder = InventoryUtils.findInventoryFromBlock(e.getClickedBlock()); //Try to add the output to the sorter - ZSorter.getInstance().getSorterManager().setOutput(sorter.getName(), inventory, priority, Arrays.asList(e.getItem().getType())); + ZSorter.getInstance().getSorterManager().setOutput(sorter.getName(), holder, priority, Arrays.asList(e.getItem().getType())); e.getPlayer().sendMessage(ChatColor.GREEN + I.t("This holder is now an output of priority {0}.", priority)); e.setCancelled(true); } diff --git a/src/main/java/fr/zcraft/zsorter/model/Input.java b/src/main/java/fr/zcraft/zsorter/model/Input.java index 0a398b3..4c75067 100644 --- a/src/main/java/fr/zcraft/zsorter/model/Input.java +++ b/src/main/java/fr/zcraft/zsorter/model/Input.java @@ -23,11 +23,11 @@ public class Input extends InputOutput implements Serializable{ /** * Constructor of an output object. - * @param inventory - Inventory of the output. + * @param holder - Holder of the output. * @param priority - Priority of the output. */ - public Input(InventoryHolder inventory, Integer priority) { - super(inventory, priority); + public Input(InventoryHolder holder, Integer priority) { + super(holder, priority); this.cloggedUp = false; } diff --git a/src/main/java/fr/zcraft/zsorter/model/Output.java b/src/main/java/fr/zcraft/zsorter/model/Output.java index 13055e0..d2c4003 100644 --- a/src/main/java/fr/zcraft/zsorter/model/Output.java +++ b/src/main/java/fr/zcraft/zsorter/model/Output.java @@ -32,11 +32,11 @@ public class Output extends InputOutput implements Serializable{ /** * Constructor of an output object. - * @param inventory - Inventory of the output. + * @param holder - Holder of the output. * @param priority - Priority of the output. */ - public Output(InventoryHolder inventory, Integer priority) { - super(inventory, priority); + public Output(InventoryHolder holder, Integer priority) { + super(holder, priority); this.materials = new ArrayList(); this.full = false; } diff --git a/src/main/java/fr/zcraft/zsorter/model/Sorter.java b/src/main/java/fr/zcraft/zsorter/model/Sorter.java index e89547d..a1a4353 100644 --- a/src/main/java/fr/zcraft/zsorter/model/Sorter.java +++ b/src/main/java/fr/zcraft/zsorter/model/Sorter.java @@ -48,8 +48,8 @@ public class Sorter implements Serializable, PostProcessable{ private transient boolean toCompute; private int speed; - private transient Map inventoryToInput; - private transient Map inventoryToOutput; + private transient Map holderToInput; + private transient Map holderToOutput; private transient Map> materialToOutputs; private transient List overflows; @@ -78,8 +78,8 @@ public Sorter(String name, String description) { this.toCompute = false; this.speed = DEFAULT_SPEED; - this.inventoryToInput = new HashMap(); - this.inventoryToOutput = new HashMap(); + this.holderToInput = new HashMap(); + this.holderToOutput = new HashMap(); this.materialToOutputs = new TreeMap>(); this.overflows = new ArrayList(); @@ -177,7 +177,7 @@ public void setSpeed(int speed) { * @return The sorter inputs. */ public Map getInventoryToInput() { - return inventoryToInput; + return holderToInput; } /** @@ -187,7 +187,7 @@ public Map getInventoryToInput() { * @return The sorter outputs. */ public Map getInventoryToOutput() { - return inventoryToOutput; + return holderToOutput; } /** @@ -226,17 +226,17 @@ public List getCloggingUpMaterials() { * Sorts the input outputs by order of priority. */ public void commit() { - inputs = inventoryToInput.values().stream().collect(Collectors.toList()); + inputs = holderToInput.values().stream().collect(Collectors.toList()); Collections.sort(inputs); //Sort the inputs - outputs = inventoryToOutput.values().stream().collect(Collectors.toList()); + outputs = holderToOutput.values().stream().collect(Collectors.toList()); Collections.sort(outputs); //Sort the outputs - overflows = inventoryToOutput.values().stream().filter(o -> o.isOverflow()).collect(Collectors.toList()); + overflows = holderToOutput.values().stream().filter(o -> o.isOverflow()).collect(Collectors.toList()); Collections.sort(overflows); //Sort the overflows materialToOutputs = new HashMap>(); - for(Output output:inventoryToOutput.values()) { //For each output + for(Output output:holderToOutput.values()) { //For each output for(Material material:output.getMaterials()) { //For each material List possibleOutputs = materialToOutputs.get(material); //Get the possible outputs for the given material if(possibleOutputs == null) { //If none have been found @@ -252,22 +252,22 @@ public void commit() { } /** - * Sets the inventory has an input.

+ * Sets the holder has an input.

* If the input already exists, the priority is updated. - * @param inventory - Inventory of the input. + * @param holder - Holder of the input. * @param priority - Priority of the input. * @return The created input object. * @throws ZSorterException if a ZSorter exception occurs. */ - public Input setInput(InventoryHolder inventory, int priority) throws ZSorterException { - Output output = inventoryToOutput.get(inventory); //Get the existing output + public Input setInput(InventoryHolder holder, int priority) throws ZSorterException { + Output output = holderToOutput.get(holder); //Get the existing output if(output != null) //If exists throw new ZSorterException(I.t("This holder is already an output.")); //Display error message - Input existingInput = inventoryToInput.get(inventory); //Get the existing input + Input existingInput = holderToInput.get(holder); //Get the existing input if(existingInput == null) { //If no input exists - existingInput = new Input(inventory, priority); //Create a new input - inventoryToInput.put(inventory, existingInput); //Add the new input + existingInput = new Input(holder, priority); //Create a new input + holderToInput.put(holder, existingInput); //Add the new input } else { //If the input exists existingInput.setPriority(priority); //Set the new priority @@ -278,35 +278,35 @@ public Input setInput(InventoryHolder inventory, int priority) throws ZSorterExc /** * Remove an input from a sorter. - * @param inventory - Inventory of the input. - * @return The removed input object, {@code null} if no input found for this inventory. + * @param holder - Holder of the input. + * @return The removed input object, {@code null} if no input found for this holder. */ - public Input removeInput(InventoryHolder inventory) { - Input result = inventoryToInput.remove(inventory); + public Input removeInput(InventoryHolder holder) { + Input result = holderToInput.remove(holder); if(result != null) commit(); return result; } /** - * Sets the inventory has an output.

+ * Sets the holder has an output.

* If the output already exists, the priority and the materials are updated. - * @param inventory - Inventory of the output. + * @param holder - Holder of the output. * @param priority - Priority of the output. * @param materials - Sorted materials of the output. * @return The created output object. * @throws ZSorterException if a ZSorter exception occurs. */ - public Output setOutput(InventoryHolder inventory, int priority, List materials) throws ZSorterException { - Input input = inventoryToInput.get(inventory); //Get the existing input + public Output setOutput(InventoryHolder holder, int priority, List materials) throws ZSorterException { + Input input = holderToInput.get(holder); //Get the existing input if(input != null) //If exists throw new ZSorterException(I.t("This holder is already an input.")); //Display error message - Output existingOutput = inventoryToOutput.get(inventory); //Get the existing output + Output existingOutput = holderToOutput.get(holder); //Get the existing output if(existingOutput == null) { //If no existing output - existingOutput = new Output(inventory, priority); //Create a new output + existingOutput = new Output(holder, priority); //Create a new output existingOutput.setMaterials(materials); //Add the materials - inventoryToOutput.put(inventory, existingOutput); //Add the new output + holderToOutput.put(holder, existingOutput); //Add the new output } else { //If the output exists existingOutput.setPriority(priority); //Set the new priority @@ -318,11 +318,11 @@ public Output setOutput(InventoryHolder inventory, int priority, List /** * Remove an output from a sorter. - * @param inventory - Inventory of the output. - * @return The removed output object, {@code null} if no output found at this inventory. + * @param holder - Holder of the output. + * @return The removed output object, {@code null} if no output found at this holder. */ - public Output removeOutput(InventoryHolder inventory) { - Output result = inventoryToOutput.remove(inventory); + public Output removeOutput(InventoryHolder holder) { + Output result = holderToOutput.remove(holder); if(result != null) commit(); return result; @@ -445,10 +445,10 @@ public RawText toRawText(DisplayMode mode) { .hover(new RawText() .then(I.t("Change the sorting speed"))) .suggest(SpeedCommand.class, name) - .then("\n " + I.t("{0} input(s):", inventoryToInput.size()) + "\n ") + .then("\n " + I.t("{0} input(s):", holderToInput.size()) + "\n ") .color(ChatColor.GRAY); - List inputs = inventoryToInput + List inputs = holderToInput .values() .stream() .sorted() @@ -482,7 +482,7 @@ public RawText toRawText(DisplayMode mode) { //if display by output if(mode == DisplayMode.OUTPUTS) { - List outputs = inventoryToOutput + List outputs = holderToOutput .values() .stream() .filter(o -> !o.isOverflow()) @@ -522,7 +522,7 @@ public RawText toRawText(DisplayMode mode) { } //If display by items else if(mode == DisplayMode.ITEMS){ - List sortedMaterials = inventoryToOutput + List sortedMaterials = holderToOutput .values() .stream() .filter(o -> !o.isOverflow()) @@ -594,13 +594,13 @@ public boolean equals(Object obj) { @Override public void postProcess() { - inventoryToInput = new HashMap(); + holderToInput = new HashMap(); for(Input input:inputs) { - inventoryToInput.putIfAbsent(input.getHolder(), input); + holderToInput.putIfAbsent(input.getHolder(), input); } - inventoryToOutput = new HashMap(); + holderToOutput = new HashMap(); for(Output output:outputs) { - inventoryToOutput.putIfAbsent(output.getHolder(), output); + holderToOutput.putIfAbsent(output.getHolder(), output); } commit(); if(enable) diff --git a/src/main/java/fr/zcraft/zsorter/model/SorterManager.java b/src/main/java/fr/zcraft/zsorter/model/SorterManager.java index fb04561..2d421a8 100644 --- a/src/main/java/fr/zcraft/zsorter/model/SorterManager.java +++ b/src/main/java/fr/zcraft/zsorter/model/SorterManager.java @@ -28,14 +28,14 @@ public class SorterManager implements Serializable{ private static final long serialVersionUID = -1782855927147248287L; private Map nameToSorter; - private transient Map inventoryToSorter; + private transient Map holderToSorter; private transient Map playerToSorter; /** * Constructor of a sorter manager object. */ public SorterManager() { - this.inventoryToSorter = new HashMap(); + this.holderToSorter = new HashMap(); this.nameToSorter = new TreeMap(); this.playerToSorter = new HashMap(); } @@ -57,13 +57,13 @@ public Map getPlayerToSorter() { } /** - * Returns the map linking a inventory to a sorter.

+ * Returns the map linking a holder to a sorter.

* Do not use this method if you need to add or remove a sorter. * Use the {@code addSorter} and {@code deleteSorter} methods instead. * @return The sorters of the plugin. */ public Map getInventoryToSorter() { - return inventoryToSorter; + return holderToSorter; } /** @@ -93,88 +93,88 @@ public Sorter deleteSorter(String name) throws ZSorterException { throw new ZSorterException(I.t("There is no sorter with this name.")); //Display error message for(Input input:sorter.getInventoryToInput().values()) //For each input of the sorter - inventoryToSorter.remove(input.getHolder()); //Remove the input from the inventory to sorter map + holderToSorter.remove(input.getHolder()); //Remove the input from the holder to sorter map for(Input input:sorter.getInventoryToInput().values()) //For each ouput of the sorter - inventoryToSorter.remove(input.getHolder()); //Remove the output from the inventory to sorter map + holderToSorter.remove(input.getHolder()); //Remove the output from the holder to sorter map return sorter; } /** * Sets a new sorter input. * @param name - Name of the sorter. - * @param inventory - Input inventory. + * @param holder - Input holder. * @param priority - Priority of the input. * @throws ZSorterException if a ZSorter exception occurs. */ - public void setInput(String name, InventoryHolder inventory, int priority) throws ZSorterException { + public void setInput(String name, InventoryHolder holder, int priority) throws ZSorterException { Sorter sorter = nameToSorter.get(name); if(sorter == null) throw new ZSorterException(I.t("There is no sorter with this name.")); - Sorter existingSorter = inventoryToSorter.putIfAbsent(inventory, sorter); //Get the sorter with this input + Sorter existingSorter = holderToSorter.putIfAbsent(holder, sorter); //Get the sorter with this input if(existingSorter != null && !sorter.equals(existingSorter)) //If the sorter is not this one throw new ZSorterException(I.t("This holder is already in use by the sorter {0}.", sorter.getName())); //Display error messsage - sorter.setInput(inventory, priority); + sorter.setInput(holder, priority); } /** * Remove an input from a sorter. * @param name - Name of the sorter. - * @param inventory - Inventory of the input. - * @return The removed input object, {@code null} if no input found for this inventory. + * @param holder - Holder of the input. + * @return The removed input object, {@code null} if no input found for this holder. * @throws ZSorterException if a ZSorter exception occurs. */ - public Input removeInput(String name, InventoryHolder inventory) throws ZSorterException { + public Input removeInput(String name, InventoryHolder holder) throws ZSorterException { Sorter sorter = nameToSorter.get(name); if(sorter == null) throw new ZSorterException(I.t("There is no sorter with this name.")); - Input input = sorter.removeInput(inventory); + Input input = sorter.removeInput(holder); if(input == null) throw new ZSorterException(I.t("This holder is not an input.")); - inventoryToSorter.remove(inventory); //Unkink the sorter + holderToSorter.remove(holder); //Unkink the sorter return input; } /** * Sets a new sorter output. * @param name - Name of the sorter. - * @param inventory - Output inventory. + * @param holder - Output holder. * @param priority - Priority of the output. * @param materials - Materials of the output. * @throws ZSorterException if a ZSorter exception occurs. */ - public void setOutput(String name, InventoryHolder inventory, int priority, List materials) throws ZSorterException { + public void setOutput(String name, InventoryHolder holder, int priority, List materials) throws ZSorterException { Sorter sorter = nameToSorter.get(name); if(sorter == null) throw new ZSorterException(I.t("There is no sorter with this name.")); - Sorter existingSorter = inventoryToSorter.putIfAbsent(inventory, sorter); //Get the sorter with this input + Sorter existingSorter = holderToSorter.putIfAbsent(holder, sorter); //Get the sorter with this input if(existingSorter != null && !sorter.equals(existingSorter)) //If the sorter is not this one throw new ZSorterException(I.t("This holder is already in use by the sorter {0}.", sorter.getName())); //Display error messsage - sorter.setOutput(inventory, priority, materials); + sorter.setOutput(holder, priority, materials); } /** * Remove an output from a sorter. * @param name - Name of the sorter. - * @param inventory - Inventory of the output. - * @return The removed output object, {@code null} if no output found for this inventory. + * @param holder - Holder of the output. + * @return The removed output object, {@code null} if no output found for this holder. * @throws ZSorterException if a ZSorter exception occurs. */ - public Output removeOutput(String name, InventoryHolder inventory) throws ZSorterException { + public Output removeOutput(String name, InventoryHolder holder) throws ZSorterException { Sorter sorter = nameToSorter.get(name); if(sorter == null) throw new ZSorterException(I.t("There is no sorter with this name.")); - Output output = sorter.removeOutput(inventory); + Output output = sorter.removeOutput(holder); if(output == null) throw new ZSorterException(I.t("This holder is not an output.")); - inventoryToSorter.remove(inventory); //Unkink the sorter + holderToSorter.remove(holder); //Unkink the sorter return output; } @@ -191,24 +191,24 @@ public List canCompute(){ } /** - * Compute the sorter associated with this inventory. - * Don't do anything if the inventory is not an input or an output. - * @param inventory - Inventory of the sorter to compute. + * Compute the sorter associated with this holder. + * Don't do anything if the holder is not an input or an output. + * @param holder - Holder of the sorter to compute. * @param checkContent - Defines the rule to apply for the output full flag. {@code true} to define the flag regarding the output content, {@code false} to set it to {@code false} anyway. * @return {@code true} if the sorter has been computed, {@code false} otherwise. */ - public boolean computeSorter(InventoryHolder inventory, boolean checkContent) { + public boolean computeSorter(InventoryHolder holder, boolean checkContent) { boolean computed = false; - Sorter sorter = inventoryToSorter.get(inventory); //Get the sorter associated with this inventory + Sorter sorter = holderToSorter.get(holder); //Get the sorter associated with this holder if(sorter != null && sorter.isEnable()) { //If sorter found and enable - Input input = sorter.getInventoryToInput().get(inventory); //Get the input linked to this inventory + Input input = sorter.getInventoryToInput().get(holder); //Get the input linked to this holder if(input != null) { //If input found sorter.setToCompute(true); //Set the sorter to compute SortTask.getInstance().start(); //Start the task computed = true; } else { - Output output = sorter.getInventoryToOutput().get(inventory); //Get the output linked to this inventory + Output output = sorter.getInventoryToOutput().get(holder); //Get the output linked to this holder if(output != null) { //If output found boolean clogging = output.getMaterials() @@ -236,7 +236,7 @@ public boolean computeSorter(InventoryHolder inventory, boolean checkContent) { public int hashCode() { final int prime = 31; int result = 1; - result = prime * result + ((inventoryToSorter == null) ? 0 : inventoryToSorter.hashCode()); + result = prime * result + ((holderToSorter == null) ? 0 : holderToSorter.hashCode()); result = prime * result + ((nameToSorter == null) ? 0 : nameToSorter.hashCode()); return result; } @@ -250,10 +250,10 @@ public boolean equals(Object obj) { if (getClass() != obj.getClass()) return false; SorterManager other = (SorterManager) obj; - if (inventoryToSorter == null) { - if (other.inventoryToSorter != null) + if (holderToSorter == null) { + if (other.holderToSorter != null) return false; - } else if (!inventoryToSorter.equals(other.inventoryToSorter)) + } else if (!holderToSorter.equals(other.holderToSorter)) return false; if (nameToSorter == null) { if (other.nameToSorter != null) diff --git a/src/main/java/fr/zcraft/zsorter/model/serializer/InventoryAdapter.java b/src/main/java/fr/zcraft/zsorter/model/serializer/InventoryHolderAdapter.java similarity index 93% rename from src/main/java/fr/zcraft/zsorter/model/serializer/InventoryAdapter.java rename to src/main/java/fr/zcraft/zsorter/model/serializer/InventoryHolderAdapter.java index 32e0e6d..be05ebf 100644 --- a/src/main/java/fr/zcraft/zsorter/model/serializer/InventoryAdapter.java +++ b/src/main/java/fr/zcraft/zsorter/model/serializer/InventoryHolderAdapter.java @@ -23,7 +23,7 @@ * @author Lucas * */ -public class InventoryAdapter implements JsonSerializer, JsonDeserializer{ +public class InventoryHolderAdapter implements JsonSerializer, JsonDeserializer{ @Override public JsonElement serialize(InventoryHolder src, Type typeOfSrc, JsonSerializationContext context) { diff --git a/src/main/java/fr/zcraft/zsorter/utils/InventoryUtils.java b/src/main/java/fr/zcraft/zsorter/utils/InventoryUtils.java index 8082d49..6fa17e5 100644 --- a/src/main/java/fr/zcraft/zsorter/utils/InventoryUtils.java +++ b/src/main/java/fr/zcraft/zsorter/utils/InventoryUtils.java @@ -31,9 +31,9 @@ public static InventoryHolder doubleHolderToSimpleHolder(InventoryHolder holder) } /** - * Find the inventory of a block. - * @param block - Block from which get the inventory. - * @return The inventory corresponding to the block location. + * Find the holder of a block. + * @param block - Block from which get the holder. + * @return Holder corresponding to the block location. * @throws ZSorterException if the block is not an instance of {@code InventoryHolder}; */ public static InventoryHolder findInventoryFromBlock(Block block) throws ZSorterException { diff --git a/src/test/java/fr/zcraft/zsorter/model/SorterManagerTest.java b/src/test/java/fr/zcraft/zsorter/model/SorterManagerTest.java index babf7cd..c46b025 100644 --- a/src/test/java/fr/zcraft/zsorter/model/SorterManagerTest.java +++ b/src/test/java/fr/zcraft/zsorter/model/SorterManagerTest.java @@ -17,7 +17,7 @@ import fr.zcraft.zsorter.ZSorterException; import fr.zcraft.zsorter.ZSorterTest; -import fr.zcraft.zsorter.model.serializer.InventoryAdapter; +import fr.zcraft.zsorter.model.serializer.InventoryHolderAdapter; import fr.zcraft.zsorter.model.serializer.PostProcessAdapterFactory; import fr.zcraft.zsorter.model.serializer.SorterManagerAdapter; @@ -136,7 +136,7 @@ public void gsonSerializationTest() throws ZSorterException, FileNotFoundExcepti GsonBuilder gsonBuilder = new GsonBuilder(); gsonBuilder.registerTypeAdapterFactory(new PostProcessAdapterFactory()); - gsonBuilder.registerTypeHierarchyAdapter(Inventory.class, new InventoryAdapter()); + gsonBuilder.registerTypeHierarchyAdapter(Inventory.class, new InventoryHolderAdapter()); gsonBuilder.registerTypeAdapter(SorterManager.class, new SorterManagerAdapter()); Gson customGson = gsonBuilder.create();