diff --git a/README.md b/README.md index 8b5c719a..9c790e29 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ # Citadel -Jenkins Build Server can be found: http://192.99.169.83:8080/job/Citadel-master/ +Original Citadel Jenkins Build Server can be found here: http://build.civcraft.co/job/Citadel-master/ -Java Docs: http://192.99.169.83:8080/job/Citadel-master/javadoc/ +Basic new player tutorial: https://www.reddit.com/r/Devoted/wiki/plugins/citadel + +If you need help installing Citadel, follow this guide: https://github.com/ProgrammerDan/civcraft-vm diff --git a/config.yml b/config.yml index 66afee2e..b345131e 100644 --- a/config.yml +++ b/config.yml @@ -2,7 +2,7 @@ # requirements is the amount of the material needed to create a reinforcement. # return is the amount of material to return. # percent_chance is the chance to return the block. Scales with damage. -# scale_amount is, if maturation is enabled, the amount extra to damage a block if it is not fully matured. The forumla for calculating the extra damage is 1/((time left of maturation) / (default amount of time for maturation)) * scale. So if a block has 5 minutes left of maturation on a 10 minute default period with a scale of 3 we do 1/(5 / 10) * 3 = 6 damage. Setting scale amount to 0 disables this function. +# scale_amount is, if maturation is enabled, the amount extra to damage a block if it is not fully matured. The forumla for calculating the extra damage is 1/(1-((time left of maturation) / (default amount of time for maturation))) * scale. So if a block has 5 minutes left of maturation on a 10 minute default period with a scale of 3 we do 1/(5 / 10) * 3 = 6 damage. Setting scale amount to 0 disables this function. reinforcements: diamond: material: DIAMOND @@ -12,7 +12,8 @@ reinforcements: hit_points: 1800 # mature time is in minutes mature_time: 1440 - scale_amount: 0 + acid_time: 1440 + scale_amount: 1 lore: # Delete the comment char to use lore. Three spaces are required # after lore. You can add multiple lines by adding - @@ -24,7 +25,8 @@ reinforcements: percent_chance: 100 hit_points: 250 mature_time: 60 - scale_amount: 0 + acid_time: 60 + scale_amount: 1 lore: stone: material: STONE @@ -33,7 +35,8 @@ reinforcements: percent_chance: 100 hit_points: 25 mature_time: 10 - scale_amount: 0 + acid_time: 10 + scale_amount: 1 lore: bedrock: material: BEDROCK @@ -42,7 +45,8 @@ reinforcements: percent_chance: 100 hit_points: 2147483646 mature_time: 2147483646 - scale_amount: 0 + acid_time: 2147483646 + scale_amount: 1 lore: #natural_reinforcements: #diamond_ore: diff --git a/plugin.yml b/plugin.yml index e975be80..db1c3cbc 100644 --- a/plugin.yml +++ b/plugin.yml @@ -6,14 +6,14 @@ depend: [NameLayer, CivModCore] description: Citadel allows you to make blocks difficult to break. When a block is reinforced, it must be broken many times before it is destroyed. commands: ctr: - aliases: [ctreinforce] + aliases: [ctreinforce, reinforce, protect, cprivate, lwc, private] ctacid: ctf: - aliases: [ctfortify] + aliases: [ctfortify, fortify] ctb: - aliases: [ctbypass] + aliases: [ctbypass, bypass] cti: - aliases: [ctinformation] + aliases: [ctinformation, info] ctin: aliases: [ctinsecure] ctm: diff --git a/pom.xml b/pom.xml index bcb4c1b9..85054fc4 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ vg.civcraft.mc.citadel Citadel jar - 3.3.9 + 3.4.0 Citadel https://github.com/Civcraft/Citadel diff --git a/src/vg/civcraft/mc/citadel/CitadelConfigManager.java b/src/vg/civcraft/mc/citadel/CitadelConfigManager.java index 17facec6..12ebcf57 100644 --- a/src/vg/civcraft/mc/citadel/CitadelConfigManager.java +++ b/src/vg/civcraft/mc/citadel/CitadelConfigManager.java @@ -63,6 +63,10 @@ public static int getHitPoints(String type){ public static int getMaturationTime(String type){ return config.getInt("reinforcements." + type + ".mature_time"); } + + public static int getAcidTime(String type) { + return config.getInt("reinforcements." + type + ".acid_time", getMaturationTime(type)); + } public static int getMaturationScale(String type){ return config.getInt("reinforcements." + type + ".scale_amount"); diff --git a/src/vg/civcraft/mc/citadel/Utility.java b/src/vg/civcraft/mc/citadel/Utility.java index 167deb79..8ea3c2ca 100644 --- a/src/vg/civcraft/mc/citadel/Utility.java +++ b/src/vg/civcraft/mc/citadel/Utility.java @@ -100,7 +100,8 @@ public static PlayerReinforcement createPlayerReinforcement(Player player, Group } // Fire the creation event PlayerReinforcement rein = new PlayerReinforcement(block.getLocation(), - type.getHitPoints(), getIntFormofMaturation(System.currentTimeMillis(),type.getItemStack()), + type.getHitPoints(), getIntFormofMaturation(System.currentTimeMillis(),type.getItemStack()), + getIntFormofAcidMaturation(System.currentTimeMillis(),type.getItemStack()), g, type.getItemStack(), g.getGroupId()); ReinforcementCreationEvent event = new ReinforcementCreationEvent(rein, block, player); Bukkit.getPluginManager().callEvent(event); @@ -160,7 +161,8 @@ public static PlayerReinforcement createPlayerReinforcementWithoutMaterialConsum return null; } PlayerReinforcement rein = new PlayerReinforcement(block.getLocation(), - type.getHitPoints(), getIntFormofMaturation(System.currentTimeMillis(),type.getItemStack()), + type.getHitPoints(), getIntFormofMaturation(System.currentTimeMillis(),type.getItemStack()), + getIntFormofAcidMaturation(System.currentTimeMillis(),type.getItemStack()), g, type.getItemStack(), g.getGroupId()); ReinforcementCreationEvent event = new ReinforcementCreationEvent(rein, block, player); Bukkit.getPluginManager().callEvent(event); @@ -354,6 +356,30 @@ public static int timeUntilMature(Reinforcement reinforcement) { } return 0; } + /** + * Used to get the amount of time left until a reinforcement's acid component is mature. + * @param Reinforcement. + * @return Returns 0 if it is mature or the time in minutes until it is mature. + */ + public static int timeUntilAcidMature(Reinforcement reinforcement) { + // Doesn't explicitly save the updated Acid Maturation time into the cache. + // That's the responsibility of the caller. + if (reinforcement instanceof PlayerReinforcement){ + int maturationTime = reinforcement.getAcidTime(); + if (maturationTime > 0) { + final int curMinute = (int)(System.currentTimeMillis() / 60000L); + if (curMinute >= maturationTime) { + maturationTime = 0; + reinforcement.setAcidTime(0); + } else { + maturationTime = maturationTime - curMinute; + } + } + return (int) maturationTime; // should be small enough by now + } + return 0; + } + /** * * @param The Player who broke the reinforcement @@ -529,8 +555,9 @@ public static PlayerReinforcement isDroppedReinforcementBlock(Player p, ItemStac return null; Group g = GroupManager.getSpecialCircumstanceGroup(group); PlayerReinforcement rein = new PlayerReinforcement(loc, dur, - getIntFormofMaturation(System.currentTimeMillis(),reinType.getItemStack()) - , g, reinType.getItemStack(), g.getGroupId()); + getIntFormofMaturation(System.currentTimeMillis(),reinType.getItemStack()), + getIntFormofAcidMaturation(System.currentTimeMillis(),reinType.getItemStack()), + g, reinType.getItemStack(), g.getGroupId()); ReinforcementCreationEvent event = new ReinforcementCreationEvent(rein, loc.getBlock(), p); Bukkit.getPluginManager().callEvent(event); @@ -564,15 +591,16 @@ public static boolean explodeReinforcement(Block block) { /** * Creates a MultiBlockReinforcement and saves it to the db. This method is to be used only be other plugins. Citadel * will not use this anywhere. - * @param locs- The locations that make up the structure. - * @param g- The group this will belong too. - * @param dur- The durability this structure will have. - * @param mature- The amount of time until it is mature (in minutes). + * @param locs The locations that make up the structure. + * @param g The group this will belong too. + * @param dur The durability this structure will have. + * @param mature The amount of time until it is mature (in minutes). + * @param acid The amount of time until it is mature (if acid -- in minutes). * @return */ - public static MultiBlockReinforcement createMultiBlockReinforcement(List locs, Group g, int dur, int mature){ + public static MultiBlockReinforcement createMultiBlockReinforcement(List locs, Group g, int dur, int mature, int acid){ int nextID = rm.getNextReinforcementID(); - MultiBlockReinforcement rein = new MultiBlockReinforcement(locs, g, dur, mature, nextID); + MultiBlockReinforcement rein = new MultiBlockReinforcement(locs, g, dur, mature, acid, nextID); ReinforcementCreationEvent event = new ReinforcementCreationEvent(rein, rein.getLocation().getBlock(), null); Bukkit.getPluginManager().callEvent(event); if (event.isCancelled()) { @@ -644,6 +672,14 @@ private static int getIntFormofMaturation(long creation, ItemStack stack){ return maturation; } + private static int getIntFormofAcidMaturation(long creation, ItemStack stack) { + int maturation = (int)(creation / 60000) + + ReinforcementType. + getReinforcementType(stack) + .getAcidTime(); + return maturation; + } + public static Block findPlantSoil(Block block){ final Set soilTypes = getPlantSoilTypes(block.getType()); if(soilTypes.size() <= 0){ diff --git a/src/vg/civcraft/mc/citadel/command/commands/Acid.java b/src/vg/civcraft/mc/citadel/command/commands/Acid.java index a2c6b856..3bbe6665 100644 --- a/src/vg/civcraft/mc/citadel/command/commands/Acid.java +++ b/src/vg/civcraft/mc/citadel/command/commands/Acid.java @@ -72,9 +72,9 @@ public boolean execute(CommandSender sender, String[] args) { + "to use acid blocks."); return true; } - int time = Utility.timeUntilMature(pRein); + int time = Utility.timeUntilAcidMature(pRein); if (time != 0) { - p.sendMessage(ChatColor.RED + "That block is not mature yet."); + p.sendMessage(ChatColor.RED + "That acid block is not mature yet."); return true; } Block topFace = block.getRelative(BlockFace.UP); @@ -97,8 +97,7 @@ public boolean execute(CommandSender sender, String[] args) { .getReinforcementType(pRein.getStackRepresentation()); ReinforcementType topReinType = ReinforcementType .getReinforcementType(pTopRein.getStackRepresentation()); - if (acidBlockType.getMaturationTime() < topReinType - .getMaturationTime()) { + if (acidBlockType.getAcidTime() < topReinType.getAcidTime()) { p.sendMessage(ChatColor.RED + "This acid block is too weak for that reinforcement."); return true; diff --git a/src/vg/civcraft/mc/citadel/command/commands/Bypass.java b/src/vg/civcraft/mc/citadel/command/commands/Bypass.java index f58dcb13..7de79979 100644 --- a/src/vg/civcraft/mc/citadel/command/commands/Bypass.java +++ b/src/vg/civcraft/mc/citadel/command/commands/Bypass.java @@ -32,7 +32,7 @@ public boolean execute(CommandSender sender, String[] args) { Player p = (Player) sender; PlayerState state = PlayerState.get(p); if (state.toggleBypassMode()){ - p.sendMessage(ChatColor.GREEN + "Bypass mode has been enabled."); + p.sendMessage(ChatColor.GREEN + "Bypass mode has been enabled. You will be able to break reinforced blocks if you are on the group."); } else p.sendMessage(ChatColor.GREEN + "Bypass mode has been disabled."); diff --git a/src/vg/civcraft/mc/citadel/command/commands/Fortification.java b/src/vg/civcraft/mc/citadel/command/commands/Fortification.java index c4eea5a9..5a2feaf7 100644 --- a/src/vg/civcraft/mc/citadel/command/commands/Fortification.java +++ b/src/vg/civcraft/mc/citadel/command/commands/Fortification.java @@ -31,7 +31,7 @@ public class Fortification extends PlayerCommand{ public Fortification(String name) { super(name); setIdentifier("ctf"); - setDescription("Allows you to place already reinforced blocks."); + setDescription("Allows you to place already reinforced blocks. Use /ctf groupname with a reinforcement material in your hand, then place down blocks and they will automatically be reinforced to groupname."); setUsage("/ctf "); setArguments(0,1); } @@ -48,7 +48,7 @@ public boolean execute(CommandSender sender, String[] args) { if(args.length == 0){ groupName = gm.getDefaultGroup(uuid); if(groupName == null){ - p.sendMessage(ChatColor.RED + "You need to set a default group \n Use /nlsdg to do so"); + p.sendMessage(ChatColor.RED + "You need to fortify to a group! Try /ctf groupname. \n Or use /nlcg groupname if you don't have a group yet."); return true; } } @@ -81,15 +81,14 @@ public boolean execute(CommandSender sender, String[] args) { } else{ if (stack.getType() == Material.AIR){ - p.sendMessage(ChatColor.RED + "You need to be holding an ItemStack."); + p.sendMessage(ChatColor.RED + "You need to be holding something to fortify with, try holding a stone block in your hand."); return true; } else if (reinType == null){ - p.sendMessage(ChatColor.RED + "That is not a ReinforcementType."); + p.sendMessage(ChatColor.RED + "You can't use the item in your hand to reinforce. Try using a stone block."); return true; } - p.sendMessage(ChatColor.GREEN + "Your mode has been set to " + - ReinforcementMode.REINFOREMENT_FORTIFICATION.name() + "."); + p.sendMessage(ChatColor.GREEN + "You are now in Fortification mode, place blocks down and they will be secured with the material in your hand. \n Type /ctf or /cto to turn this off when you are done."); state.setMode(ReinforcementMode.REINFOREMENT_FORTIFICATION); state.setFortificationItemStack(reinType.getItemStack()); state.setGroup(g); diff --git a/src/vg/civcraft/mc/citadel/command/commands/Information.java b/src/vg/civcraft/mc/citadel/command/commands/Information.java index f2d46fb2..8bbd2fce 100644 --- a/src/vg/civcraft/mc/citadel/command/commands/Information.java +++ b/src/vg/civcraft/mc/citadel/command/commands/Information.java @@ -34,8 +34,7 @@ public boolean execute(CommandSender sender, String[] args) { state.reset(); } else{ - p.sendMessage(ChatColor.GREEN + "Reinforcement mode changed to " - + ReinforcementMode.REINFORCEMENT_INFORMATION.name() + "."); + p.sendMessage(ChatColor.GREEN + "You are now in Information mode, click on blocks to see their reinforcement information! \n Type /cti or /cto to turn this off."); state.setMode(ReinforcementMode.REINFORCEMENT_INFORMATION); } return true; diff --git a/src/vg/civcraft/mc/citadel/command/commands/Materials.java b/src/vg/civcraft/mc/citadel/command/commands/Materials.java index 98ff7fe9..20521a84 100644 --- a/src/vg/civcraft/mc/citadel/command/commands/Materials.java +++ b/src/vg/civcraft/mc/citadel/command/commands/Materials.java @@ -34,6 +34,7 @@ public boolean execute(CommandSender sender, String[] args) { t += "Amount: " + type.getRequiredAmount() + ".\n "; t += "Durability: " + type.getHitPoints() + ".\n "; t += "Material: " + type.getMaterial() + ".\n "; + t += "Maturation: " + type.maturationTime() + ".\n "; if (type.getItemStack().getItemMeta().hasLore()){ t += "Lore: "; for (String x: type.getItemStack().getItemMeta().getLore()) diff --git a/src/vg/civcraft/mc/citadel/command/commands/Reinforce.java b/src/vg/civcraft/mc/citadel/command/commands/Reinforce.java index da740f58..e8977363 100644 --- a/src/vg/civcraft/mc/citadel/command/commands/Reinforce.java +++ b/src/vg/civcraft/mc/citadel/command/commands/Reinforce.java @@ -43,7 +43,7 @@ public boolean execute(CommandSender sender, String[] args) { if(args.length == 0){ groupName = gm.getDefaultGroup(uuid); if(groupName == null){ - p.sendMessage(ChatColor.RED + "You need to set a default group \n Use /nlsdg to do so"); + p.sendMessage(ChatColor.RED + "You need to reinforce to a group! Try /ctr groupname. \n Or /nlcg groupname if you don't have a group yet."); return true; } } @@ -72,8 +72,7 @@ public boolean execute(CommandSender sender, String[] args) { state.reset(); } else{ - p.sendMessage(ChatColor.GREEN + "Your mode has been set to " + - ReinforcementMode.REINFORCEMENT.name() + "."); + p.sendMessage(ChatColor.GREEN + "You are now in Reinforcement mode, hit blocks with a reinforcement material to secure them. \n Type /ctr or /cto to turn this off when you are done."); state.setMode(ReinforcementMode.REINFORCEMENT); state.setGroup(g); } diff --git a/src/vg/civcraft/mc/citadel/database/CitadelReinforcementData.java b/src/vg/civcraft/mc/citadel/database/CitadelReinforcementData.java index b288bf65..d16938e4 100644 --- a/src/vg/civcraft/mc/citadel/database/CitadelReinforcementData.java +++ b/src/vg/civcraft/mc/citadel/database/CitadelReinforcementData.java @@ -165,6 +165,15 @@ private void createTables(){ ver = NameLayerPlugin.getVersionNum(plugin.getName()); Citadel.Log("The update to Version 7 took " + (System.currentTimeMillis() / first_time) / 1000 + " seconds."); } + if (ver == 7) { + long first_time = System.currentTimeMillis(); + Citadel.Log("Updating to version 8: The acid test. Note: This will take a while."); + db.execute("alter table reinforcement add acid_time int not null;"); + db.execute("update reinforcement set acid_time = maturation_time;"); // Might take a minute. + NameLayerPlugin.insertVersionNum(ver, plugin.getName()); + ver = NameLayerPlugin.getVersionNum(plugin.getName()); + Citadel.Log("The update to Version 8 took " + (System.currentTimeMillis() / first_time) / 1000 + " seconds."); + } Citadel.Log("The total time it took Citadel to update was " + (System.currentTimeMillis() - begin_time) / 1000 + " seconds."); } @@ -187,7 +196,7 @@ private void reconnectAndReinitialize(){ */ private void initalizePreparedStatements(){ getRein = "select r.material_id, r.durability, " + - "r.insecure, f.group_name, r.maturation_time, rt.rein_type, " + "r.insecure, f.group_name, r.maturation_time, r.acid_time, rt.rein_type, " + "r.lore, r.group_id, r.rein_id from reinforcement r " + "inner join faction_id f on f.group_id = r.group_id " + "inner join reinforcement_id ri on r.rein_id = ri.rein_id " @@ -195,7 +204,7 @@ private void initalizePreparedStatements(){ + "where ri.x = ? and ri.y = ? and ri.z = ? and ri.chunk_id = ? and ri.world = ?"; getReins = "select ri.x, ri.y, ri.z, ri.world, r.material_id, r.durability, " + "r.insecure, f.group_name, r.maturation_time, rt.rein_type, " - + "r.lore, r.group_id, r.rein_id from reinforcement r " + + "r.lore, r.group_id, r.rein_id, r.acid_time from reinforcement r " + "inner join faction_id f on f.group_id = r.group_id " + "inner join reinforcement_id ri on r.rein_id = ri.rein_id " + "inner join reinforcement_type rt on rt.rein_type_id = r.rein_type_id " @@ -203,7 +212,7 @@ private void initalizePreparedStatements(){ addRein = "insert into reinforcement (" + "material_id, durability, " + "insecure, group_id, maturation_time, rein_type_id," - + "lore, rein_id) select ?, ?, ?, f.group_id, ?, rt.rein_type_id, ?, ? from faction_id f " + + "lore, rein_id, acid_time) select ?, ?, ?, f.group_id, ?, rt.rein_type_id, ?, ?, ? from faction_id f " + "inner join reinforcement_type rt on rt.rein_type = ? " + "where f.group_name = ? limit 1"; removeRein = "delete r.*, ri.* from reinforcement r " @@ -213,7 +222,7 @@ private void initalizePreparedStatements(){ + "inner join reinforcement_id ri on ri.rein_id = r.rein_id " + "set r.durability = ?, r.insecure = ?, r.group_id = " + "(select f.group_id from faction_id f where f.group_name = ? limit 1), " - + "maturation_time = ? " + + "maturation_time = ?, acid_time = ? " + "where ri.x = ? and ri.y = ? and ri.z = ? and ri.world =?"; getGroupFromRein = "select fi.group_name from faction_id fi " + "inner join reinforcement r on fi.group_id = r.group_id " @@ -269,9 +278,10 @@ public Reinforcement getReinforcement(Location loc){ boolean inSecure = set.getBoolean(3); String group = set.getString(4); int mature = set.getInt(5); - String rein_type = set.getString(6); - String lore = set.getString(7); - int group_id = set.getInt(8); + int acid = set.getInt(6); + String rein_type = set.getString(7); + String lore = set.getString(8); + int group_id = set.getInt(9); // Check for what type of reinforcement and return the one // needed. if (rein_type.equals("PlayerReinforcement")){ @@ -284,7 +294,7 @@ public Reinforcement getReinforcement(Location loc){ } PlayerReinforcement rein = new PlayerReinforcement(loc, durability, - mature, GroupManager.getGroup(group), + mature, acid, GroupManager.getGroup(group), stack, group_id); rein.setInsecure(inSecure); set.close(); @@ -297,7 +307,7 @@ else if(rein_type.equals("NaturalReinforcement")){ return rein; } else if (rein_type.equals("MultiBlockReinforcement")){ - int id = set.getInt(9); + int id = set.getInt(10); set.close(); MultiBlockReinforcement rein = MultiBlockReinforcement.getMultiRein(id); if (rein != null) @@ -313,7 +323,7 @@ else if (rein_type.equals("MultiBlockReinforcement")){ } set.close(); - rein = new MultiBlockReinforcement(locs, GroupManager.getGroup(group), durability, mature, id); + rein = new MultiBlockReinforcement(locs, GroupManager.getGroup(group), durability, mature, acid, id); return rein; } } catch (SQLException e) { @@ -346,6 +356,7 @@ public List getReinforcements(Chunk chunk){ String rein_type = set.getString(10); String lore = set.getString(11); int group_id = set.getInt(12); + int acid = set.getInt(14); Location loc = new Location(Bukkit.getWorld(world), x, y, z); @@ -359,7 +370,7 @@ public List getReinforcements(Chunk chunk){ } PlayerReinforcement rein = new PlayerReinforcement(loc, durability, - mature, g, + mature, acid, g, stack, group_id); rein.setInsecure(inSecure); reins.add(rein); @@ -385,7 +396,7 @@ else if (rein_type.equals("MultiBlockReinforcement")){ } multi.close(); - rein = new MultiBlockReinforcement(locs, g, durability, mature, id); + rein = new MultiBlockReinforcement(locs, g, durability, mature, acid, id); reins.add(rein); } } @@ -412,6 +423,7 @@ public void insertReinforcement(Reinforcement rein){ Material mat = rein.getMaterial(); int dur = rein.getDurability(); int maturationTime = rein.getMaturationTime(); + int acidTime = rein.getAcidTime(); boolean insecure = false; String group = null; String reinType = ""; @@ -445,8 +457,9 @@ public void insertReinforcement(Reinforcement rein){ addRein.setInt(4, maturationTime); addRein.setString(5, lore); addRein.setInt(6, id); - addRein.setString(7, reinType); - addRein.setString(8, group); + addRein.setInt(7, acidTime); + addRein.setString(8, reinType); + addRein.setString(9, group); addRein.execute(); } catch (SQLException e) { // TODO Auto-generated catch block @@ -461,6 +474,7 @@ else if (rein instanceof NaturalReinforcement){ int dur = rein.getDurability(); String chunk_id = loc.getChunk().toString(); int maturationTime = rein.getMaturationTime(); + int acidTime = rein.getAcidTime(); boolean insecure = false; String group = NameLayerPlugin.getSpecialAdminGroup(); String reinType = "NaturalReinforcement"; @@ -485,8 +499,9 @@ else if (rein instanceof NaturalReinforcement){ addRein.setInt(4, maturationTime); addRein.setString(5, lore); addRein.setInt(6, id); - addRein.setString(7, reinType); - addRein.setString(8, group); + addRein.setInt(7, acidTime); + addRein.setString(8, reinType); + addRein.setString(9, group); addRein.execute(); } catch (Exception e) { // TODO Auto-generated catch block @@ -519,8 +534,9 @@ else if (rein instanceof MultiBlockReinforcement){ addRein.setInt(4, mbRein.getMaturationTime()); addRein.setString(5, null); addRein.setInt(6, id); - addRein.setString(7, "MultiBlockReinforcement"); - addRein.setString(8, mbRein.getGroup().getName()); + addRein.setInt(7, mbRein.getAcidTime()); + addRein.setString(8, "MultiBlockReinforcement"); + addRein.setString(9, mbRein.getGroup().getName()); addRein.execute(); } catch (SQLException e) { // TODO Auto-generated catch block @@ -564,6 +580,7 @@ public void saveReinforcement(Reinforcement rein){ boolean insecure = false; String groupName = null; int mature = rein.getMaturationTime(); + int acid = rein.getAcidTime(); Location loc = rein.getLocation(); int x = loc.getBlockX(), y = loc.getBlockY(), z = loc.getBlockZ(); String world = loc.getWorld().getName(); @@ -578,10 +595,11 @@ public void saveReinforcement(Reinforcement rein){ updateRein.setBoolean(2, insecure); updateRein.setString(3, groupName); updateRein.setInt(4, mature); - updateRein.setInt(5, x); - updateRein.setInt(6, y); - updateRein.setInt(7, z); - updateRein.setString(8, world); + updateRein.setInt(5, acid); + updateRein.setInt(6, x); + updateRein.setInt(7, y); + updateRein.setInt(8, z); + updateRein.setString(9, world); updateRein.execute(); } catch (SQLException e) { Citadel.Log(String.format("The Null Group Exception that is being followed has to deal with the group name: %s," diff --git a/src/vg/civcraft/mc/citadel/listener/BlockListener.java b/src/vg/civcraft/mc/citadel/listener/BlockListener.java index 7d2f4ad0..b3959854 100644 --- a/src/vg/civcraft/mc/citadel/listener/BlockListener.java +++ b/src/vg/civcraft/mc/citadel/listener/BlockListener.java @@ -9,6 +9,7 @@ import static vg.civcraft.mc.citadel.Utility.reinforcementBroken; import static vg.civcraft.mc.citadel.Utility.reinforcementDamaged; import static vg.civcraft.mc.citadel.Utility.timeUntilMature; +import static vg.civcraft.mc.citadel.Utility.timeUntilAcidMature; import static vg.civcraft.mc.citadel.Utility.wouldPlantDoubleReinforce; import java.util.Arrays; @@ -463,6 +464,17 @@ public void interact(PlayerInteractEvent pie) { sb.append(maturationTime); sb.append("]"); } + int acidTime = timeUntilAcidMature(reinforcement); + if (CitadelConfigManager.getAcidBlock() == block.getType()) { + sb.append(" Acid "); + if (acidTime != 0) { + sb.append("Immature["); + sb.append(acidTime); + sb.append("]"); + } else { + sb.append("Mature"); + } + } if (reinforcement.isInsecure()) { sb.append(" (Insecure)"); } @@ -474,10 +486,10 @@ public void interact(PlayerInteractEvent pie) { player.sendMessage(ChatColor.GREEN + sb.toString()); } else if(reinforcement.isAccessible(player, PermissionType.BLOCKS, PermissionType.DOORS, PermissionType.CHESTS)){ sb = new StringBuilder(); - boolean immature = - timeUntilMature(reinforcement) != 0 - && (CitadelConfigManager.isMaturationEnabled() - || CitadelConfigManager.getAcidBlock() == block.getType()); + boolean immature = timeUntilMature(reinforcement) != 0 + && CitadelConfigManager.isMaturationEnabled(); + boolean acid = timeUntilAcidMature(reinforcement) != 0 + && CitadelConfigManager.getAcidBlock() == block.getType(); String groupName = "!NULL!"; if (group != null) { groupName = group.getName(); @@ -487,6 +499,9 @@ public void interact(PlayerInteractEvent pie) { if(immature){ sb.append(" (Hardening)"); } + if(acid){ + sb.append(" (Acid Maturing)"); + } if (reinforcement.isInsecure()) { sb.append(" (Insecure)"); } diff --git a/src/vg/civcraft/mc/citadel/reinforcement/MultiBlockReinforcement.java b/src/vg/civcraft/mc/citadel/reinforcement/MultiBlockReinforcement.java index 8bee38d3..cccc4b0d 100644 --- a/src/vg/civcraft/mc/citadel/reinforcement/MultiBlockReinforcement.java +++ b/src/vg/civcraft/mc/citadel/reinforcement/MultiBlockReinforcement.java @@ -18,8 +18,8 @@ public class MultiBlockReinforcement extends Reinforcement{ new HashMap(); public MultiBlockReinforcement(List locs, Group g, int dur, - int creation, int multiBlockId) { - super(null, null, dur, creation); + int creation, int acid, int multiBlockId) { + super(null, null, dur, creation, acid); this.g = g; this.locs = locs; reins.put(multiBlockId, this); diff --git a/src/vg/civcraft/mc/citadel/reinforcement/NaturalReinforcement.java b/src/vg/civcraft/mc/citadel/reinforcement/NaturalReinforcement.java index 4ee2864a..7086ba72 100644 --- a/src/vg/civcraft/mc/citadel/reinforcement/NaturalReinforcement.java +++ b/src/vg/civcraft/mc/citadel/reinforcement/NaturalReinforcement.java @@ -5,7 +5,7 @@ public class NaturalReinforcement extends Reinforcement{ public NaturalReinforcement(Block block, int dur){ - super(block.getLocation(), block.getType(), dur, 0); + super(block.getLocation(), block.getType(), dur, 0, 0); // The group is null be natural reinforcements don't belong to a group. } } diff --git a/src/vg/civcraft/mc/citadel/reinforcement/NullReinforcement.java b/src/vg/civcraft/mc/citadel/reinforcement/NullReinforcement.java index 59c34a80..94a29b16 100644 --- a/src/vg/civcraft/mc/citadel/reinforcement/NullReinforcement.java +++ b/src/vg/civcraft/mc/citadel/reinforcement/NullReinforcement.java @@ -8,6 +8,6 @@ public class NullReinforcement extends Reinforcement{ public NullReinforcement(Location loc) { - super(loc, null, 0, 0); + super(loc, null, 0, 0, 0); } } diff --git a/src/vg/civcraft/mc/citadel/reinforcement/PlayerReinforcement.java b/src/vg/civcraft/mc/citadel/reinforcement/PlayerReinforcement.java index 879bc39c..6b40c12f 100644 --- a/src/vg/civcraft/mc/citadel/reinforcement/PlayerReinforcement.java +++ b/src/vg/civcraft/mc/citadel/reinforcement/PlayerReinforcement.java @@ -28,8 +28,8 @@ public class PlayerReinforcement extends Reinforcement{ private ItemStack stack; public PlayerReinforcement(Location loc, int health, - int creation, Group g, ItemStack stack, int group_id) { - super(loc, stack.getType(), health, creation); + int creation, int acid, Group g, ItemStack stack, int group_id) { + super(loc, stack.getType(), health, creation, acid); this.g = g; this.stack = stack; gp = NameAPI.getGroupManager().getPermissionforGroup(g); diff --git a/src/vg/civcraft/mc/citadel/reinforcement/Reinforcement.java b/src/vg/civcraft/mc/citadel/reinforcement/Reinforcement.java index e40c81b5..e6f639a0 100644 --- a/src/vg/civcraft/mc/citadel/reinforcement/Reinforcement.java +++ b/src/vg/civcraft/mc/citadel/reinforcement/Reinforcement.java @@ -6,16 +6,18 @@ public class Reinforcement { private int creation; + private int acid; private Location loc; private Material mat; private int dur; protected boolean isDirty; - public Reinforcement(Location loc, Material mat, int dur, int creation){ + public Reinforcement(Location loc, Material mat, int dur, int creation, int acid){ this.loc = loc; this.mat = mat; this.dur = dur; this.creation = creation; + this.acid = acid; isDirty = false; } /** @@ -52,12 +54,26 @@ public int getMaturationTime(){ } /** * Sets the maturation time of this reinforcement. - * @param The time in seconds it was created. + * @param The time in minutes it was created. */ public void setMaturationTime(int time){ creation = time; isDirty = true; } + /** + * @return Returns the time that this acid process began or 0 if not acid/done. + */ + public int getAcidTime(){ + return acid; + } + /** + * Sets the acid process time of this reinforcement (0 to indicate done/not acid). + * @param The time in minutes acid process began. + */ + public void setAcidTime(int acid) { + this.acid = acid; + isDirty = true; + } /** * @return Returns if this reinforcement needs to be saved. */ diff --git a/src/vg/civcraft/mc/citadel/reinforcementtypes/ReinforcementType.java b/src/vg/civcraft/mc/citadel/reinforcementtypes/ReinforcementType.java index 3f8352c8..6273f4e4 100644 --- a/src/vg/civcraft/mc/citadel/reinforcementtypes/ReinforcementType.java +++ b/src/vg/civcraft/mc/citadel/reinforcementtypes/ReinforcementType.java @@ -19,6 +19,7 @@ public class ReinforcementType { private int hitpoints; private Material mat; private int maturationTime; + private int acidTime; private int scale; private ItemStack stack; @@ -26,14 +27,15 @@ public class ReinforcementType { new HashMap(); public ReinforcementType(Material mat, int amount, double percentReturn, - int returnValue, int hitpoints, int maturationTime, int scale, - List lore) { + int returnValue, int hitpoints, int maturationTime, int acidTime, + int scale, List lore) { this.mat = mat; this.amount = amount; this.percentReturn = percentReturn/100; this.returnValue = returnValue; this.hitpoints = hitpoints; this.maturationTime = maturationTime; + this.acidTime = acidTime; this.scale = scale; ItemStack stack = new ItemStack(mat, amount); ItemMeta meta = stack.getItemMeta(); @@ -52,10 +54,11 @@ public static void initializeReinforcementTypes(){ int returnValue = CitadelConfigManager.getReturns(type); int hitpoints = CitadelConfigManager.getHitPoints(type); int maturation = CitadelConfigManager.getMaturationTime(type); + int acid = CitadelConfigManager.getAcidTime(type); int maturation_scale = CitadelConfigManager.getMaturationScale(type); List lore = CitadelConfigManager.getLoreValues(type); new ReinforcementType(mat, amount, percentReturn, returnValue, - hitpoints, maturation, maturation_scale, lore); + hitpoints, maturation, acid, maturation_scale, lore); } } /** @@ -94,6 +97,12 @@ public int getHitPoints() { public int getMaturationTime(){ return maturationTime; } + /** + * @return Returns the Acid time needed until this acid block is ready. + */ + public int getAcidTime() { + return acidTime; + } /** * @return Get the scale of amount of damage a block should take when it is not fully mature. */ @@ -124,4 +133,4 @@ public static List getReinforcementTypes(){ type.addAll(types.values()); return type; } -} \ No newline at end of file +}