Fixed nasty loop causing server crash.
This commit is contained in:
		
							parent
							
								
									ac3cf8846c
								
							
						
					
					
						commit
						bb59525e12
					
				
										
											Binary file not shown.
										
									
								
							| @ -1165,14 +1165,14 @@ public class CustomDamage { | |||||||
| 	private static int GetHeartAmount(double dmg) { | 	private static int GetHeartAmount(double dmg) { | ||||||
| 		int heartcount = 1; | 		int heartcount = 1; | ||||||
| 		double dmgamountcopy = dmg; | 		double dmgamountcopy = dmg; | ||||||
| 		TwosideKeeper.log("Starting Damage: "+dmgamountcopy, 0); | 		//TwosideKeeper.log("Starting Damage: "+dmgamountcopy, 0); | ||||||
| 		while (dmgamountcopy>10) { | 		while (dmgamountcopy>10) { | ||||||
| 			dmgamountcopy/=2; | 			dmgamountcopy/=2; | ||||||
| 			heartcount++; | 			heartcount++; | ||||||
| 			TwosideKeeper.log("Hearts: "+heartcount, 0); | 			//TwosideKeeper.log("Hearts: "+heartcount, 0); | ||||||
| 			TwosideKeeper.log("Remaining Damage: "+dmgamountcopy, 0); | 			//TwosideKeeper.log("Remaining Damage: "+dmgamountcopy, 0); | ||||||
| 		} | 		} | ||||||
| 		TwosideKeeper.log(ChatColor.RED+"Final Heart Count: "+heartcount, 0); | 		//TwosideKeeper.log(ChatColor.RED+"Final Heart Count: "+heartcount, 0); | ||||||
| 		return heartcount; | 		return heartcount; | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -18,6 +18,7 @@ import org.bukkit.Material; | |||||||
| import org.bukkit.Sound; | import org.bukkit.Sound; | ||||||
| import org.bukkit.attribute.Attribute; | import org.bukkit.attribute.Attribute; | ||||||
| import org.bukkit.block.Block; | import org.bukkit.block.Block; | ||||||
|  | import org.bukkit.block.BlockFace; | ||||||
| import org.bukkit.block.Sign; | import org.bukkit.block.Sign; | ||||||
| import org.bukkit.command.CommandSender; | import org.bukkit.command.CommandSender; | ||||||
| import org.bukkit.enchantments.Enchantment; | import org.bukkit.enchantments.Enchantment; | ||||||
| @ -4339,7 +4340,7 @@ public class GenericFunctions { | |||||||
| 			Location originalloc = player.getLocation().clone(); | 			Location originalloc = player.getLocation().clone(); | ||||||
| 			Location teleloc = target.getLocation().add(target.getLocation().getDirection().multiply(-1.0-mult)); | 			Location teleloc = target.getLocation().add(target.getLocation().getDirection().multiply(-1.0-mult)); | ||||||
| 			int i=0; | 			int i=0; | ||||||
| 			while (!(teleloc.getBlock().getRelative(0, -1, 0).getType().isSolid() && teleloc.getBlock().getType()==Material.AIR && teleloc.getBlock().getRelative(0, 1, 0).getType()==Material.AIR)) { | 			/*while (!(teleloc.getBlock().getRelative(0, -1, 0).getType().isSolid() && teleloc.getBlock().getType()==Material.AIR && teleloc.getBlock().getRelative(0, 1, 0).getType()==Material.AIR)) { | ||||||
| 				if (i==0) { | 				if (i==0) { | ||||||
| 					teleloc=target.getLocation(); | 					teleloc=target.getLocation(); | ||||||
| 				} else  | 				} else  | ||||||
| @ -4358,6 +4359,23 @@ public class GenericFunctions { | |||||||
| 					teleloc=teleloc.add(0,1,0); | 					teleloc=teleloc.add(0,1,0); | ||||||
| 				} | 				} | ||||||
| 				i++; | 				i++; | ||||||
|  | 			}*/ | ||||||
|  | 			int tries = 0; | ||||||
|  | 			while (tries<2) { | ||||||
|  | 				if ((TwosideKeeper.isNatural.contains(teleloc.getBlock().getType()) || teleloc.getBlock().getType()==Material.AIR) && | ||||||
|  | 						(TwosideKeeper.isNatural.contains(teleloc.getBlock().getRelative(BlockFace.UP).getType()) || teleloc.getBlock().getType()==Material.AIR)) { | ||||||
|  | 					break; | ||||||
|  | 				} else { | ||||||
|  | 					//Try 1 higher. | ||||||
|  | 					teleloc.add(0,1,0); | ||||||
|  | 					tries++; | ||||||
|  | 				} | ||||||
|  | 			} | ||||||
|  | 			if (TwosideKeeper.isNatural.contains(teleloc.getBlock().getType())) { | ||||||
|  | 				teleloc.getBlock().breakNaturally(); | ||||||
|  | 			} | ||||||
|  | 			if (TwosideKeeper.isNatural.contains(teleloc.getBlock().getRelative(BlockFace.UP).getType())) { | ||||||
|  | 				teleloc.getBlock().getRelative(BlockFace.UP).breakNaturally(); | ||||||
| 			} | 			} | ||||||
| 			SoundUtils.playGlobalSound(teleloc, Sound.BLOCK_NOTE_SNARE, 1.0f, 1.0f); | 			SoundUtils.playGlobalSound(teleloc, Sound.BLOCK_NOTE_SNARE, 1.0f, 1.0f); | ||||||
| 			teleloc.setPitch((float)pitch); | 			teleloc.setPitch((float)pitch); | ||||||
|  | |||||||
| @ -449,6 +449,16 @@ public class TwosideKeeper extends JavaPlugin implements Listener { | |||||||
| 	public static List<JobRecipe> jobrecipes = new ArrayList<JobRecipe>(); | 	public static List<JobRecipe> jobrecipes = new ArrayList<JobRecipe>(); | ||||||
| 	long LastClearStructureTime = 0; | 	long LastClearStructureTime = 0; | ||||||
| 	 | 	 | ||||||
|  |     public static final Set<Material> isNatural = ImmutableSet.of(Material.CLAY, Material.DIRT, Material.GRASS, | ||||||
|  |             Material.GRASS_PATH, Material.GRAVEL, Material.MYCEL, Material.SAND, Material.SNOW, Material.SNOW_BLOCK, | ||||||
|  |             Material.SOUL_SAND, Material.STONE, Material.COBBLESTONE, Material.DOUBLE_PLANT, Material.LONG_GRASS,  | ||||||
|  |             Material.RED_ROSE, Material.YELLOW_FLOWER, Material.STATIONARY_WATER, Material.STATIONARY_LAVA, | ||||||
|  |             Material.MOSSY_COBBLESTONE, Material.COAL_ORE, Material.IRON_ORE, Material.GOLD_ORE, Material.REDSTONE_ORE, | ||||||
|  |             Material.GLOWING_REDSTONE_ORE, Material.LAPIS_ORE, Material.DIAMOND_ORE, Material.EMERALD_ORE, | ||||||
|  |             Material.OBSIDIAN, Material.ENDER_STONE, Material.NETHERRACK, Material.NETHER_BRICK, Material.HARD_CLAY, | ||||||
|  |             Material.STAINED_CLAY, Material.SANDSTONE, Material.LOG, Material.LOG_2, Material.WOOD, | ||||||
|  |             Material.FENCE, Material.PUMPKIN, Material.MELON_BLOCK, Material.LEAVES, Material.LEAVES_2); | ||||||
|  | 	  | ||||||
| 	public int TeamCounter = 0;  | 	public int TeamCounter = 0;  | ||||||
| 	public static int time_passed = 0; //The total amount of time lost due to modifications to FullTime(). | 	public static int time_passed = 0; //The total amount of time lost due to modifications to FullTime(). | ||||||
| 	public List<Integer> colors_used = new ArrayList<Integer>(); | 	public List<Integer> colors_used = new ArrayList<Integer>(); | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user