Changeset 5156
- Timestamp:
- Jan 27, 2012 11:18:01 PM (4 months ago)
- Location:
- branches/unstable/L2J_Server_BETA/java/com/l2jserver/gameserver
- Files:
-
- 6 edited
-
ai/L2AttackableAI.java (modified) (1 diff)
-
model/actor/instance/L2VillageMasterInstance.java (modified) (4 diffs)
-
model/itemcontainer/Inventory.java (modified) (11 diffs)
-
model/itemcontainer/PcInventory.java (modified) (2 diffs)
-
taskmanager/DecayTaskManager.java (modified) (4 diffs)
-
util/Util.java (modified) (23 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/unstable/L2J_Server_BETA/java/com/l2jserver/gameserver/ai/L2AttackableAI.java
r5146 r5156 1918 1918 } 1919 1919 1920 /** 1921 * @param skill the skill to check. 1922 * @return {@code true} if the skill is available for casting {@code false} otherwise. 1923 */ 1920 1924 private boolean checkSkillCastConditions(L2Skill skill) 1921 1925 { 1926 // Not enough MP. 1922 1927 if (skill.getMpConsume() >= getActiveChar().getCurrentMp()) 1928 { 1923 1929 return false; 1924 else if (getActiveChar().isSkillDisabled(skill)) 1930 } 1931 // Character is in "skill disabled" mode. 1932 if (getActiveChar().isSkillDisabled(skill)) 1933 { 1925 1934 return false; 1926 else if (!skill.ignoreSkillMute()) 1927 { 1928 if (skill.isMagic()) 1929 { 1930 if (getActiveChar().isMuted()) 1931 return false; 1932 } 1933 else 1934 { 1935 if (getActiveChar().isPhysicalMuted()) 1936 return false; 1937 } 1938 } 1939 1935 } 1936 // Is a magic skill and character is magically muted or is a physical skill and character is physically muted. 1937 if (!skill.ignoreSkillMute() && ((skill.isMagic() && getActiveChar().isMuted()) || getActiveChar().isPhysicalMuted())) 1938 { 1939 return false; 1940 } 1940 1941 return true; 1941 1942 } -
branches/unstable/L2J_Server_BETA/java/com/l2jserver/gameserver/model/actor/instance/L2VillageMasterInstance.java
r5146 r5156 17 17 import java.util.Iterator; 18 18 import java.util.Set; 19 import java.util. regex.Matcher;19 import java.util.logging.Logger; 20 20 import java.util.regex.Pattern; 21 21 import java.util.regex.PatternSyntaxException; … … 63 63 public class L2VillageMasterInstance extends L2NpcInstance 64 64 { 65 //private static Logger _log = Logger.getLogger(L2VillageMasterInstance.class.getName());65 private static Logger _log = Logger.getLogger(L2VillageMasterInstance.class.getName()); 66 66 67 67 /** … … 1146 1146 } 1147 1147 1148 private static boolean isValidName(String text) 1149 { 1150 boolean result = true; 1151 String test = text; 1148 private static boolean isValidName(String name) 1149 { 1152 1150 Pattern pattern; 1153 1151 try … … 1155 1153 pattern = Pattern.compile(Config.CLAN_NAME_TEMPLATE); 1156 1154 } 1157 catch (PatternSyntaxException e) // case of illegal pattern1158 { 1159 _log.warning("ERROR : Clan name pattern of config is wrong!");1155 catch (PatternSyntaxException e) 1156 { 1157 _log.warning("ERROR: Wrong pattern for clan name!"); 1160 1158 pattern = Pattern.compile(".*"); 1161 1159 } 1162 Matcher regexp = pattern.matcher(test); 1163 if (!regexp.matches()) 1164 { 1165 result = false; 1166 } 1167 return result; 1160 return pattern.matcher(name).matches(); 1168 1161 } 1169 1162 } -
branches/unstable/L2J_Server_BETA/java/com/l2jserver/gameserver/model/itemcontainer/Inventory.java
r5146 r5156 21 21 import java.util.List; 22 22 import java.util.logging.Level; 23 import java.util.logging.Logger; 23 24 24 25 import javolution.util.FastList; … … 53 54 public abstract class Inventory extends ItemContainer 54 55 { 55 //protectedstatic final Logger _log = Logger.getLogger(Inventory.class.getName());56 private static final Logger _log = Logger.getLogger(Inventory.class.getName()); 56 57 57 58 public interface PaperdollListener … … 933 934 934 935 /** 935 * Returns the ID of the item in the paperdol slot936 * Returns the ID of the item in the paperdoll slot 936 937 * @param slot : int designating the slot 937 938 * @return int designating the ID of the item … … 939 940 public int getPaperdollItemDisplayId(int slot) 940 941 { 941 L2ItemInstance item = _paperdoll[slot]; 942 if (item != null) 943 return item.getDisplayId(); 944 return 0; 942 final L2ItemInstance item = _paperdoll[slot]; 943 return (item != null) ? item.getDisplayId() : 0; 945 944 } 946 945 … … 948 947 { 949 948 final L2ItemInstance item = _paperdoll[slot]; 950 if ((item != null) && (item.getAugmentation() != null)) 951 { 952 return item.getAugmentation().getAugmentationId(); 953 } 954 return 0; 949 return ((item != null) && (item.getAugmentation() != null)) ? item.getAugmentation().getAugmentationId() : 0; 955 950 } 956 951 … … 962 957 public int getPaperdollObjectId(int slot) 963 958 { 964 L2ItemInstance item = _paperdoll[slot]; 965 if (item != null) 966 return item.getObjectId(); 967 return 0; 959 final L2ItemInstance item = _paperdoll[slot]; 960 return (item != null) ? item.getObjectId() : 0; 968 961 } 969 962 … … 1045 1038 1046 1039 /** 1047 * Return the mask of weared item 1048 * @return int 1040 * @return the mask of wore item 1049 1041 */ 1050 1042 public int getWearedMask() … … 1160 1152 1161 1153 /** 1162 * Une pquips item in slot and returns alterations<BR>1154 * Unequips item in slot and returns alterations<BR> 1163 1155 * <B>If you dont need return value use {@link Inventory#unEquipItemInSlot(int)} instead</B> 1164 1156 * @param slot : int designating the slot … … 1282 1274 /** 1283 1275 * Equips item and returns list of alterations<BR> 1284 * <B>If you don t need return value use {@link Inventory#equipItem(L2ItemInstance)} instead</B>1276 * <B>If you don't need return value use {@link Inventory#equipItem(L2ItemInstance)} instead</B> 1285 1277 * @param item : L2ItemInstance corresponding to the item 1286 1278 * @return L2ItemInstance[] : list of alterations … … 1362 1354 case L2Item.SLOT_R_HAND: 1363 1355 { 1364 // don t care about arrows, listener will unequip them (hopefully)1356 // don't care about arrows, listener will unequip them (hopefully) 1365 1357 setPaperdollItem(PAPERDOLL_RHAND, item); 1366 1358 break; … … 1501 1493 1502 1494 /** 1503 * Returns the totalWeight. 1504 * @return int 1495 * @return the totalWeight. 1505 1496 */ 1506 1497 public int getTotalWeight() -
branches/unstable/L2J_Server_BETA/java/com/l2jserver/gameserver/model/itemcontainer/PcInventory.java
r5146 r5156 19 19 import java.sql.ResultSet; 20 20 import java.util.logging.Level; 21 import java.util.logging.Logger; 21 22 22 23 import javolution.util.FastList; … … 40 41 public class PcInventory extends Inventory 41 42 { 43 private static final Logger _log = Logger.getLogger(PcInventory.class.getName()); 44 42 45 public static final int ADENA_ID = 57; 43 46 public static final int ANCIENT_ADENA_ID = 5575; -
branches/unstable/L2J_Server_BETA/java/com/l2jserver/gameserver/taskmanager/DecayTaskManager.java
r4981 r5156 18 18 import java.util.Map; 19 19 import java.util.Map.Entry; 20 import java.util.NoSuchElementException;21 20 import java.util.logging.Level; 22 21 import java.util.logging.Logger; … … 50 49 public void addDecayTask(L2Character actor) 51 50 { 52 _decayTasks.put(actor, System.currentTimeMillis());51 addDecayTask(actor, 0); 53 52 } 54 53 … … 60 59 public void cancelDecayTask(L2Character actor) 61 60 { 62 try 63 { 64 _decayTasks.remove(actor); 65 } 66 catch (NoSuchElementException e) 67 { 68 } 61 _decayTasks.remove(actor); 69 62 } 70 63 … … 92 85 actor = e.getKey(); 93 86 next = e.getValue(); 94 if ( next == null)87 if (actor == null || next == null) 95 88 continue; 96 89 if (actor.isRaid() && !actor.isRaidMinion()) -
branches/unstable/L2J_Server_BETA/java/com/l2jserver/gameserver/util/Util.java
r5130 r5156 43 43 44 44 /** 45 * @param obj1 46 * @param obj2 45 * @param obj1 46 * @param obj2 47 47 * @return degree value of object 2 to the horizontal line with object 1 being the origin. 48 48 */ … … 53 53 54 54 /** 55 * @param obj1X 56 * @param obj1Y 57 * @param obj2X 58 * @param obj2Y 55 * @param obj1X 56 * @param obj1Y 57 * @param obj2X 58 * @param obj2Y 59 59 * @return degree value of object 2 to the horizontal line with object 1 being the origin 60 60 */ … … 63 63 double angleTarget = Math.toDegrees(Math.atan2(obj2Y - obj1Y, obj2X - obj1X)); 64 64 if (angleTarget < 0) 65 { 65 66 angleTarget = 360 + angleTarget; 67 } 66 68 return angleTarget; 67 69 } … … 76 78 { 77 79 if (degree < 0) 80 { 78 81 degree = 360 + degree; 82 } 79 83 return (int) (degree * 182.044444444); 80 84 } … … 89 93 double angleTarget = Math.toDegrees(Math.atan2(obj2Y - obj1Y, obj2X - obj1X)); 90 94 if (angleTarget < 0) 95 { 91 96 angleTarget = 360 + angleTarget; 97 } 92 98 return (int) (angleTarget * 182.044444444); 93 99 } … … 97 103 double angleTarget = Math.toDegrees(Math.atan2(dy, dx)); 98 104 if (angleTarget < 0) 105 { 99 106 angleTarget = 360 + angleTarget; 107 } 100 108 return (int) (angleTarget * 182.044444444); 101 109 } 102 110 103 111 /** 104 * @param x1 105 * @param y1 106 * @param x2 107 * @param y2 112 * @param x1 113 * @param y1 114 * @param x2 115 * @param y2 108 116 * @return the distance between the two coordinates in 2D plane 109 117 */ … … 114 122 115 123 /** 116 * @param x1 117 * @param y1 118 * @param z1 119 * @param x2 120 * @param y2 121 * @param z2 124 * @param x1 125 * @param y1 126 * @param z1 127 * @param x2 128 * @param y2 129 * @param z2 122 130 * @param includeZAxis - if true, includes also the Z axis in the calculation 123 131 * @return the distance between the two coordinates … … 131 139 { 132 140 double dz = z1 - z2; 133 return Math.sqrt( dx * dx + dy * dy + dz * dz);134 } 135 return Math.sqrt( dx * dx + dy * dy);136 } 137 138 /** 139 * @param obj1 140 * @param obj2 141 return Math.sqrt((dx * dx) + (dy * dy) + (dz * dz)); 142 } 143 return Math.sqrt((dx * dx) + (dy * dy)); 144 } 145 146 /** 147 * @param obj1 148 * @param obj2 141 149 * @param includeZAxis - if true, includes also the Z axis in the calculation 142 150 * @return the distance between the two objects … … 144 152 public static double calculateDistance(L2Object obj1, L2Object obj2, boolean includeZAxis) 145 153 { 146 if (obj1 == null || obj2 == null) 154 if ((obj1 == null) || (obj2 == null)) 155 { 147 156 return 1000000; 157 } 148 158 149 159 return calculateDistance(obj1.getPosition().getX(), obj1.getPosition().getY(), obj1.getPosition().getZ(), obj2.getPosition().getX(), obj2.getPosition().getY(), obj2.getPosition().getZ(), includeZAxis); … … 151 161 152 162 /** 153 *154 163 * @param str - the string whose first letter to capitalize 155 164 * @return a string with the first letter of the {@code str} capitalized … … 157 166 public static String capitalizeFirst(String str) 158 167 { 159 if ( str == null|| str.isEmpty())168 if ((str == null) || str.isEmpty()) 160 169 { 161 170 return str; … … 172 181 173 182 /** 174 * (Based on ucwords() function of PHP) 175 * 183 * (Based on ucwords() function of PHP)<br> 176 184 * DrHouse: still functional but must be rewritten to avoid += to concat strings 177 *178 185 * @param str - the string to capitalize 179 186 * @return a string with the first letter of every word in {@code str} capitalized … … 182 189 public static String capitalizeWords(String str) 183 190 { 184 if (str == null || str.isEmpty()) 191 if ((str == null) || str.isEmpty()) 192 { 185 193 return str; 194 } 186 195 187 196 char[] charArray = str.toCharArray(); … … 194 203 { 195 204 if (Character.isWhitespace(charArray[i])) 205 { 196 206 charArray[i + 1] = Character.toUpperCase(charArray[i + 1]); 207 } 197 208 198 209 result.append(charArray[i]); … … 203 214 204 215 /** 205 * @param range 206 * @param obj1 207 * @param obj2 208 * @param includeZAxis 216 * @param range 217 * @param obj1 218 * @param obj2 219 * @param includeZAxis 209 220 * @return {@code true} if the two objects are within specified range between each other, {@code false} otherwise 210 221 */ 211 222 public static boolean checkIfInRange(int range, L2Object obj1, L2Object obj2, boolean includeZAxis) 212 223 { 213 if (obj1 == null || obj2 == null) 224 if ((obj1 == null) || (obj2 == null)) 225 { 214 226 return false; 227 } 215 228 if (obj1.getInstanceId() != obj2.getInstanceId()) 229 { 216 230 return false; 231 } 217 232 if (range == -1) 233 { 218 234 return true; // not limited 219 235 } 236 220 237 int rad = 0; 221 238 if (obj1 instanceof L2Character) 239 { 222 240 rad += ((L2Character) obj1).getTemplate().getCollisionRadius(); 241 } 223 242 if (obj2 instanceof L2Character) 243 { 224 244 rad += ((L2Character) obj2).getTemplate().getCollisionRadius(); 245 } 225 246 226 247 double dx = obj1.getX() - obj2.getX(); … … 230 251 { 231 252 double dz = obj1.getZ() - obj2.getZ(); 232 double d = dx * dx + dy * dy + dz * dz;253 double d = (dx * dx) + (dy * dy) + (dz * dz); 233 254 234 return d <= range * range + 2 * range * rad + rad * rad; 235 } 236 double d = dx * dx + dy * dy; 237 return d <= range * range + 2 * range * rad + rad * rad; 238 } 239 240 /** 241 * Checks if object is within short (sqrt(int.max_value)) radius, not using collisionRadius. 242 * Faster calculation than checkIfInRange if distance is short and collisionRadius isn't needed. 243 * Not for long distance checks (potential teleports, far away castles etc). 255 return d <= ((range * range) + (2 * range * rad) + (rad * rad)); 256 } 257 double d = (dx * dx) + (dy * dy); 258 return d <= ((range * range) + (2 * range * rad) + (rad * rad)); 259 } 260 261 /** 262 * Checks if object is within short (sqrt(int.max_value)) radius, not using collisionRadius. Faster calculation than checkIfInRange if distance is short and collisionRadius isn't needed. Not for long distance checks (potential teleports, far away castles etc). 244 263 * @param radius 245 264 * @param obj1 … … 250 269 public static boolean checkIfInShortRadius(int radius, L2Object obj1, L2Object obj2, boolean includeZAxis) 251 270 { 252 if (obj1 == null || obj2 == null) 271 if ((obj1 == null) || (obj2 == null)) 272 { 253 273 return false; 274 } 254 275 if (radius == -1) 276 { 255 277 return true; // not limited 256 278 } 279 257 280 int dx = obj1.getX() - obj2.getX(); 258 281 int dy = obj1.getY() - obj2.getY(); … … 261 284 { 262 285 int dz = obj1.getZ() - obj2.getZ(); 263 return dx * dx + dy * dy + dz * dz <= radius * radius;264 } 265 return dx * dx + dy * dy <= radius * radius;286 return ((dx * dx) + (dy * dy) + (dz * dz)) <= (radius * radius); 287 } 288 return ((dx * dx) + (dy * dy)) <= (radius * radius); 266 289 } 267 290 … … 305 328 { 306 329 if (numPlaces <= 1) 330 { 307 331 return Math.round(number); 332 } 308 333 309 334 float exponent = (float) Math.pow(10, numPlaces); 310 311 335 return Math.round(number * exponent) / exponent; 312 336 } 313 337 314 338 /** 315 * @param text - the text to check 316 * @return {@code true} if {@code text} contains only numbers, {@code false} otherwise 317 */ 318 public static boolean isDigit(String text) 319 { 320 if (text == null || text.isEmpty()) 321 return false; 322 for (char c : text.toCharArray()) 323 if (!Character.isDigit(c)) 324 return false; 325 return true; 326 } 339 * @param text - the text to check 340 * @return {@code true} if {@code text} contains only numbers, {@code false} otherwise 341 */ 342 public static boolean isDigit(String text) 343 { 344 if ((text == null) || text.isEmpty()) 345 { 346 return false; 347 } 348 for (char c : text.toCharArray()) 349 { 350 if (!Character.isDigit(c)) 351 { 352 return false; 353 } 354 } 355 return true; 356 } 327 357 328 358 /** … … 332 362 public static boolean isAlphaNumeric(String text) 333 363 { 334 if (text == null || text.isEmpty()) 364 if ((text == null) || text.isEmpty()) 365 { 335 366 return false; 367 } 336 368 for (char c : text.toCharArray()) 369 { 337 370 if (!Character.isLetterOrDigit(c)) 371 { 338 372 return false; 373 } 374 } 339 375 return true; 340 376 } 341 377 342 378 /** 343 * Format the specified digit using the digit grouping symbol "," (comma). 379 * Format the specified digit using the digit grouping symbol "," (comma).<br> 344 380 * For example, 123456789 becomes 123,456,789. 345 381 * @param amount - the amount of adena … … 355 391 { 356 392 if (rem < 99) 393 { 357 394 s = '0' + s; 395 } 358 396 if (rem < 9) 397 { 359 398 s = '0' + s; 399 } 360 400 rem = amount % 1000; 361 401 s = Long.toString(rem) + "," + s; … … 365 405 } 366 406 367 /** 368 * Format the given date on the given format 369 * @param date : the date to format. 370 * @param format : the format to correct by. 371 * @return a string representation of the formatted date. 372 */ 373 public static String formatDate(Date date, String format) 374 { 375 final DateFormat dateFormat = new SimpleDateFormat(format); 376 if (date != null) 377 return dateFormat.format(date); 378 379 return null; 380 } 381 382 /** 383 * @param <T> 407 /** 408 * Format the given date on the given format 409 * @param date : the date to format. 410 * @param format : the format to correct by. 411 * @return a string representation of the formatted date. 412 */ 413 public static String formatDate(Date date, String format) 414 { 415 if (date != null) 416 { 417 return null; 418 } 419 final DateFormat dateFormat = new SimpleDateFormat(format); 420 return dateFormat.format(date); 421 } 422 423 /** 424 * @param <T> 384 425 * @param array - the array to look into 385 426 * @param obj - the object to search for 386 * @return {@code true} if the {@code array} contains the {@code obj}, {@code false} otherwise 427 * @return {@code true} if the {@code array} contains the {@code obj}, {@code false} otherwise. 387 428 */ 388 429 public static <T> boolean contains(T[] array, T obj) 389 430 { 390 431 for (T element : array) 432 { 391 433 if (element == obj) 434 { 392 435 return true; 436 } 437 } 393 438 return false; 394 439 } … … 402 447 { 403 448 for (int element : array) 449 { 404 450 if (element == obj) 451 { 405 452 return true; 453 } 454 } 406 455 return false; 407 456 } 408 457 409 458 public static File[] getDatapackFiles(String dirname, String extention) 410 459 { 411 460 File dir = new File(Config.DATAPACK_ROOT, "data/" + dirname); 412 461 if (!dir.exists()) 462 { 413 463 return null; 414 464 } 415 465 return dir.listFiles(new ExtFilter(extention)); 416 466 }
Note: See TracChangeset
for help on using the changeset viewer.
