Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 14 additions & 10 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,39 +7,39 @@
<parent>
<groupId>com.github.civclassic</groupId>
<artifactId>civclassic-parent</artifactId>
<version>1.0.0</version>
<version>1.0.1</version>
</parent>

<groupId>com.github.igotyou</groupId>
<artifactId>FactoryMod</artifactId>
<packaging>jar</packaging>
<version>2.5.2</version>
<version>2.6.0</version>
<name>FactoryMod</name>
<url>https://github.com/Civclassic/FactoryMod</url>

<dependencies>
<dependency>
<groupId>com.destroystokyo.paper</groupId>
<groupId>io.papermc.paper</groupId>
<artifactId>paper</artifactId>
<version>1.16.5-R0.1-SNAPSHOT</version>
<version>1.17.1-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>vg.civcraft.mc.namelayer</groupId>
<groupId>com.github.civclassic</groupId>
<artifactId>NameLayer</artifactId>
<version>2.14.1</version>
<version>2.15.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>vg.civcraft.mc.citadel</groupId>
<groupId>com.github.civclassic</groupId>
<artifactId>Citadel</artifactId>
<version>4.1.1</version>
<version>4.2.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>vg.civcraft.mc.civmodcore</groupId>
<groupId>com.github.civclassic</groupId>
<artifactId>CivModCore</artifactId>
<version>1.8.4</version>
<version>1.9.0</version>
<scope>provided</scope>
</dependency>
</dependencies>
Expand All @@ -49,5 +49,9 @@
<id>civ-github-repo</id>
<url>https://raw.githubusercontent.com/CivClassic/artifacts/master/</url>
</repository>
<repository>
<id>papermc</id>
<url>https://papermc.io/repo/repository/maven-public/</url>
</repository>
</repositories>
</project>
48 changes: 24 additions & 24 deletions src/main/java/com/github/igotyou/FactoryMod/ConfigParser.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
package com.github.igotyou.FactoryMod;

import static vg.civcraft.mc.civmodcore.util.ConfigParsing.parseItemMap;
import static vg.civcraft.mc.civmodcore.util.ConfigParsing.parseItemMapDirectly;
import static vg.civcraft.mc.civmodcore.util.ConfigParsing.parseTime;
import static vg.civcraft.mc.civmodcore.util.ConfigParsing.parseTimeAsTicks;
import static vg.civcraft.mc.civmodcore.config.ConfigHelper.parseTime;
import static vg.civcraft.mc.civmodcore.config.ConfigHelper.parseTimeAsTicks;


import com.github.igotyou.FactoryMod.eggs.FurnCraftChestEgg;
import com.github.igotyou.FactoryMod.eggs.IFactoryEgg;
Expand Down Expand Up @@ -58,7 +57,8 @@
import org.bukkit.enchantments.Enchantment;
import org.bukkit.inventory.ItemStack;
import org.bukkit.scheduler.BukkitRunnable;
import vg.civcraft.mc.civmodcore.itemHandling.ItemMap;
import vg.civcraft.mc.civmodcore.config.ConfigHelper;
import vg.civcraft.mc.civmodcore.inventory.items.ItemMap;

