mirror of
https://github.com/CivMC/Civ.git
synced 2026-07-18 00:20:44 +00:00
Updated managers, main sub-manager nearly done.
This commit is contained in:
@@ -12,9 +12,9 @@ import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import com.github.igotyou.FactoryMod.FactoryObject.FactoryType;
|
||||
import com.github.igotyou.FactoryMod.FactoryObject.SubFactoryType;
|
||||
import com.github.igotyou.FactoryMod.interfaces.Properties;
|
||||
import com.github.igotyou.FactoryMod.managers.FactoryModManager;
|
||||
import com.github.igotyou.FactoryMod.properties.ProductionProperties;
|
||||
import com.github.igotyou.interfaces.Properties;
|
||||
|
||||
public class FactoryModPlugin extends JavaPlugin
|
||||
{
|
||||
@@ -25,6 +25,7 @@ public class FactoryModPlugin extends JavaPlugin
|
||||
public static int AMOUNT_OF_RECIPES_TO_REMOVE;
|
||||
public static int PRODUCTION_MAX_TIERS;
|
||||
public static int PRODUCER_UPDATE_CYCLE;
|
||||
public static String PRODUCTION_SAVES_FILE;
|
||||
|
||||
public void onEnable()
|
||||
{
|
||||
|
||||
@@ -11,9 +11,9 @@ import org.bukkit.block.Dispenser;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import com.github.igotyou.FactoryMod.interfaces.Properties;
|
||||
import com.github.igotyou.FactoryMod.utility.InteractionResponse;
|
||||
import com.github.igotyou.FactoryMod.utility.InteractionResponse.InteractionResult;
|
||||
import com.github.igotyou.interfaces.Properties;
|
||||
|
||||
//original file:
|
||||
/**
|
||||
|
||||
@@ -7,9 +7,9 @@ import org.bukkit.Material;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import com.github.igotyou.FactoryMod.FactoryObject;
|
||||
import com.github.igotyou.FactoryMod.interfaces.Factory;
|
||||
import com.github.igotyou.FactoryMod.managers.ProductionManager;
|
||||
import com.github.igotyou.FactoryMod.utility.InteractionResponse;
|
||||
import com.github.igotyou.interfaces.Factory;
|
||||
|
||||
public class Production extends FactoryObject implements Factory
|
||||
{
|
||||
@@ -39,21 +39,14 @@ public class Production extends FactoryObject implements Factory
|
||||
// TODO add
|
||||
}
|
||||
|
||||
public void destroy(ItemStack item)
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
}
|
||||
|
||||
public void powerOn()
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
active = true;
|
||||
}
|
||||
|
||||
public void powerOff()
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
active = false;
|
||||
}
|
||||
|
||||
public InteractionResponse togglePower()
|
||||
@@ -62,10 +55,19 @@ public class Production extends FactoryObject implements Factory
|
||||
return null;
|
||||
}
|
||||
|
||||
public Location getLocation()
|
||||
public Location getCenterLocation()
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
return factoryLocation;
|
||||
}
|
||||
|
||||
public Location getInventoryLocation()
|
||||
{
|
||||
return factoryInventoryLocation;
|
||||
}
|
||||
|
||||
public Location getPowerSourceLocation()
|
||||
{
|
||||
return factoryPowerSource;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
package com.github.igotyou.FactoryMod.interfaces;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import com.github.igotyou.FactoryMod.utility.InteractionResponse;
|
||||
//original file:
|
||||
/**
|
||||
* Machine.java
|
||||
* Purpose: An interface for machines to implement with basic functionality
|
||||
*
|
||||
* @author MrTwiggy
|
||||
* @version 0.1 1/14/13
|
||||
*/
|
||||
//edited version:
|
||||
/**
|
||||
* Factory.java
|
||||
* Purpose: An interface for machines to implement with basic functionality
|
||||
* @author igotyou
|
||||
*
|
||||
*/
|
||||
public interface Factory
|
||||
{
|
||||
/**
|
||||
* Updates the machine
|
||||
*/
|
||||
public void update();
|
||||
|
||||
/**
|
||||
* Powers on the machine
|
||||
*/
|
||||
public void powerOn();
|
||||
|
||||
/**
|
||||
* Powers off the machine
|
||||
*/
|
||||
public void powerOff();
|
||||
|
||||
/**
|
||||
* Toggles the current power state and returns interaction response
|
||||
*/
|
||||
public InteractionResponse togglePower();
|
||||
|
||||
/**
|
||||
* Returns the location of the machine
|
||||
*/
|
||||
public Location getCenterLocation();
|
||||
|
||||
public Location getInventoryLocation();
|
||||
|
||||
public Location getPowerSourceLocation();
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
package com.github.igotyou.FactoryMod.interfaces;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
import org.bukkit.Location;
|
||||
|
||||
import com.github.igotyou.FactoryMod.utility.InteractionResponse;
|
||||
|
||||
//original file:
|
||||
/**
|
||||
* Manager.java
|
||||
* Purpose: Interface for Manager objects for basic manager functionality
|
||||
*
|
||||
* @author MrTwiggy
|
||||
* @version 0.1 1/08/13
|
||||
*/
|
||||
//edited version:
|
||||
/**
|
||||
* Manager.java
|
||||
* Purpose: Interface for Manager objects for basic manager functionality
|
||||
* @author igotyou
|
||||
*
|
||||
*/
|
||||
|
||||
public interface Manager
|
||||
{
|
||||
|
||||
/**
|
||||
* Saves the machine objects list of this manager to file
|
||||
*/
|
||||
public void save(File file) throws IOException;
|
||||
|
||||
/**
|
||||
* Loads machine objects list of this manager from file
|
||||
*/
|
||||
public void load(File file) throws IOException;
|
||||
|
||||
/**
|
||||
* Updates all the machines from this manager's machine object list
|
||||
*/
|
||||
public void updateFactorys();
|
||||
|
||||
/**
|
||||
* Attempts to create a new machine for this manager
|
||||
*/
|
||||
public InteractionResponse createFactory(Location factoryLocation, Location inventoryLocation, Location powerLocation);
|
||||
|
||||
/**
|
||||
* Creates a machine from an existing machine data object
|
||||
*/
|
||||
public InteractionResponse addFactory(Factory factory);
|
||||
|
||||
/**
|
||||
* Returns the machine (if any exists) at the given location from this manager
|
||||
*/
|
||||
public Factory getFactory(Location factoryLocation);
|
||||
|
||||
/**
|
||||
* Returns whether a machine exists at the given location
|
||||
*/
|
||||
public boolean factoryExistsAt(Location factoryLocation);
|
||||
|
||||
/**
|
||||
* Removes the given machine from the object list
|
||||
*/
|
||||
public void removeFactory(Factory factory);
|
||||
|
||||
/**
|
||||
* Returns the saves file name for this manager
|
||||
*/
|
||||
public String getSavesFileName();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package com.github.igotyou.FactoryMod.interfaces;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.bukkit.Material;
|
||||
|
||||
//original file:
|
||||
/**
|
||||
* Properties.java
|
||||
* Purpose: Interface for Properties objects for basic properties functionality
|
||||
*
|
||||
* @author MrTwiggy
|
||||
* @version 0.1 1/17/13
|
||||
*/
|
||||
//edited version:
|
||||
/**
|
||||
* Properties.java
|
||||
* Purpose: Interface for Properties objects for basic properties functionality
|
||||
* @author igotyou
|
||||
*
|
||||
*/
|
||||
public interface Properties
|
||||
{
|
||||
/**
|
||||
* Returns the amount of upgrade materials required to reach this tier
|
||||
*/
|
||||
public HashMap<Integer,Integer> getBuildAmount();
|
||||
|
||||
/**
|
||||
* Returns the material used to upgrade to this tier
|
||||
*/
|
||||
public HashMap<Integer,Material> getBuildMaterial();
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.github.igotyou.FactoryMod.interfaces;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.bukkit.Material;
|
||||
|
||||
public interface Recipe
|
||||
{
|
||||
//how many output do we produce at once?
|
||||
public int getBatchAmount();
|
||||
|
||||
//the output of this recipe
|
||||
public Material getOutput();
|
||||
|
||||
//get the materials needed for one output
|
||||
public HashMap<Integer,Material> getInputMaterial();
|
||||
|
||||
//get the amount of above material nedded
|
||||
public HashMap<Integer,Integer> getInputAmount();
|
||||
|
||||
//get the recipes name, example: Iron Pickaxe
|
||||
public String getRecipeName();
|
||||
|
||||
//get production time in update cycles
|
||||
public int getProductionTime();
|
||||
|
||||
}
|
||||
@@ -16,11 +16,11 @@ import org.bukkit.inventory.Inventory;
|
||||
import com.github.igotyou.FactoryMod.FactoryModPlugin;
|
||||
import com.github.igotyou.FactoryMod.FactoryObject.SubFactoryType;
|
||||
import com.github.igotyou.FactoryMod.Factorys.Production;
|
||||
import com.github.igotyou.FactoryMod.interfaces.Factory;
|
||||
import com.github.igotyou.FactoryMod.interfaces.Manager;
|
||||
import com.github.igotyou.FactoryMod.properties.ProductionProperties;
|
||||
import com.github.igotyou.FactoryMod.utility.InteractionResponse;
|
||||
import com.github.igotyou.FactoryMod.utility.InteractionResponse.InteractionResult;
|
||||
import com.github.igotyou.interfaces.Factory;
|
||||
import com.github.igotyou.interfaces.Manager;
|
||||
|
||||
public class ProductionManager implements Manager
|
||||
{
|
||||
@@ -60,7 +60,7 @@ public class ProductionManager implements Manager
|
||||
}, 0L, FactoryModPlugin.PRODUCER_UPDATE_CYCLE);
|
||||
}
|
||||
|
||||
public InteractionResponse createFactory(Location factoryLocation, Location inventoryLocation, Location powerLocation)
|
||||
public InteractionResponse createFactory(Location factoryLocation, Location inventoryLocation, Location powerSourceLocation)
|
||||
{
|
||||
if (!factoryExistsAt(factoryLocation))
|
||||
{
|
||||
@@ -87,7 +87,7 @@ public class ProductionManager implements Manager
|
||||
}
|
||||
if (hasMaterials == true && subFactoryType != null)
|
||||
{
|
||||
Production production = new Production(factoryLocation, inventoryLocation, powerLocation,subFactoryType);
|
||||
Production production = new Production(factoryLocation, inventoryLocation, powerSourceLocation,subFactoryType);
|
||||
if (production.buildMaterialAvailable(properties.get(subFactoryType)))
|
||||
{
|
||||
addFactory(production);
|
||||
@@ -102,32 +102,43 @@ public class ProductionManager implements Manager
|
||||
|
||||
public InteractionResponse addFactory(Factory factory)
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
Production production = (Production) factory;
|
||||
if (production.getCenterLocation().getBlock().getType().equals(Material.WORKBENCH) && (!factoryExistsAt(production.getCenterLocation()))
|
||||
|| !factoryExistsAt(production.getInventoryLocation()) || !factoryExistsAt(production.getPowerSourceLocation()))
|
||||
{
|
||||
producers.add(production);
|
||||
return new InteractionResponse(InteractionResult.SUCCESS, "");
|
||||
}
|
||||
else
|
||||
{
|
||||
return new InteractionResponse(InteractionResult.FAILURE, "");
|
||||
}
|
||||
}
|
||||
|
||||
public Factory getFactory(Location factoryLocation)
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
for (Production production : producers)
|
||||
{
|
||||
if (production.getCenterLocation().equals(factoryLocation) || production.getInventory().equals(factoryLocation)
|
||||
|| production.getPowerSourceLocation().equals(factoryLocation))
|
||||
return production;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean factoryExistsAt(Location factoryLocation)
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
return getFactory(factoryLocation) != null;
|
||||
}
|
||||
|
||||
public void removeFactory(Factory factory)
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
producers.remove((Production)factory);
|
||||
}
|
||||
|
||||
public String getSavesFileName()
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
return FactoryModPlugin.PRODUCTION_SAVES_FILE;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -6,8 +6,8 @@ import java.util.List;
|
||||
|
||||
import org.bukkit.Material;
|
||||
|
||||
import com.github.igotyou.FactoryMod.interfaces.Properties;
|
||||
import com.github.igotyou.FactoryMod.recipes.ProductionRecipe;
|
||||
import com.github.igotyou.interfaces.Properties;
|
||||
|
||||
public class ProductionProperties implements Properties
|
||||
{
|
||||
|
||||
@@ -4,7 +4,7 @@ import java.util.HashMap;
|
||||
|
||||
import org.bukkit.Material;
|
||||
|
||||
import com.github.igotyou.interfaces.Recipe;
|
||||
import com.github.igotyou.FactoryMod.interfaces.Recipe;
|
||||
|
||||
public class ProductionRecipe implements Recipe
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user