public class ConfigParser {
private FactoryMod plugin;
Expand Down Expand Up @@ -115,7 +115,7 @@ public FactoryModManager parse() {
}
defaultUpdateTime = parseTimeAsTicks(config.getString("default_update_time", "250ms"));
defaultHealth = config.getInt("default_health", 10000);
ItemMap dFuel = parseItemMap(config.getConfigurationSection("default_fuel"));
ItemMap dFuel = ConfigHelper.parseItemMap(config.getConfigurationSection("default_fuel"));
if (dFuel.getTotalUniqueItemAmount() > 0) {
defaultFuel = dFuel.getItemStackRepresentation().get(0);
} else {
Expand Down Expand Up @@ -306,7 +306,7 @@ private void parseFactory(ConfigurationSection config) {
if (egg == null) {
break;
}
ItemMap pipeSetupCost = parseItemMap(config.getConfigurationSection("setupcost"));
ItemMap pipeSetupCost = ConfigHelper.parseItemMap(config.getConfigurationSection("setupcost"));
if (pipeSetupCost.getTotalUniqueItemAmount() > 0) {
manager.addFactoryEgg(PipeStructure.class, pipeSetupCost, egg);
} else {
Expand All @@ -318,7 +318,7 @@ private void parseFactory(ConfigurationSection config) {
if (egg == null) {
break;
}
ItemMap sorterSetupCost = parseItemMap(config.getConfigurationSection("setupcost"));
ItemMap sorterSetupCost = ConfigHelper.parseItemMap(config.getConfigurationSection("setupcost"));
if (sorterSetupCost.getTotalUniqueItemAmount() > 0) {
manager.addFactoryEgg(BlockFurnaceStructure.class, sorterSetupCost, egg);
} else {
Expand Down Expand Up @@ -352,7 +352,7 @@ public SorterEgg parseSorter(ConfigurationSection config) {
}
ItemStack fuel;
if (config.contains("fuel")) {
ItemMap tfuel = parseItemMap(config.getConfigurationSection("fuel"));
ItemMap tfuel = ConfigHelper.parseItemMap(config.getConfigurationSection("fuel"));
if (tfuel.getTotalUniqueItemAmount() > 0) {
fuel = tfuel.getItemStackRepresentation().get(0);
} else {
Expand Down Expand Up @@ -390,7 +390,7 @@ public PipeEgg parsePipe(ConfigurationSection config) {
}
ItemStack fuel;
if (config.contains("fuel")) {
ItemMap tfuel = parseItemMap(config.getConfigurationSection("fuel"));
ItemMap tfuel = ConfigHelper.parseItemMap(config.getConfigurationSection("fuel"));
if (tfuel.getTotalUniqueItemAmount() > 0) {
fuel = tfuel.getItemStackRepresentation().get(0);
} else {
Expand Down Expand Up @@ -430,7 +430,7 @@ public IFactoryEgg parseFCCFactory(ConfigurationSection config) {
}
ItemStack fuel;
if (config.contains("fuel")) {
ItemMap tfuel = parseItemMap(config.getConfigurationSection("fuel"));
ItemMap tfuel = ConfigHelper.parseItemMap(config.getConfigurationSection("fuel"));
if (tfuel.getTotalUniqueItemAmount() > 0) {
fuel = tfuel.getItemStackRepresentation().get(0);
} else {
Expand Down Expand Up @@ -468,7 +468,7 @@ public IFactoryEgg parseFCCFactory(ConfigurationSection config) {
double citadelBreakReduction = config.getDouble("citadelBreakReduction", 1.0);
ItemMap setupCost = null;
if (config.isConfigurationSection("setupcost")) {
setupCost = parseItemMap(config.getConfigurationSection("setupcost"));
setupCost = ConfigHelper.parseItemMap(config.getConfigurationSection("setupcost"));
}
FurnCraftChestEgg egg = new FurnCraftChestEgg(name, update, null, fuel, fuelIntervall, returnRate, health,
gracePeriod, healthPerDamageIntervall, citadelBreakReduction, setupCost);
Expand Down Expand Up @@ -540,7 +540,7 @@ private IRecipe parseRecipe(ConfigurationSection config) {
input = ((InputRecipe) parentRecipe).getInput();
}
} else {
input = parseItemMap(inputSection);
input = ConfigHelper.parseItemMap(inputSection);
}
switch (type) {
case "PRODUCTION":
Expand All @@ -556,7 +556,7 @@ private IRecipe parseRecipe(ConfigurationSection config) {
recipeRepresentation = ((ProductionRecipe) parentRecipe).getRecipeRepresentation();
}
} else {
output = parseItemMap(outputSection);
output = ConfigHelper.parseItemMap(outputSection);
recipeRepresentation = parseFirstItem(outputSection);
}
ProductionRecipeModifier modi = parseProductionRecipeModifier(config.getConfigurationSection("modi"));
Expand Down Expand Up @@ -640,7 +640,7 @@ private IRecipe parseRecipe(ConfigurationSection config) {
// This is untested and should not be used for now
plugin.warning(
"This recipe is not tested or even completly developed, use it with great care and don't expect it to work");
ItemMap tessence = parseItemMap(config.getConfigurationSection("essence"));
ItemMap tessence = ConfigHelper.parseItemMap(config.getConfigurationSection("essence"));
if (tessence.getTotalUniqueItemAmount() > 0) {
ItemStack essence = tessence.getItemStackRepresentation().get(0);
int repPerEssence = config.getInt("repair_per_essence");
Expand All @@ -661,7 +661,7 @@ private IRecipe parseRecipe(ConfigurationSection config) {
outputMap = ((PylonRecipe) parentRecipe).getOutput().clone();
}
} else {
outputMap = parseItemMap(outputSec);
outputMap = ConfigHelper.parseItemMap(outputSec);
}
if (outputMap.getTotalItemAmount() == 0) {
plugin.warning("Pylon recipe " + name + " has an empty output specified");
Expand Down Expand Up @@ -696,7 +696,7 @@ private IRecipe parseRecipe(ConfigurationSection config) {
tool = ((DeterministicEnchantingRecipe) parentRecipe).getTool().clone();
}
} else {
tool = parseItemMap(toolSection);
tool = ConfigHelper.parseItemMap(toolSection);
}
if (tool.getTotalItemAmount() == 0) {
plugin.warning("Deterministic enchanting recipe " + name
Expand Down Expand Up @@ -730,7 +730,7 @@ private IRecipe parseRecipe(ConfigurationSection config) {
if (keySec != null) {
double chance = keySec.getDouble("chance");
totalChance += chance;
ItemMap im = parseItemMap(keySec);
ItemMap im = ConfigHelper.parseItemMap(keySec);
outputs.put(im, chance);
if (key.equals(displayMap)) {
displayThis = im;
Expand Down Expand Up @@ -762,7 +762,7 @@ private IRecipe parseRecipe(ConfigurationSection config) {
toolMap = ((LoreEnchantRecipe) parentRecipe).getTool().clone();
}
} else {
toolMap = parseItemMap(toolSec);
toolMap = ConfigHelper.parseItemMap(toolSec);
}
if (toolMap.getTotalItemAmount() == 0) {
plugin.warning("Lore enchanting recipe " + name + " had no tool to enchant specified, it was skipped");
Expand Down Expand Up @@ -816,7 +816,7 @@ private IRecipe parseRecipe(ConfigurationSection config) {
printingPlateOutput = ((PrintingPlateRecipe) parentRecipe).getOutput();
}
} else {
printingPlateOutput = parseItemMap(printingPlateOutputSection);
printingPlateOutput = ConfigHelper.parseItemMap(printingPlateOutputSection);
}
result = new PrintingPlateRecipe(identifier, name, productionTime, input, printingPlateOutput);
break;
Expand All @@ -830,18 +830,18 @@ private IRecipe parseRecipe(ConfigurationSection config) {
printingPlateJsonOutput = ((PrintingPlateJsonRecipe) parentRecipe).getOutput();
}
} else {
printingPlateJsonOutput = parseItemMap(printingPlateJsonOutputSection);
printingPlateJsonOutput = ConfigHelper.parseItemMap(printingPlateJsonOutputSection);
}
result = new PrintingPlateJsonRecipe(identifier, name, productionTime, input, printingPlateJsonOutput);
break;
case "PRINTBOOK":
ItemMap printBookPlate = parseItemMap(config.getConfigurationSection("printingplate"));
ItemMap printBookPlate = ConfigHelper.parseItemMap(config.getConfigurationSection("printingplate"));
int printBookOutputAmount = config.getInt("outputamount", 1);
result = new PrintBookRecipe(identifier, name, productionTime, input, printBookPlate,
printBookOutputAmount);
break;
case "PRINTNOTE":
ItemMap printNotePlate = parseItemMap(config.getConfigurationSection("printingplate"));
ItemMap printNotePlate = ConfigHelper.parseItemMap(config.getConfigurationSection("printingplate"));
int printBookNoteAmount = config.getInt("outputamount", 1);
boolean secureNote = config.getBoolean("securenote", false);
String noteTitle = config.getString("title");
Expand Down Expand Up @@ -903,7 +903,7 @@ private static ItemStack parseFirstItem(ConfigurationSection config) {

for (String key : config.getKeys(false)) {
ConfigurationSection current = config.getConfigurationSection(key);
List<ItemStack> list = parseItemMapDirectly(current).getItemStackRepresentation();
List<ItemStack> list = ConfigHelper.parseItemMapDirectly(current).getItemStackRepresentation();
return list.isEmpty() ? null : list.get(0);
}

Expand Down
3 changes: 3 additions & 0 deletions src/main/java/com/github/igotyou/FactoryMod/FactoryMod.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.github.igotyou.FactoryMod;

import com.github.igotyou.FactoryMod.commands.FMCommandManager;
import com.github.igotyou.FactoryMod.listeners.CitadelListener;
import com.github.igotyou.FactoryMod.listeners.CompactItemListener;
import com.github.igotyou.FactoryMod.listeners.FactoryModListener;
Expand All @@ -10,6 +11,7 @@ public class FactoryMod extends ACivMod {
private FactoryModManager manager;
private static FactoryMod plugin;
private FactoryModPermissionManager permissionManager;
private FMCommandManager commandManager;

@Override
public void onEnable() {
Expand All @@ -21,6 +23,7 @@ public void onEnable() {
if (manager.isCitadelEnabled()) {
permissionManager = new FactoryModPermissionManager();
}
commandManager = new FMCommandManager(this);
registerListeners();
info("Successfully enabled");
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.github.igotyou.FactoryMod;

import com.github.igotyou.FactoryMod.commands.FactoryTabCompleters;
import com.github.igotyou.FactoryMod.eggs.FurnCraftChestEgg;
import com.github.igotyou.FactoryMod.eggs.IFactoryEgg;
import com.github.igotyou.FactoryMod.eggs.PipeEgg;
Expand Down Expand Up @@ -31,7 +30,7 @@
import org.bukkit.block.Dispenser;
import org.bukkit.block.Dropper;
import org.bukkit.entity.Player;
import vg.civcraft.mc.civmodcore.itemHandling.ItemMap;
import vg.civcraft.mc.civmodcore.inventory.items.ItemMap;

/**
* Manager class which handles all factories, their locations and their creation
Expand Down Expand Up @@ -453,7 +452,6 @@ public void addFactoryEgg(Class<? extends MultiBlockStructure> blockStructureCla
eggs.put(recipe, egg);
}
this.eggs.put(egg.getName().toLowerCase(), egg);
FactoryTabCompleters.addFactory(egg.getName());
}

public void saveFactories() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
package com.github.igotyou.FactoryMod;

import java.util.UUID;
import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;
import vg.civcraft.mc.civmodcore.playersettings.PlayerSettingAPI;
import vg.civcraft.mc.civmodcore.playersettings.gui.MenuSection;
import vg.civcraft.mc.civmodcore.playersettings.impl.EnumSetting;

import java.util.UUID;
import vg.civcraft.mc.civmodcore.players.settings.PlayerSettingAPI;
import vg.civcraft.mc.civmodcore.players.settings.gui.MenuSection;
import vg.civcraft.mc.civmodcore.players.settings.impl.EnumSetting;

public class FactoryModPlayerSettings {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
package com.github.igotyou.FactoryMod.commands;

import co.aikar.commands.BaseCommand;
import co.aikar.commands.annotation.CommandAlias;
import co.aikar.commands.annotation.CommandPermission;
import co.aikar.commands.annotation.Description;
import com.github.igotyou.FactoryMod.FactoryMod;
import com.github.igotyou.FactoryMod.FactoryModManager;
import com.github.igotyou.FactoryMod.factories.Factory;
Expand All @@ -11,47 +15,37 @@
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import vg.civcraft.mc.civmodcore.command.CivCommand;
import vg.civcraft.mc.civmodcore.command.StandaloneCommand;

@CivCommand(id = "fmco")
public class CheatOutput extends StandaloneCommand {
public class CheatOutput extends BaseCommand {

@Override
public boolean execute(CommandSender sender, String[] args) {
Player player = (Player) sender;
@CommandAlias("fmco")
@CommandPermission("fm.op")
@Description("Gives you the output of the selected recipe in the factory you are looking at")
public void execute(Player sender) {
Set<Material> transparent = null;
List<Block> view = ((Player) sender).getLineOfSight(transparent, 10);
FactoryModManager manager = FactoryMod.getInstance().getManager();
Factory exis = manager.getFactoryAt(view.get(view.size() - 1));
if (exis != null && exis instanceof FurnCraftChestFactory) {
FurnCraftChestFactory fcc = (FurnCraftChestFactory) exis;
if (fcc.getCurrentRecipe() == null) {
player.sendMessage(ChatColor.RED + "This factory has no recipe selected");
return true;
sender.sendMessage(ChatColor.RED + "This factory has no recipe selected");
return;
}
IRecipe rec = fcc.getCurrentRecipe();
if (!(rec instanceof ProductionRecipe)) {
player.sendMessage(ChatColor.RED + "The selected recipe is not a production recipe");
return true;
sender.sendMessage(ChatColor.RED + "The selected recipe is not a production recipe");
return;
}
ProductionRecipe prod = (ProductionRecipe) rec;
for (ItemStack is : prod.getOutput().getItemStackRepresentation()) {
player.getInventory().addItem(is);
sender.getInventory().addItem(is);
}
player.sendMessage(ChatColor.GREEN + "Gave you all items for recipe " + ChatColor.GREEN + prod.getName());
sender.sendMessage(ChatColor.GREEN + "Gave you all items for recipe " + ChatColor.GREEN + prod.getName());
} else {
player.sendMessage(ChatColor.RED + "You are not looking at a valid factory");
sender.sendMessage(ChatColor.RED + "You are not looking at a valid factory");
}
return true;
}

@Override
public List<String> tabComplete(CommandSender sender, String[] args) {
return null;
}

}
Loading