Removed enhanced For from World and WorldRegion.
This commit is contained in:
@@ -94,7 +94,7 @@ sp_cleanup.always_use_parentheses_in_expressions=true
|
|||||||
sp_cleanup.always_use_this_for_non_static_field_access=false
|
sp_cleanup.always_use_this_for_non_static_field_access=false
|
||||||
sp_cleanup.always_use_this_for_non_static_method_access=false
|
sp_cleanup.always_use_this_for_non_static_method_access=false
|
||||||
sp_cleanup.convert_functional_interfaces=true
|
sp_cleanup.convert_functional_interfaces=true
|
||||||
sp_cleanup.convert_to_enhanced_for_loop=true
|
sp_cleanup.convert_to_enhanced_for_loop=false
|
||||||
sp_cleanup.correct_indentation=false
|
sp_cleanup.correct_indentation=false
|
||||||
sp_cleanup.format_source_code=true
|
sp_cleanup.format_source_code=true
|
||||||
sp_cleanup.format_source_code_changes_only=false
|
sp_cleanup.format_source_code_changes_only=false
|
||||||
@@ -106,18 +106,23 @@ sp_cleanup.make_type_abstract_if_missing_method=false
|
|||||||
sp_cleanup.make_variable_declarations_final=true
|
sp_cleanup.make_variable_declarations_final=true
|
||||||
sp_cleanup.never_use_blocks=false
|
sp_cleanup.never_use_blocks=false
|
||||||
sp_cleanup.never_use_parentheses_in_expressions=false
|
sp_cleanup.never_use_parentheses_in_expressions=false
|
||||||
|
sp_cleanup.number_suffix=false
|
||||||
sp_cleanup.on_save_use_additional_actions=true
|
sp_cleanup.on_save_use_additional_actions=true
|
||||||
sp_cleanup.organize_imports=true
|
sp_cleanup.organize_imports=true
|
||||||
|
sp_cleanup.push_down_negation=false
|
||||||
sp_cleanup.qualify_static_field_accesses_with_declaring_class=false
|
sp_cleanup.qualify_static_field_accesses_with_declaring_class=false
|
||||||
sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true
|
sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true
|
||||||
sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true
|
sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true
|
||||||
sp_cleanup.qualify_static_member_accesses_with_declaring_class=true
|
sp_cleanup.qualify_static_member_accesses_with_declaring_class=true
|
||||||
sp_cleanup.qualify_static_method_accesses_with_declaring_class=false
|
sp_cleanup.qualify_static_method_accesses_with_declaring_class=false
|
||||||
sp_cleanup.remove_private_constructors=true
|
sp_cleanup.remove_private_constructors=true
|
||||||
|
sp_cleanup.remove_redundant_modifiers=false
|
||||||
|
sp_cleanup.remove_redundant_semicolons=false
|
||||||
sp_cleanup.remove_redundant_type_arguments=false
|
sp_cleanup.remove_redundant_type_arguments=false
|
||||||
sp_cleanup.remove_trailing_whitespaces=false
|
sp_cleanup.remove_trailing_whitespaces=false
|
||||||
sp_cleanup.remove_trailing_whitespaces_all=true
|
sp_cleanup.remove_trailing_whitespaces_all=true
|
||||||
sp_cleanup.remove_trailing_whitespaces_ignore_empty=true
|
sp_cleanup.remove_trailing_whitespaces_ignore_empty=true
|
||||||
|
sp_cleanup.remove_unnecessary_array_creation=false
|
||||||
sp_cleanup.remove_unnecessary_casts=true
|
sp_cleanup.remove_unnecessary_casts=true
|
||||||
sp_cleanup.remove_unnecessary_nls_tags=true
|
sp_cleanup.remove_unnecessary_nls_tags=true
|
||||||
sp_cleanup.remove_unused_imports=true
|
sp_cleanup.remove_unused_imports=true
|
||||||
@@ -126,11 +131,14 @@ sp_cleanup.remove_unused_private_fields=true
|
|||||||
sp_cleanup.remove_unused_private_members=false
|
sp_cleanup.remove_unused_private_members=false
|
||||||
sp_cleanup.remove_unused_private_methods=true
|
sp_cleanup.remove_unused_private_methods=true
|
||||||
sp_cleanup.remove_unused_private_types=true
|
sp_cleanup.remove_unused_private_types=true
|
||||||
|
sp_cleanup.simplify_lambda_expression_and_method_ref=false
|
||||||
sp_cleanup.sort_members=false
|
sp_cleanup.sort_members=false
|
||||||
sp_cleanup.sort_members_all=false
|
sp_cleanup.sort_members_all=false
|
||||||
sp_cleanup.use_anonymous_class_creation=false
|
sp_cleanup.use_anonymous_class_creation=false
|
||||||
|
sp_cleanup.use_autoboxing=false
|
||||||
sp_cleanup.use_blocks=true
|
sp_cleanup.use_blocks=true
|
||||||
sp_cleanup.use_blocks_only_for_return_and_throw=false
|
sp_cleanup.use_blocks_only_for_return_and_throw=false
|
||||||
|
sp_cleanup.use_directly_map_method=false
|
||||||
sp_cleanup.use_lambda=true
|
sp_cleanup.use_lambda=true
|
||||||
sp_cleanup.use_parentheses_in_expressions=true
|
sp_cleanup.use_parentheses_in_expressions=true
|
||||||
sp_cleanup.use_this_for_non_static_field_access=false
|
sp_cleanup.use_this_for_non_static_field_access=false
|
||||||
@@ -138,3 +146,4 @@ sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true
|
|||||||
sp_cleanup.use_this_for_non_static_method_access=false
|
sp_cleanup.use_this_for_non_static_method_access=false
|
||||||
sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true
|
sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true
|
||||||
sp_cleanup.use_type_arguments=false
|
sp_cleanup.use_type_arguments=false
|
||||||
|
sp_cleanup.use_unboxing=false
|
||||||
|
@@ -406,10 +406,13 @@ public class World
|
|||||||
oldRegion.removeVisibleObject(object);
|
oldRegion.removeVisibleObject(object);
|
||||||
|
|
||||||
// Go through all surrounding WorldRegion Creatures
|
// Go through all surrounding WorldRegion Creatures
|
||||||
for (WorldRegion worldRegion : oldRegion.getSurroundingRegions())
|
final WorldRegion[] surroundingRegions = oldRegion.getSurroundingRegions();
|
||||||
|
for (int i = 0; i < surroundingRegions.length; i++)
|
||||||
{
|
{
|
||||||
for (WorldObject wo : worldRegion.getVisibleObjects().values())
|
final List<WorldObject> visibleObjects = surroundingRegions[i].getVisibleObjects();
|
||||||
|
for (int j = 0; j < visibleObjects.size(); j++)
|
||||||
{
|
{
|
||||||
|
final WorldObject wo = visibleObjects.get(j);
|
||||||
if (wo == object)
|
if (wo == object)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
@@ -466,15 +469,19 @@ public class World
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (WorldRegion worldRegion : oldRegion.getSurroundingRegions())
|
final WorldRegion[] oldSurroundingRegions = oldRegion.getSurroundingRegions();
|
||||||
|
for (int i = 0; i < oldSurroundingRegions.length; i++)
|
||||||
{
|
{
|
||||||
|
final WorldRegion worldRegion = oldSurroundingRegions[i];
|
||||||
if (newRegion.isSurroundingRegion(worldRegion))
|
if (newRegion.isSurroundingRegion(worldRegion))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (WorldObject wo : worldRegion.getVisibleObjects().values())
|
final List<WorldObject> visibleObjects = worldRegion.getVisibleObjects();
|
||||||
|
for (int j = 0; j < visibleObjects.size(); j++)
|
||||||
{
|
{
|
||||||
|
final WorldObject wo = visibleObjects.get(j);
|
||||||
if (wo == object)
|
if (wo == object)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
@@ -522,15 +529,19 @@ public class World
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (WorldRegion worldRegion : newRegion.getSurroundingRegions())
|
final WorldRegion[] newSurroundingRegions = newRegion.getSurroundingRegions();
|
||||||
|
for (int i = 0; i < newSurroundingRegions.length; i++)
|
||||||
{
|
{
|
||||||
|
final WorldRegion worldRegion = newSurroundingRegions[i];
|
||||||
if (oldRegion.isSurroundingRegion(worldRegion))
|
if (oldRegion.isSurroundingRegion(worldRegion))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (WorldObject wo : worldRegion.getVisibleObjects().values())
|
final List<WorldObject> visibleObjects = worldRegion.getVisibleObjects();
|
||||||
|
for (int j = 0; j < visibleObjects.size(); j++)
|
||||||
{
|
{
|
||||||
|
final WorldObject wo = visibleObjects.get(j);
|
||||||
if ((wo == object) || (wo.getInstanceWorld() != object.getInstanceWorld()))
|
if ((wo == object) || (wo.getInstanceWorld() != object.getInstanceWorld()))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
@@ -610,27 +621,30 @@ public class World
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final WorldRegion centerWorldRegion = getRegion(object);
|
final WorldRegion worldRegion = getRegion(object);
|
||||||
if (centerWorldRegion == null)
|
if (worldRegion == null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (WorldRegion region : centerWorldRegion.getSurroundingRegions())
|
final WorldRegion[] surroundingRegions = worldRegion.getSurroundingRegions();
|
||||||
|
for (int i = 0; i < surroundingRegions.length; i++)
|
||||||
{
|
{
|
||||||
for (WorldObject visibleObject : region.getVisibleObjects().values())
|
final List<WorldObject> visibleObjects = surroundingRegions[i].getVisibleObjects();
|
||||||
|
for (int j = 0; j < visibleObjects.size(); j++)
|
||||||
{
|
{
|
||||||
if ((visibleObject == null) || (visibleObject == object) || !clazz.isInstance(visibleObject))
|
final WorldObject wo = visibleObjects.get(j);
|
||||||
|
if ((wo == null) || (wo == object) || !clazz.isInstance(wo))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (visibleObject.getInstanceWorld() != object.getInstanceWorld())
|
if (wo.getInstanceWorld() != object.getInstanceWorld())
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
c.accept(clazz.cast(visibleObject));
|
c.accept(clazz.cast(wo));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -662,29 +676,32 @@ public class World
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final WorldRegion centerWorldRegion = getRegion(object);
|
final WorldRegion worldRegion = getRegion(object);
|
||||||
if (centerWorldRegion == null)
|
if (worldRegion == null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (WorldRegion region : centerWorldRegion.getSurroundingRegions())
|
final WorldRegion[] surroundingRegions = worldRegion.getSurroundingRegions();
|
||||||
|
for (int i = 0; i < surroundingRegions.length; i++)
|
||||||
{
|
{
|
||||||
for (WorldObject visibleObject : region.getVisibleObjects().values())
|
final List<WorldObject> visibleObjects = surroundingRegions[i].getVisibleObjects();
|
||||||
|
for (int j = 0; j < visibleObjects.size(); j++)
|
||||||
{
|
{
|
||||||
if ((visibleObject == null) || (visibleObject == object) || !clazz.isInstance(visibleObject))
|
final WorldObject wo = visibleObjects.get(j);
|
||||||
|
if ((wo == null) || (wo == object) || !clazz.isInstance(wo))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (visibleObject.getInstanceWorld() != object.getInstanceWorld())
|
if (wo.getInstanceWorld() != object.getInstanceWorld())
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (visibleObject.calculateDistance3D(object) <= range)
|
if (wo.calculateDistance3D(object) <= range)
|
||||||
{
|
{
|
||||||
c.accept(clazz.cast(visibleObject));
|
c.accept(clazz.cast(wo));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -16,8 +16,8 @@
|
|||||||
*/
|
*/
|
||||||
package org.l2jmobius.gameserver.model;
|
package org.l2jmobius.gameserver.model;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.ArrayList;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.List;
|
||||||
import java.util.concurrent.ScheduledFuture;
|
import java.util.concurrent.ScheduledFuture;
|
||||||
|
|
||||||
import org.l2jmobius.Config;
|
import org.l2jmobius.Config;
|
||||||
@@ -28,9 +28,9 @@ import org.l2jmobius.gameserver.taskmanager.RandomAnimationTaskManager;
|
|||||||
|
|
||||||
public class WorldRegion
|
public class WorldRegion
|
||||||
{
|
{
|
||||||
/** Map containing visible objects in this world region. */
|
/** List containing visible objects in this world region. */
|
||||||
private final Map<Integer, WorldObject> _visibleObjects = new ConcurrentHashMap<>();
|
private final List<WorldObject> _visibleObjects = new ArrayList<>();
|
||||||
/** Map containing nearby regions forming this world region's effective area. */
|
/** Array containing nearby regions forming this world region's effective area. */
|
||||||
private WorldRegion[] _surroundingRegions;
|
private WorldRegion[] _surroundingRegions;
|
||||||
private final int _regionX;
|
private final int _regionX;
|
||||||
private final int _regionY;
|
private final int _regionY;
|
||||||
@@ -52,8 +52,9 @@ public class WorldRegion
|
|||||||
|
|
||||||
if (!isOn)
|
if (!isOn)
|
||||||
{
|
{
|
||||||
for (WorldObject wo : _visibleObjects.values())
|
for (int i = 0; i < _visibleObjects.size(); i++)
|
||||||
{
|
{
|
||||||
|
final WorldObject wo = _visibleObjects.get(i);
|
||||||
if (wo.isAttackable())
|
if (wo.isAttackable())
|
||||||
{
|
{
|
||||||
final Attackable mob = (Attackable) wo;
|
final Attackable mob = (Attackable) wo;
|
||||||
@@ -87,15 +88,16 @@ public class WorldRegion
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for (WorldObject wo : _visibleObjects.values())
|
for (int i = 0; i < _visibleObjects.size(); i++)
|
||||||
{
|
{
|
||||||
|
final WorldObject wo = _visibleObjects.get(i);
|
||||||
if (wo.isAttackable())
|
if (wo.isAttackable())
|
||||||
{
|
{
|
||||||
// Start HP/MP/CP regeneration task.
|
// Start HP/MP/CP regeneration task.
|
||||||
((Attackable) wo).getStatus().startHpMpRegeneration();
|
((Attackable) wo).getStatus().startHpMpRegeneration();
|
||||||
RandomAnimationTaskManager.getInstance().add((Npc) wo);
|
RandomAnimationTaskManager.getInstance().add((Npc) wo);
|
||||||
}
|
}
|
||||||
else if (wo instanceof Npc)
|
else if (wo.isNpc())
|
||||||
{
|
{
|
||||||
RandomAnimationTaskManager.getInstance().add((Npc) wo);
|
RandomAnimationTaskManager.getInstance().add((Npc) wo);
|
||||||
}
|
}
|
||||||
@@ -110,13 +112,21 @@ public class WorldRegion
|
|||||||
|
|
||||||
public boolean areNeighborsEmpty()
|
public boolean areNeighborsEmpty()
|
||||||
{
|
{
|
||||||
for (WorldRegion worldRegion : _surroundingRegions)
|
for (int i = 0; i < _surroundingRegions.length; i++)
|
||||||
{
|
{
|
||||||
if (worldRegion.isActive() && worldRegion.getVisibleObjects().values().stream().anyMatch(WorldObject::isPlayable))
|
final WorldRegion worldRegion = _surroundingRegions[i];
|
||||||
|
if (worldRegion.isActive())
|
||||||
|
{
|
||||||
|
final List<WorldObject> regionObjects = worldRegion.getVisibleObjects();
|
||||||
|
for (int j = 0; j < regionObjects.size(); j++)
|
||||||
|
{
|
||||||
|
if (regionObjects.get(j).isPlayable())
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -157,9 +167,9 @@ public class WorldRegion
|
|||||||
// Then, set a timer to activate the neighbors.
|
// Then, set a timer to activate the neighbors.
|
||||||
_neighborsTask = ThreadPool.schedule(() ->
|
_neighborsTask = ThreadPool.schedule(() ->
|
||||||
{
|
{
|
||||||
for (WorldRegion worldRegion : _surroundingRegions)
|
for (int i = 0; i < _surroundingRegions.length; i++)
|
||||||
{
|
{
|
||||||
worldRegion.setActive(true);
|
_surroundingRegions[i].setActive(true);
|
||||||
}
|
}
|
||||||
}, 1000 * Config.GRID_NEIGHBOR_TURNON_TIME);
|
}, 1000 * Config.GRID_NEIGHBOR_TURNON_TIME);
|
||||||
}
|
}
|
||||||
@@ -183,8 +193,9 @@ public class WorldRegion
|
|||||||
// Suggest means: first check if a neighbor has PlayerInstances in it. If not, deactivate.
|
// Suggest means: first check if a neighbor has PlayerInstances in it. If not, deactivate.
|
||||||
_neighborsTask = ThreadPool.schedule(() ->
|
_neighborsTask = ThreadPool.schedule(() ->
|
||||||
{
|
{
|
||||||
for (WorldRegion worldRegion : _surroundingRegions)
|
for (int i = 0; i < _surroundingRegions.length; i++)
|
||||||
{
|
{
|
||||||
|
final WorldRegion worldRegion = _surroundingRegions[i];
|
||||||
if (worldRegion.areNeighborsEmpty())
|
if (worldRegion.areNeighborsEmpty())
|
||||||
{
|
{
|
||||||
worldRegion.setActive(false);
|
worldRegion.setActive(false);
|
||||||
@@ -206,7 +217,13 @@ public class WorldRegion
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
_visibleObjects.put(object.getObjectId(), object);
|
synchronized (_visibleObjects)
|
||||||
|
{
|
||||||
|
if (!_visibleObjects.contains(object))
|
||||||
|
{
|
||||||
|
_visibleObjects.add(object);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// If this is the first player to enter the region, activate self and neighbors.
|
// If this is the first player to enter the region, activate self and neighbors.
|
||||||
if (object.isPlayable() && !_active && !Config.GRIDS_ALWAYS_ON)
|
if (object.isPlayable() && !_active && !Config.GRIDS_ALWAYS_ON)
|
||||||
@@ -230,7 +247,11 @@ public class WorldRegion
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_visibleObjects.remove(object.getObjectId());
|
|
||||||
|
synchronized (_visibleObjects)
|
||||||
|
{
|
||||||
|
_visibleObjects.remove(object);
|
||||||
|
}
|
||||||
|
|
||||||
if (object.isPlayable() && areNeighborsEmpty() && !Config.GRIDS_ALWAYS_ON)
|
if (object.isPlayable() && areNeighborsEmpty() && !Config.GRIDS_ALWAYS_ON)
|
||||||
{
|
{
|
||||||
@@ -238,7 +259,7 @@ public class WorldRegion
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<Integer, WorldObject> getVisibleObjects()
|
public List<WorldObject> getVisibleObjects()
|
||||||
{
|
{
|
||||||
return _visibleObjects;
|
return _visibleObjects;
|
||||||
}
|
}
|
||||||
|
@@ -94,7 +94,7 @@ sp_cleanup.always_use_parentheses_in_expressions=true
|
|||||||
sp_cleanup.always_use_this_for_non_static_field_access=false
|
sp_cleanup.always_use_this_for_non_static_field_access=false
|
||||||
sp_cleanup.always_use_this_for_non_static_method_access=false
|
sp_cleanup.always_use_this_for_non_static_method_access=false
|
||||||
sp_cleanup.convert_functional_interfaces=true
|
sp_cleanup.convert_functional_interfaces=true
|
||||||
sp_cleanup.convert_to_enhanced_for_loop=true
|
sp_cleanup.convert_to_enhanced_for_loop=false
|
||||||
sp_cleanup.correct_indentation=false
|
sp_cleanup.correct_indentation=false
|
||||||
sp_cleanup.format_source_code=true
|
sp_cleanup.format_source_code=true
|
||||||
sp_cleanup.format_source_code_changes_only=false
|
sp_cleanup.format_source_code_changes_only=false
|
||||||
@@ -106,18 +106,23 @@ sp_cleanup.make_type_abstract_if_missing_method=false
|
|||||||
sp_cleanup.make_variable_declarations_final=true
|
sp_cleanup.make_variable_declarations_final=true
|
||||||
sp_cleanup.never_use_blocks=false
|
sp_cleanup.never_use_blocks=false
|
||||||
sp_cleanup.never_use_parentheses_in_expressions=false
|
sp_cleanup.never_use_parentheses_in_expressions=false
|
||||||
|
sp_cleanup.number_suffix=false
|
||||||
sp_cleanup.on_save_use_additional_actions=true
|
sp_cleanup.on_save_use_additional_actions=true
|
||||||
sp_cleanup.organize_imports=true
|
sp_cleanup.organize_imports=true
|
||||||
|
sp_cleanup.push_down_negation=false
|
||||||
sp_cleanup.qualify_static_field_accesses_with_declaring_class=false
|
sp_cleanup.qualify_static_field_accesses_with_declaring_class=false
|
||||||
sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true
|
sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true
|
||||||
sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true
|
sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true
|
||||||
sp_cleanup.qualify_static_member_accesses_with_declaring_class=true
|
sp_cleanup.qualify_static_member_accesses_with_declaring_class=true
|
||||||
sp_cleanup.qualify_static_method_accesses_with_declaring_class=false
|
sp_cleanup.qualify_static_method_accesses_with_declaring_class=false
|
||||||
sp_cleanup.remove_private_constructors=true
|
sp_cleanup.remove_private_constructors=true
|
||||||
|
sp_cleanup.remove_redundant_modifiers=false
|
||||||
|
sp_cleanup.remove_redundant_semicolons=false
|
||||||
sp_cleanup.remove_redundant_type_arguments=false
|
sp_cleanup.remove_redundant_type_arguments=false
|
||||||
sp_cleanup.remove_trailing_whitespaces=false
|
sp_cleanup.remove_trailing_whitespaces=false
|
||||||
sp_cleanup.remove_trailing_whitespaces_all=true
|
sp_cleanup.remove_trailing_whitespaces_all=true
|
||||||
sp_cleanup.remove_trailing_whitespaces_ignore_empty=true
|
sp_cleanup.remove_trailing_whitespaces_ignore_empty=true
|
||||||
|
sp_cleanup.remove_unnecessary_array_creation=false
|
||||||
sp_cleanup.remove_unnecessary_casts=true
|
sp_cleanup.remove_unnecessary_casts=true
|
||||||
sp_cleanup.remove_unnecessary_nls_tags=true
|
sp_cleanup.remove_unnecessary_nls_tags=true
|
||||||
sp_cleanup.remove_unused_imports=true
|
sp_cleanup.remove_unused_imports=true
|
||||||
@@ -126,11 +131,14 @@ sp_cleanup.remove_unused_private_fields=true
|
|||||||
sp_cleanup.remove_unused_private_members=false
|
sp_cleanup.remove_unused_private_members=false
|
||||||
sp_cleanup.remove_unused_private_methods=true
|
sp_cleanup.remove_unused_private_methods=true
|
||||||
sp_cleanup.remove_unused_private_types=true
|
sp_cleanup.remove_unused_private_types=true
|
||||||
|
sp_cleanup.simplify_lambda_expression_and_method_ref=false
|
||||||
sp_cleanup.sort_members=false
|
sp_cleanup.sort_members=false
|
||||||
sp_cleanup.sort_members_all=false
|
sp_cleanup.sort_members_all=false
|
||||||
sp_cleanup.use_anonymous_class_creation=false
|
sp_cleanup.use_anonymous_class_creation=false
|
||||||
|
sp_cleanup.use_autoboxing=false
|
||||||
sp_cleanup.use_blocks=true
|
sp_cleanup.use_blocks=true
|
||||||
sp_cleanup.use_blocks_only_for_return_and_throw=false
|
sp_cleanup.use_blocks_only_for_return_and_throw=false
|
||||||
|
sp_cleanup.use_directly_map_method=false
|
||||||
sp_cleanup.use_lambda=true
|
sp_cleanup.use_lambda=true
|
||||||
sp_cleanup.use_parentheses_in_expressions=true
|
sp_cleanup.use_parentheses_in_expressions=true
|
||||||
sp_cleanup.use_this_for_non_static_field_access=false
|
sp_cleanup.use_this_for_non_static_field_access=false
|
||||||
@@ -138,3 +146,4 @@ sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true
|
|||||||
sp_cleanup.use_this_for_non_static_method_access=false
|
sp_cleanup.use_this_for_non_static_method_access=false
|
||||||
sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true
|
sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true
|
||||||
sp_cleanup.use_type_arguments=false
|
sp_cleanup.use_type_arguments=false
|
||||||
|
sp_cleanup.use_unboxing=false
|
||||||
|
@@ -406,10 +406,13 @@ public class World
|
|||||||
oldRegion.removeVisibleObject(object);
|
oldRegion.removeVisibleObject(object);
|
||||||
|
|
||||||
// Go through all surrounding WorldRegion Creatures
|
// Go through all surrounding WorldRegion Creatures
|
||||||
for (WorldRegion worldRegion : oldRegion.getSurroundingRegions())
|
final WorldRegion[] surroundingRegions = oldRegion.getSurroundingRegions();
|
||||||
|
for (int i = 0; i < surroundingRegions.length; i++)
|
||||||
{
|
{
|
||||||
for (WorldObject wo : worldRegion.getVisibleObjects().values())
|
final List<WorldObject> visibleObjects = surroundingRegions[i].getVisibleObjects();
|
||||||
|
for (int j = 0; j < visibleObjects.size(); j++)
|
||||||
{
|
{
|
||||||
|
final WorldObject wo = visibleObjects.get(j);
|
||||||
if (wo == object)
|
if (wo == object)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
@@ -466,15 +469,19 @@ public class World
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (WorldRegion worldRegion : oldRegion.getSurroundingRegions())
|
final WorldRegion[] oldSurroundingRegions = oldRegion.getSurroundingRegions();
|
||||||
|
for (int i = 0; i < oldSurroundingRegions.length; i++)
|
||||||
{
|
{
|
||||||
|
final WorldRegion worldRegion = oldSurroundingRegions[i];
|
||||||
if (newRegion.isSurroundingRegion(worldRegion))
|
if (newRegion.isSurroundingRegion(worldRegion))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (WorldObject wo : worldRegion.getVisibleObjects().values())
|
final List<WorldObject> visibleObjects = worldRegion.getVisibleObjects();
|
||||||
|
for (int j = 0; j < visibleObjects.size(); j++)
|
||||||
{
|
{
|
||||||
|
final WorldObject wo = visibleObjects.get(j);
|
||||||
if (wo == object)
|
if (wo == object)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
@@ -522,15 +529,19 @@ public class World
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (WorldRegion worldRegion : newRegion.getSurroundingRegions())
|
final WorldRegion[] newSurroundingRegions = newRegion.getSurroundingRegions();
|
||||||
|
for (int i = 0; i < newSurroundingRegions.length; i++)
|
||||||
{
|
{
|
||||||
|
final WorldRegion worldRegion = newSurroundingRegions[i];
|
||||||
if (oldRegion.isSurroundingRegion(worldRegion))
|
if (oldRegion.isSurroundingRegion(worldRegion))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (WorldObject wo : worldRegion.getVisibleObjects().values())
|
final List<WorldObject> visibleObjects = worldRegion.getVisibleObjects();
|
||||||
|
for (int j = 0; j < visibleObjects.size(); j++)
|
||||||
{
|
{
|
||||||
|
final WorldObject wo = visibleObjects.get(j);
|
||||||
if ((wo == object) || (wo.getInstanceWorld() != object.getInstanceWorld()))
|
if ((wo == object) || (wo.getInstanceWorld() != object.getInstanceWorld()))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
@@ -610,27 +621,30 @@ public class World
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final WorldRegion centerWorldRegion = getRegion(object);
|
final WorldRegion worldRegion = getRegion(object);
|
||||||
if (centerWorldRegion == null)
|
if (worldRegion == null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (WorldRegion region : centerWorldRegion.getSurroundingRegions())
|
final WorldRegion[] surroundingRegions = worldRegion.getSurroundingRegions();
|
||||||
|
for (int i = 0; i < surroundingRegions.length; i++)
|
||||||
{
|
{
|
||||||
for (WorldObject visibleObject : region.getVisibleObjects().values())
|
final List<WorldObject> visibleObjects = surroundingRegions[i].getVisibleObjects();
|
||||||
|
for (int j = 0; j < visibleObjects.size(); j++)
|
||||||
{
|
{
|
||||||
if ((visibleObject == null) || (visibleObject == object) || !clazz.isInstance(visibleObject))
|
final WorldObject wo = visibleObjects.get(j);
|
||||||
|
if ((wo == null) || (wo == object) || !clazz.isInstance(wo))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (visibleObject.getInstanceWorld() != object.getInstanceWorld())
|
if (wo.getInstanceWorld() != object.getInstanceWorld())
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
c.accept(clazz.cast(visibleObject));
|
c.accept(clazz.cast(wo));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -662,29 +676,32 @@ public class World
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final WorldRegion centerWorldRegion = getRegion(object);
|
final WorldRegion worldRegion = getRegion(object);
|
||||||
if (centerWorldRegion == null)
|
if (worldRegion == null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (WorldRegion region : centerWorldRegion.getSurroundingRegions())
|
final WorldRegion[] surroundingRegions = worldRegion.getSurroundingRegions();
|
||||||
|
for (int i = 0; i < surroundingRegions.length; i++)
|
||||||
{
|
{
|
||||||
for (WorldObject visibleObject : region.getVisibleObjects().values())
|
final List<WorldObject> visibleObjects = surroundingRegions[i].getVisibleObjects();
|
||||||
|
for (int j = 0; j < visibleObjects.size(); j++)
|
||||||
{
|
{
|
||||||
if ((visibleObject == null) || (visibleObject == object) || !clazz.isInstance(visibleObject))
|
final WorldObject wo = visibleObjects.get(j);
|
||||||
|
if ((wo == null) || (wo == object) || !clazz.isInstance(wo))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (visibleObject.getInstanceWorld() != object.getInstanceWorld())
|
if (wo.getInstanceWorld() != object.getInstanceWorld())
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (visibleObject.calculateDistance3D(object) <= range)
|
if (wo.calculateDistance3D(object) <= range)
|
||||||
{
|
{
|
||||||
c.accept(clazz.cast(visibleObject));
|
c.accept(clazz.cast(wo));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -16,8 +16,8 @@
|
|||||||
*/
|
*/
|
||||||
package org.l2jmobius.gameserver.model;
|
package org.l2jmobius.gameserver.model;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.ArrayList;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.List;
|
||||||
import java.util.concurrent.ScheduledFuture;
|
import java.util.concurrent.ScheduledFuture;
|
||||||
|
|
||||||
import org.l2jmobius.Config;
|
import org.l2jmobius.Config;
|
||||||
@@ -28,9 +28,9 @@ import org.l2jmobius.gameserver.taskmanager.RandomAnimationTaskManager;
|
|||||||
|
|
||||||
public class WorldRegion
|
public class WorldRegion
|
||||||
{
|
{
|
||||||
/** Map containing visible objects in this world region. */
|
/** List containing visible objects in this world region. */
|
||||||
private final Map<Integer, WorldObject> _visibleObjects = new ConcurrentHashMap<>();
|
private final List<WorldObject> _visibleObjects = new ArrayList<>();
|
||||||
/** Map containing nearby regions forming this world region's effective area. */
|
/** Array containing nearby regions forming this world region's effective area. */
|
||||||
private WorldRegion[] _surroundingRegions;
|
private WorldRegion[] _surroundingRegions;
|
||||||
private final int _regionX;
|
private final int _regionX;
|
||||||
private final int _regionY;
|
private final int _regionY;
|
||||||
@@ -52,8 +52,9 @@ public class WorldRegion
|
|||||||
|
|
||||||
if (!isOn)
|
if (!isOn)
|
||||||
{
|
{
|
||||||
for (WorldObject wo : _visibleObjects.values())
|
for (int i = 0; i < _visibleObjects.size(); i++)
|
||||||
{
|
{
|
||||||
|
final WorldObject wo = _visibleObjects.get(i);
|
||||||
if (wo.isAttackable())
|
if (wo.isAttackable())
|
||||||
{
|
{
|
||||||
final Attackable mob = (Attackable) wo;
|
final Attackable mob = (Attackable) wo;
|
||||||
@@ -87,15 +88,16 @@ public class WorldRegion
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for (WorldObject wo : _visibleObjects.values())
|
for (int i = 0; i < _visibleObjects.size(); i++)
|
||||||
{
|
{
|
||||||
|
final WorldObject wo = _visibleObjects.get(i);
|
||||||
if (wo.isAttackable())
|
if (wo.isAttackable())
|
||||||
{
|
{
|
||||||
// Start HP/MP/CP regeneration task.
|
// Start HP/MP/CP regeneration task.
|
||||||
((Attackable) wo).getStatus().startHpMpRegeneration();
|
((Attackable) wo).getStatus().startHpMpRegeneration();
|
||||||
RandomAnimationTaskManager.getInstance().add((Npc) wo);
|
RandomAnimationTaskManager.getInstance().add((Npc) wo);
|
||||||
}
|
}
|
||||||
else if (wo instanceof Npc)
|
else if (wo.isNpc())
|
||||||
{
|
{
|
||||||
RandomAnimationTaskManager.getInstance().add((Npc) wo);
|
RandomAnimationTaskManager.getInstance().add((Npc) wo);
|
||||||
}
|
}
|
||||||
@@ -110,13 +112,21 @@ public class WorldRegion
|
|||||||
|
|
||||||
public boolean areNeighborsEmpty()
|
public boolean areNeighborsEmpty()
|
||||||
{
|
{
|
||||||
for (WorldRegion worldRegion : _surroundingRegions)
|
for (int i = 0; i < _surroundingRegions.length; i++)
|
||||||
{
|
{
|
||||||
if (worldRegion.isActive() && worldRegion.getVisibleObjects().values().stream().anyMatch(WorldObject::isPlayable))
|
final WorldRegion worldRegion = _surroundingRegions[i];
|
||||||
|
if (worldRegion.isActive())
|
||||||
|
{
|
||||||
|
final List<WorldObject> regionObjects = worldRegion.getVisibleObjects();
|
||||||
|
for (int j = 0; j < regionObjects.size(); j++)
|
||||||
|
{
|
||||||
|
if (regionObjects.get(j).isPlayable())
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -157,9 +167,9 @@ public class WorldRegion
|
|||||||
// Then, set a timer to activate the neighbors.
|
// Then, set a timer to activate the neighbors.
|
||||||
_neighborsTask = ThreadPool.schedule(() ->
|
_neighborsTask = ThreadPool.schedule(() ->
|
||||||
{
|
{
|
||||||
for (WorldRegion worldRegion : _surroundingRegions)
|
for (int i = 0; i < _surroundingRegions.length; i++)
|
||||||
{
|
{
|
||||||
worldRegion.setActive(true);
|
_surroundingRegions[i].setActive(true);
|
||||||
}
|
}
|
||||||
}, 1000 * Config.GRID_NEIGHBOR_TURNON_TIME);
|
}, 1000 * Config.GRID_NEIGHBOR_TURNON_TIME);
|
||||||
}
|
}
|
||||||
@@ -183,8 +193,9 @@ public class WorldRegion
|
|||||||
// Suggest means: first check if a neighbor has PlayerInstances in it. If not, deactivate.
|
// Suggest means: first check if a neighbor has PlayerInstances in it. If not, deactivate.
|
||||||
_neighborsTask = ThreadPool.schedule(() ->
|
_neighborsTask = ThreadPool.schedule(() ->
|
||||||
{
|
{
|
||||||
for (WorldRegion worldRegion : _surroundingRegions)
|
for (int i = 0; i < _surroundingRegions.length; i++)
|
||||||
{
|
{
|
||||||
|
final WorldRegion worldRegion = _surroundingRegions[i];
|
||||||
if (worldRegion.areNeighborsEmpty())
|
if (worldRegion.areNeighborsEmpty())
|
||||||
{
|
{
|
||||||
worldRegion.setActive(false);
|
worldRegion.setActive(false);
|
||||||
@@ -206,7 +217,13 @@ public class WorldRegion
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
_visibleObjects.put(object.getObjectId(), object);
|
synchronized (_visibleObjects)
|
||||||
|
{
|
||||||
|
if (!_visibleObjects.contains(object))
|
||||||
|
{
|
||||||
|
_visibleObjects.add(object);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// If this is the first player to enter the region, activate self and neighbors.
|
// If this is the first player to enter the region, activate self and neighbors.
|
||||||
if (object.isPlayable() && !_active && !Config.GRIDS_ALWAYS_ON)
|
if (object.isPlayable() && !_active && !Config.GRIDS_ALWAYS_ON)
|
||||||
@@ -230,7 +247,11 @@ public class WorldRegion
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_visibleObjects.remove(object.getObjectId());
|
|
||||||
|
synchronized (_visibleObjects)
|
||||||
|
{
|
||||||
|
_visibleObjects.remove(object);
|
||||||
|
}
|
||||||
|
|
||||||
if (object.isPlayable() && areNeighborsEmpty() && !Config.GRIDS_ALWAYS_ON)
|
if (object.isPlayable() && areNeighborsEmpty() && !Config.GRIDS_ALWAYS_ON)
|
||||||
{
|
{
|
||||||
@@ -238,7 +259,7 @@ public class WorldRegion
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<Integer, WorldObject> getVisibleObjects()
|
public List<WorldObject> getVisibleObjects()
|
||||||
{
|
{
|
||||||
return _visibleObjects;
|
return _visibleObjects;
|
||||||
}
|
}
|
||||||
|
@@ -94,7 +94,7 @@ sp_cleanup.always_use_parentheses_in_expressions=true
|
|||||||
sp_cleanup.always_use_this_for_non_static_field_access=false
|
sp_cleanup.always_use_this_for_non_static_field_access=false
|
||||||
sp_cleanup.always_use_this_for_non_static_method_access=false
|
sp_cleanup.always_use_this_for_non_static_method_access=false
|
||||||
sp_cleanup.convert_functional_interfaces=true
|
sp_cleanup.convert_functional_interfaces=true
|
||||||
sp_cleanup.convert_to_enhanced_for_loop=true
|
sp_cleanup.convert_to_enhanced_for_loop=false
|
||||||
sp_cleanup.correct_indentation=false
|
sp_cleanup.correct_indentation=false
|
||||||
sp_cleanup.format_source_code=true
|
sp_cleanup.format_source_code=true
|
||||||
sp_cleanup.format_source_code_changes_only=false
|
sp_cleanup.format_source_code_changes_only=false
|
||||||
@@ -106,18 +106,23 @@ sp_cleanup.make_type_abstract_if_missing_method=false
|
|||||||
sp_cleanup.make_variable_declarations_final=true
|
sp_cleanup.make_variable_declarations_final=true
|
||||||
sp_cleanup.never_use_blocks=false
|
sp_cleanup.never_use_blocks=false
|
||||||
sp_cleanup.never_use_parentheses_in_expressions=false
|
sp_cleanup.never_use_parentheses_in_expressions=false
|
||||||
|
sp_cleanup.number_suffix=false
|
||||||
sp_cleanup.on_save_use_additional_actions=true
|
sp_cleanup.on_save_use_additional_actions=true
|
||||||
sp_cleanup.organize_imports=true
|
sp_cleanup.organize_imports=true
|
||||||
|
sp_cleanup.push_down_negation=false
|
||||||
sp_cleanup.qualify_static_field_accesses_with_declaring_class=false
|
sp_cleanup.qualify_static_field_accesses_with_declaring_class=false
|
||||||
sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true
|
sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true
|
||||||
sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true
|
sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true
|
||||||
sp_cleanup.qualify_static_member_accesses_with_declaring_class=true
|
sp_cleanup.qualify_static_member_accesses_with_declaring_class=true
|
||||||
sp_cleanup.qualify_static_method_accesses_with_declaring_class=false
|
sp_cleanup.qualify_static_method_accesses_with_declaring_class=false
|
||||||
sp_cleanup.remove_private_constructors=true
|
sp_cleanup.remove_private_constructors=true
|
||||||
|
sp_cleanup.remove_redundant_modifiers=false
|
||||||
|
sp_cleanup.remove_redundant_semicolons=false
|
||||||
sp_cleanup.remove_redundant_type_arguments=false
|
sp_cleanup.remove_redundant_type_arguments=false
|
||||||
sp_cleanup.remove_trailing_whitespaces=false
|
sp_cleanup.remove_trailing_whitespaces=false
|
||||||
sp_cleanup.remove_trailing_whitespaces_all=true
|
sp_cleanup.remove_trailing_whitespaces_all=true
|
||||||
sp_cleanup.remove_trailing_whitespaces_ignore_empty=true
|
sp_cleanup.remove_trailing_whitespaces_ignore_empty=true
|
||||||
|
sp_cleanup.remove_unnecessary_array_creation=false
|
||||||
sp_cleanup.remove_unnecessary_casts=true
|
sp_cleanup.remove_unnecessary_casts=true
|
||||||
sp_cleanup.remove_unnecessary_nls_tags=true
|
sp_cleanup.remove_unnecessary_nls_tags=true
|
||||||
sp_cleanup.remove_unused_imports=true
|
sp_cleanup.remove_unused_imports=true
|
||||||
@@ -126,11 +131,14 @@ sp_cleanup.remove_unused_private_fields=true
|
|||||||
sp_cleanup.remove_unused_private_members=false
|
sp_cleanup.remove_unused_private_members=false
|
||||||
sp_cleanup.remove_unused_private_methods=true
|
sp_cleanup.remove_unused_private_methods=true
|
||||||
sp_cleanup.remove_unused_private_types=true
|
sp_cleanup.remove_unused_private_types=true
|
||||||
|
sp_cleanup.simplify_lambda_expression_and_method_ref=false
|
||||||
sp_cleanup.sort_members=false
|
sp_cleanup.sort_members=false
|
||||||
sp_cleanup.sort_members_all=false
|
sp_cleanup.sort_members_all=false
|
||||||
sp_cleanup.use_anonymous_class_creation=false
|
sp_cleanup.use_anonymous_class_creation=false
|
||||||
|
sp_cleanup.use_autoboxing=false
|
||||||
sp_cleanup.use_blocks=true
|
sp_cleanup.use_blocks=true
|
||||||
sp_cleanup.use_blocks_only_for_return_and_throw=false
|
sp_cleanup.use_blocks_only_for_return_and_throw=false
|
||||||
|
sp_cleanup.use_directly_map_method=false
|
||||||
sp_cleanup.use_lambda=true
|
sp_cleanup.use_lambda=true
|
||||||
sp_cleanup.use_parentheses_in_expressions=true
|
sp_cleanup.use_parentheses_in_expressions=true
|
||||||
sp_cleanup.use_this_for_non_static_field_access=false
|
sp_cleanup.use_this_for_non_static_field_access=false
|
||||||
@@ -138,3 +146,4 @@ sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true
|
|||||||
sp_cleanup.use_this_for_non_static_method_access=false
|
sp_cleanup.use_this_for_non_static_method_access=false
|
||||||
sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true
|
sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true
|
||||||
sp_cleanup.use_type_arguments=false
|
sp_cleanup.use_type_arguments=false
|
||||||
|
sp_cleanup.use_unboxing=false
|
||||||
|
@@ -406,10 +406,13 @@ public class World
|
|||||||
oldRegion.removeVisibleObject(object);
|
oldRegion.removeVisibleObject(object);
|
||||||
|
|
||||||
// Go through all surrounding WorldRegion Creatures
|
// Go through all surrounding WorldRegion Creatures
|
||||||
for (WorldRegion worldRegion : oldRegion.getSurroundingRegions())
|
final WorldRegion[] surroundingRegions = oldRegion.getSurroundingRegions();
|
||||||
|
for (int i = 0; i < surroundingRegions.length; i++)
|
||||||
{
|
{
|
||||||
for (WorldObject wo : worldRegion.getVisibleObjects().values())
|
final List<WorldObject> visibleObjects = surroundingRegions[i].getVisibleObjects();
|
||||||
|
for (int j = 0; j < visibleObjects.size(); j++)
|
||||||
{
|
{
|
||||||
|
final WorldObject wo = visibleObjects.get(j);
|
||||||
if (wo == object)
|
if (wo == object)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
@@ -466,15 +469,19 @@ public class World
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (WorldRegion worldRegion : oldRegion.getSurroundingRegions())
|
final WorldRegion[] oldSurroundingRegions = oldRegion.getSurroundingRegions();
|
||||||
|
for (int i = 0; i < oldSurroundingRegions.length; i++)
|
||||||
{
|
{
|
||||||
|
final WorldRegion worldRegion = oldSurroundingRegions[i];
|
||||||
if (newRegion.isSurroundingRegion(worldRegion))
|
if (newRegion.isSurroundingRegion(worldRegion))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (WorldObject wo : worldRegion.getVisibleObjects().values())
|
final List<WorldObject> visibleObjects = worldRegion.getVisibleObjects();
|
||||||
|
for (int j = 0; j < visibleObjects.size(); j++)
|
||||||
{
|
{
|
||||||
|
final WorldObject wo = visibleObjects.get(j);
|
||||||
if (wo == object)
|
if (wo == object)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
@@ -522,15 +529,19 @@ public class World
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (WorldRegion worldRegion : newRegion.getSurroundingRegions())
|
final WorldRegion[] newSurroundingRegions = newRegion.getSurroundingRegions();
|
||||||
|
for (int i = 0; i < newSurroundingRegions.length; i++)
|
||||||
{
|
{
|
||||||
|
final WorldRegion worldRegion = newSurroundingRegions[i];
|
||||||
if (oldRegion.isSurroundingRegion(worldRegion))
|
if (oldRegion.isSurroundingRegion(worldRegion))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (WorldObject wo : worldRegion.getVisibleObjects().values())
|
final List<WorldObject> visibleObjects = worldRegion.getVisibleObjects();
|
||||||
|
for (int j = 0; j < visibleObjects.size(); j++)
|
||||||
{
|
{
|
||||||
|
final WorldObject wo = visibleObjects.get(j);
|
||||||
if ((wo == object) || (wo.getInstanceWorld() != object.getInstanceWorld()))
|
if ((wo == object) || (wo.getInstanceWorld() != object.getInstanceWorld()))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
@@ -610,27 +621,30 @@ public class World
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final WorldRegion centerWorldRegion = getRegion(object);
|
final WorldRegion worldRegion = getRegion(object);
|
||||||
if (centerWorldRegion == null)
|
if (worldRegion == null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (WorldRegion region : centerWorldRegion.getSurroundingRegions())
|
final WorldRegion[] surroundingRegions = worldRegion.getSurroundingRegions();
|
||||||
|
for (int i = 0; i < surroundingRegions.length; i++)
|
||||||
{
|
{
|
||||||
for (WorldObject visibleObject : region.getVisibleObjects().values())
|
final List<WorldObject> visibleObjects = surroundingRegions[i].getVisibleObjects();
|
||||||
|
for (int j = 0; j < visibleObjects.size(); j++)
|
||||||
{
|
{
|
||||||
if ((visibleObject == null) || (visibleObject == object) || !clazz.isInstance(visibleObject))
|
final WorldObject wo = visibleObjects.get(j);
|
||||||
|
if ((wo == null) || (wo == object) || !clazz.isInstance(wo))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (visibleObject.getInstanceWorld() != object.getInstanceWorld())
|
if (wo.getInstanceWorld() != object.getInstanceWorld())
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
c.accept(clazz.cast(visibleObject));
|
c.accept(clazz.cast(wo));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -662,29 +676,32 @@ public class World
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final WorldRegion centerWorldRegion = getRegion(object);
|
final WorldRegion worldRegion = getRegion(object);
|
||||||
if (centerWorldRegion == null)
|
if (worldRegion == null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (WorldRegion region : centerWorldRegion.getSurroundingRegions())
|
final WorldRegion[] surroundingRegions = worldRegion.getSurroundingRegions();
|
||||||
|
for (int i = 0; i < surroundingRegions.length; i++)
|
||||||
{
|
{
|
||||||
for (WorldObject visibleObject : region.getVisibleObjects().values())
|
final List<WorldObject> visibleObjects = surroundingRegions[i].getVisibleObjects();
|
||||||
|
for (int j = 0; j < visibleObjects.size(); j++)
|
||||||
{
|
{
|
||||||
if ((visibleObject == null) || (visibleObject == object) || !clazz.isInstance(visibleObject))
|
final WorldObject wo = visibleObjects.get(j);
|
||||||
|
if ((wo == null) || (wo == object) || !clazz.isInstance(wo))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (visibleObject.getInstanceWorld() != object.getInstanceWorld())
|
if (wo.getInstanceWorld() != object.getInstanceWorld())
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (visibleObject.calculateDistance3D(object) <= range)
|
if (wo.calculateDistance3D(object) <= range)
|
||||||
{
|
{
|
||||||
c.accept(clazz.cast(visibleObject));
|
c.accept(clazz.cast(wo));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -16,8 +16,8 @@
|
|||||||
*/
|
*/
|
||||||
package org.l2jmobius.gameserver.model;
|
package org.l2jmobius.gameserver.model;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.ArrayList;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.List;
|
||||||
import java.util.concurrent.ScheduledFuture;
|
import java.util.concurrent.ScheduledFuture;
|
||||||
|
|
||||||
import org.l2jmobius.Config;
|
import org.l2jmobius.Config;
|
||||||
@@ -28,9 +28,9 @@ import org.l2jmobius.gameserver.taskmanager.RandomAnimationTaskManager;
|
|||||||
|
|
||||||
public class WorldRegion
|
public class WorldRegion
|
||||||
{
|
{
|
||||||
/** Map containing visible objects in this world region. */
|
/** List containing visible objects in this world region. */
|
||||||
private final Map<Integer, WorldObject> _visibleObjects = new ConcurrentHashMap<>();
|
private final List<WorldObject> _visibleObjects = new ArrayList<>();
|
||||||
/** Map containing nearby regions forming this world region's effective area. */
|
/** Array containing nearby regions forming this world region's effective area. */
|
||||||
private WorldRegion[] _surroundingRegions;
|
private WorldRegion[] _surroundingRegions;
|
||||||
private final int _regionX;
|
private final int _regionX;
|
||||||
private final int _regionY;
|
private final int _regionY;
|
||||||
@@ -52,8 +52,9 @@ public class WorldRegion
|
|||||||
|
|
||||||
if (!isOn)
|
if (!isOn)
|
||||||
{
|
{
|
||||||
for (WorldObject wo : _visibleObjects.values())
|
for (int i = 0; i < _visibleObjects.size(); i++)
|
||||||
{
|
{
|
||||||
|
final WorldObject wo = _visibleObjects.get(i);
|
||||||
if (wo.isAttackable())
|
if (wo.isAttackable())
|
||||||
{
|
{
|
||||||
final Attackable mob = (Attackable) wo;
|
final Attackable mob = (Attackable) wo;
|
||||||
@@ -87,15 +88,16 @@ public class WorldRegion
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for (WorldObject wo : _visibleObjects.values())
|
for (int i = 0; i < _visibleObjects.size(); i++)
|
||||||
{
|
{
|
||||||
|
final WorldObject wo = _visibleObjects.get(i);
|
||||||
if (wo.isAttackable())
|
if (wo.isAttackable())
|
||||||
{
|
{
|
||||||
// Start HP/MP/CP regeneration task.
|
// Start HP/MP/CP regeneration task.
|
||||||
((Attackable) wo).getStatus().startHpMpRegeneration();
|
((Attackable) wo).getStatus().startHpMpRegeneration();
|
||||||
RandomAnimationTaskManager.getInstance().add((Npc) wo);
|
RandomAnimationTaskManager.getInstance().add((Npc) wo);
|
||||||
}
|
}
|
||||||
else if (wo instanceof Npc)
|
else if (wo.isNpc())
|
||||||
{
|
{
|
||||||
RandomAnimationTaskManager.getInstance().add((Npc) wo);
|
RandomAnimationTaskManager.getInstance().add((Npc) wo);
|
||||||
}
|
}
|
||||||
@@ -110,13 +112,21 @@ public class WorldRegion
|
|||||||
|
|
||||||
public boolean areNeighborsEmpty()
|
public boolean areNeighborsEmpty()
|
||||||
{
|
{
|
||||||
for (WorldRegion worldRegion : _surroundingRegions)
|
for (int i = 0; i < _surroundingRegions.length; i++)
|
||||||
{
|
{
|
||||||
if (worldRegion.isActive() && worldRegion.getVisibleObjects().values().stream().anyMatch(WorldObject::isPlayable))
|
final WorldRegion worldRegion = _surroundingRegions[i];
|
||||||
|
if (worldRegion.isActive())
|
||||||
|
{
|
||||||
|
final List<WorldObject> regionObjects = worldRegion.getVisibleObjects();
|
||||||
|
for (int j = 0; j < regionObjects.size(); j++)
|
||||||
|
{
|
||||||
|
if (regionObjects.get(j).isPlayable())
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -157,9 +167,9 @@ public class WorldRegion
|
|||||||
// Then, set a timer to activate the neighbors.
|
// Then, set a timer to activate the neighbors.
|
||||||
_neighborsTask = ThreadPool.schedule(() ->
|
_neighborsTask = ThreadPool.schedule(() ->
|
||||||
{
|
{
|
||||||
for (WorldRegion worldRegion : _surroundingRegions)
|
for (int i = 0; i < _surroundingRegions.length; i++)
|
||||||
{
|
{
|
||||||
worldRegion.setActive(true);
|
_surroundingRegions[i].setActive(true);
|
||||||
}
|
}
|
||||||
}, 1000 * Config.GRID_NEIGHBOR_TURNON_TIME);
|
}, 1000 * Config.GRID_NEIGHBOR_TURNON_TIME);
|
||||||
}
|
}
|
||||||
@@ -183,8 +193,9 @@ public class WorldRegion
|
|||||||
// Suggest means: first check if a neighbor has PlayerInstances in it. If not, deactivate.
|
// Suggest means: first check if a neighbor has PlayerInstances in it. If not, deactivate.
|
||||||
_neighborsTask = ThreadPool.schedule(() ->
|
_neighborsTask = ThreadPool.schedule(() ->
|
||||||
{
|
{
|
||||||
for (WorldRegion worldRegion : _surroundingRegions)
|
for (int i = 0; i < _surroundingRegions.length; i++)
|
||||||
{
|
{
|
||||||
|
final WorldRegion worldRegion = _surroundingRegions[i];
|
||||||
if (worldRegion.areNeighborsEmpty())
|
if (worldRegion.areNeighborsEmpty())
|
||||||
{
|
{
|
||||||
worldRegion.setActive(false);
|
worldRegion.setActive(false);
|
||||||
@@ -206,7 +217,13 @@ public class WorldRegion
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
_visibleObjects.put(object.getObjectId(), object);
|
synchronized (_visibleObjects)
|
||||||
|
{
|
||||||
|
if (!_visibleObjects.contains(object))
|
||||||
|
{
|
||||||
|
_visibleObjects.add(object);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// If this is the first player to enter the region, activate self and neighbors.
|
// If this is the first player to enter the region, activate self and neighbors.
|
||||||
if (object.isPlayable() && !_active && !Config.GRIDS_ALWAYS_ON)
|
if (object.isPlayable() && !_active && !Config.GRIDS_ALWAYS_ON)
|
||||||
@@ -230,7 +247,11 @@ public class WorldRegion
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_visibleObjects.remove(object.getObjectId());
|
|
||||||
|
synchronized (_visibleObjects)
|
||||||
|
{
|
||||||
|
_visibleObjects.remove(object);
|
||||||
|
}
|
||||||
|
|
||||||
if (object.isPlayable() && areNeighborsEmpty() && !Config.GRIDS_ALWAYS_ON)
|
if (object.isPlayable() && areNeighborsEmpty() && !Config.GRIDS_ALWAYS_ON)
|
||||||
{
|
{
|
||||||
@@ -238,7 +259,7 @@ public class WorldRegion
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<Integer, WorldObject> getVisibleObjects()
|
public List<WorldObject> getVisibleObjects()
|
||||||
{
|
{
|
||||||
return _visibleObjects;
|
return _visibleObjects;
|
||||||
}
|
}
|
||||||
|
@@ -94,7 +94,7 @@ sp_cleanup.always_use_parentheses_in_expressions=true
|
|||||||
sp_cleanup.always_use_this_for_non_static_field_access=false
|
sp_cleanup.always_use_this_for_non_static_field_access=false
|
||||||
sp_cleanup.always_use_this_for_non_static_method_access=false
|
sp_cleanup.always_use_this_for_non_static_method_access=false
|
||||||
sp_cleanup.convert_functional_interfaces=true
|
sp_cleanup.convert_functional_interfaces=true
|
||||||
sp_cleanup.convert_to_enhanced_for_loop=true
|
sp_cleanup.convert_to_enhanced_for_loop=false
|
||||||
sp_cleanup.correct_indentation=false
|
sp_cleanup.correct_indentation=false
|
||||||
sp_cleanup.format_source_code=true
|
sp_cleanup.format_source_code=true
|
||||||
sp_cleanup.format_source_code_changes_only=false
|
sp_cleanup.format_source_code_changes_only=false
|
||||||
@@ -106,18 +106,23 @@ sp_cleanup.make_type_abstract_if_missing_method=false
|
|||||||
sp_cleanup.make_variable_declarations_final=true
|
sp_cleanup.make_variable_declarations_final=true
|
||||||
sp_cleanup.never_use_blocks=false
|
sp_cleanup.never_use_blocks=false
|
||||||
sp_cleanup.never_use_parentheses_in_expressions=false
|
sp_cleanup.never_use_parentheses_in_expressions=false
|
||||||
|
sp_cleanup.number_suffix=false
|
||||||
sp_cleanup.on_save_use_additional_actions=true
|
sp_cleanup.on_save_use_additional_actions=true
|
||||||
sp_cleanup.organize_imports=true
|
sp_cleanup.organize_imports=true
|
||||||
|
sp_cleanup.push_down_negation=false
|
||||||
sp_cleanup.qualify_static_field_accesses_with_declaring_class=false
|
sp_cleanup.qualify_static_field_accesses_with_declaring_class=false
|
||||||
sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true
|
sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true
|
||||||
sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true
|
sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true
|
||||||
sp_cleanup.qualify_static_member_accesses_with_declaring_class=true
|
sp_cleanup.qualify_static_member_accesses_with_declaring_class=true
|
||||||
sp_cleanup.qualify_static_method_accesses_with_declaring_class=false
|
sp_cleanup.qualify_static_method_accesses_with_declaring_class=false
|
||||||
sp_cleanup.remove_private_constructors=true
|
sp_cleanup.remove_private_constructors=true
|
||||||
|
sp_cleanup.remove_redundant_modifiers=false
|
||||||
|
sp_cleanup.remove_redundant_semicolons=false
|
||||||
sp_cleanup.remove_redundant_type_arguments=false
|
sp_cleanup.remove_redundant_type_arguments=false
|
||||||
sp_cleanup.remove_trailing_whitespaces=false
|
sp_cleanup.remove_trailing_whitespaces=false
|
||||||
sp_cleanup.remove_trailing_whitespaces_all=true
|
sp_cleanup.remove_trailing_whitespaces_all=true
|
||||||
sp_cleanup.remove_trailing_whitespaces_ignore_empty=true
|
sp_cleanup.remove_trailing_whitespaces_ignore_empty=true
|
||||||
|
sp_cleanup.remove_unnecessary_array_creation=false
|
||||||
sp_cleanup.remove_unnecessary_casts=true
|
sp_cleanup.remove_unnecessary_casts=true
|
||||||
sp_cleanup.remove_unnecessary_nls_tags=true
|
sp_cleanup.remove_unnecessary_nls_tags=true
|
||||||
sp_cleanup.remove_unused_imports=true
|
sp_cleanup.remove_unused_imports=true
|
||||||
@@ -126,11 +131,14 @@ sp_cleanup.remove_unused_private_fields=true
|
|||||||
sp_cleanup.remove_unused_private_members=false
|
sp_cleanup.remove_unused_private_members=false
|
||||||
sp_cleanup.remove_unused_private_methods=true
|
sp_cleanup.remove_unused_private_methods=true
|
||||||
sp_cleanup.remove_unused_private_types=true
|
sp_cleanup.remove_unused_private_types=true
|
||||||
|
sp_cleanup.simplify_lambda_expression_and_method_ref=false
|
||||||
sp_cleanup.sort_members=false
|
sp_cleanup.sort_members=false
|
||||||
sp_cleanup.sort_members_all=false
|
sp_cleanup.sort_members_all=false
|
||||||
sp_cleanup.use_anonymous_class_creation=false
|
sp_cleanup.use_anonymous_class_creation=false
|
||||||
|
sp_cleanup.use_autoboxing=false
|
||||||
sp_cleanup.use_blocks=true
|
sp_cleanup.use_blocks=true
|
||||||
sp_cleanup.use_blocks_only_for_return_and_throw=false
|
sp_cleanup.use_blocks_only_for_return_and_throw=false
|
||||||
|
sp_cleanup.use_directly_map_method=false
|
||||||
sp_cleanup.use_lambda=true
|
sp_cleanup.use_lambda=true
|
||||||
sp_cleanup.use_parentheses_in_expressions=true
|
sp_cleanup.use_parentheses_in_expressions=true
|
||||||
sp_cleanup.use_this_for_non_static_field_access=false
|
sp_cleanup.use_this_for_non_static_field_access=false
|
||||||
@@ -138,3 +146,4 @@ sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true
|
|||||||
sp_cleanup.use_this_for_non_static_method_access=false
|
sp_cleanup.use_this_for_non_static_method_access=false
|
||||||
sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true
|
sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true
|
||||||
sp_cleanup.use_type_arguments=false
|
sp_cleanup.use_type_arguments=false
|
||||||
|
sp_cleanup.use_unboxing=false
|
||||||
|
@@ -406,10 +406,13 @@ public class World
|
|||||||
oldRegion.removeVisibleObject(object);
|
oldRegion.removeVisibleObject(object);
|
||||||
|
|
||||||
// Go through all surrounding WorldRegion Creatures
|
// Go through all surrounding WorldRegion Creatures
|
||||||
for (WorldRegion worldRegion : oldRegion.getSurroundingRegions())
|
final WorldRegion[] surroundingRegions = oldRegion.getSurroundingRegions();
|
||||||
|
for (int i = 0; i < surroundingRegions.length; i++)
|
||||||
{
|
{
|
||||||
for (WorldObject wo : worldRegion.getVisibleObjects().values())
|
final List<WorldObject> visibleObjects = surroundingRegions[i].getVisibleObjects();
|
||||||
|
for (int j = 0; j < visibleObjects.size(); j++)
|
||||||
{
|
{
|
||||||
|
final WorldObject wo = visibleObjects.get(j);
|
||||||
if (wo == object)
|
if (wo == object)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
@@ -466,15 +469,19 @@ public class World
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (WorldRegion worldRegion : oldRegion.getSurroundingRegions())
|
final WorldRegion[] oldSurroundingRegions = oldRegion.getSurroundingRegions();
|
||||||
|
for (int i = 0; i < oldSurroundingRegions.length; i++)
|
||||||
{
|
{
|
||||||
|
final WorldRegion worldRegion = oldSurroundingRegions[i];
|
||||||
if (newRegion.isSurroundingRegion(worldRegion))
|
if (newRegion.isSurroundingRegion(worldRegion))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (WorldObject wo : worldRegion.getVisibleObjects().values())
|
final List<WorldObject> visibleObjects = worldRegion.getVisibleObjects();
|
||||||
|
for (int j = 0; j < visibleObjects.size(); j++)
|
||||||
{
|
{
|
||||||
|
final WorldObject wo = visibleObjects.get(j);
|
||||||
if (wo == object)
|
if (wo == object)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
@@ -522,15 +529,19 @@ public class World
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (WorldRegion worldRegion : newRegion.getSurroundingRegions())
|
final WorldRegion[] newSurroundingRegions = newRegion.getSurroundingRegions();
|
||||||
|
for (int i = 0; i < newSurroundingRegions.length; i++)
|
||||||
{
|
{
|
||||||
|
final WorldRegion worldRegion = newSurroundingRegions[i];
|
||||||
if (oldRegion.isSurroundingRegion(worldRegion))
|
if (oldRegion.isSurroundingRegion(worldRegion))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (WorldObject wo : worldRegion.getVisibleObjects().values())
|
final List<WorldObject> visibleObjects = worldRegion.getVisibleObjects();
|
||||||
|
for (int j = 0; j < visibleObjects.size(); j++)
|
||||||
{
|
{
|
||||||
|
final WorldObject wo = visibleObjects.get(j);
|
||||||
if ((wo == object) || (wo.getInstanceWorld() != object.getInstanceWorld()))
|
if ((wo == object) || (wo.getInstanceWorld() != object.getInstanceWorld()))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
@@ -610,27 +621,30 @@ public class World
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final WorldRegion centerWorldRegion = getRegion(object);
|
final WorldRegion worldRegion = getRegion(object);
|
||||||
if (centerWorldRegion == null)
|
if (worldRegion == null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (WorldRegion region : centerWorldRegion.getSurroundingRegions())
|
final WorldRegion[] surroundingRegions = worldRegion.getSurroundingRegions();
|
||||||
|
for (int i = 0; i < surroundingRegions.length; i++)
|
||||||
{
|
{
|
||||||
for (WorldObject visibleObject : region.getVisibleObjects().values())
|
final List<WorldObject> visibleObjects = surroundingRegions[i].getVisibleObjects();
|
||||||
|
for (int j = 0; j < visibleObjects.size(); j++)
|
||||||
{
|
{
|
||||||
if ((visibleObject == null) || (visibleObject == object) || !clazz.isInstance(visibleObject))
|
final WorldObject wo = visibleObjects.get(j);
|
||||||
|
if ((wo == null) || (wo == object) || !clazz.isInstance(wo))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (visibleObject.getInstanceWorld() != object.getInstanceWorld())
|
if (wo.getInstanceWorld() != object.getInstanceWorld())
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
c.accept(clazz.cast(visibleObject));
|
c.accept(clazz.cast(wo));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -662,29 +676,32 @@ public class World
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final WorldRegion centerWorldRegion = getRegion(object);
|
final WorldRegion worldRegion = getRegion(object);
|
||||||
if (centerWorldRegion == null)
|
if (worldRegion == null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (WorldRegion region : centerWorldRegion.getSurroundingRegions())
|
final WorldRegion[] surroundingRegions = worldRegion.getSurroundingRegions();
|
||||||
|
for (int i = 0; i < surroundingRegions.length; i++)
|
||||||
{
|
{
|
||||||
for (WorldObject visibleObject : region.getVisibleObjects().values())
|
final List<WorldObject> visibleObjects = surroundingRegions[i].getVisibleObjects();
|
||||||
|
for (int j = 0; j < visibleObjects.size(); j++)
|
||||||
{
|
{
|
||||||
if ((visibleObject == null) || (visibleObject == object) || !clazz.isInstance(visibleObject))
|
final WorldObject wo = visibleObjects.get(j);
|
||||||
|
if ((wo == null) || (wo == object) || !clazz.isInstance(wo))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (visibleObject.getInstanceWorld() != object.getInstanceWorld())
|
if (wo.getInstanceWorld() != object.getInstanceWorld())
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (visibleObject.calculateDistance3D(object) <= range)
|
if (wo.calculateDistance3D(object) <= range)
|
||||||
{
|
{
|
||||||
c.accept(clazz.cast(visibleObject));
|
c.accept(clazz.cast(wo));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -16,8 +16,8 @@
|
|||||||
*/
|
*/
|
||||||
package org.l2jmobius.gameserver.model;
|
package org.l2jmobius.gameserver.model;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.ArrayList;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.List;
|
||||||
import java.util.concurrent.ScheduledFuture;
|
import java.util.concurrent.ScheduledFuture;
|
||||||
|
|
||||||
import org.l2jmobius.Config;
|
import org.l2jmobius.Config;
|
||||||
@@ -28,9 +28,9 @@ import org.l2jmobius.gameserver.taskmanager.RandomAnimationTaskManager;
|
|||||||
|
|
||||||
public class WorldRegion
|
public class WorldRegion
|
||||||
{
|
{
|
||||||
/** Map containing visible objects in this world region. */
|
/** List containing visible objects in this world region. */
|
||||||
private final Map<Integer, WorldObject> _visibleObjects = new ConcurrentHashMap<>();
|
private final List<WorldObject> _visibleObjects = new ArrayList<>();
|
||||||
/** Map containing nearby regions forming this world region's effective area. */
|
/** Array containing nearby regions forming this world region's effective area. */
|
||||||
private WorldRegion[] _surroundingRegions;
|
private WorldRegion[] _surroundingRegions;
|
||||||
private final int _regionX;
|
private final int _regionX;
|
||||||
private final int _regionY;
|
private final int _regionY;
|
||||||
@@ -52,8 +52,9 @@ public class WorldRegion
|
|||||||
|
|
||||||
if (!isOn)
|
if (!isOn)
|
||||||
{
|
{
|
||||||
for (WorldObject wo : _visibleObjects.values())
|
for (int i = 0; i < _visibleObjects.size(); i++)
|
||||||
{
|
{
|
||||||
|
final WorldObject wo = _visibleObjects.get(i);
|
||||||
if (wo.isAttackable())
|
if (wo.isAttackable())
|
||||||
{
|
{
|
||||||
final Attackable mob = (Attackable) wo;
|
final Attackable mob = (Attackable) wo;
|
||||||
@@ -87,15 +88,16 @@ public class WorldRegion
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for (WorldObject wo : _visibleObjects.values())
|
for (int i = 0; i < _visibleObjects.size(); i++)
|
||||||
{
|
{
|
||||||
|
final WorldObject wo = _visibleObjects.get(i);
|
||||||
if (wo.isAttackable())
|
if (wo.isAttackable())
|
||||||
{
|
{
|
||||||
// Start HP/MP/CP regeneration task.
|
// Start HP/MP/CP regeneration task.
|
||||||
((Attackable) wo).getStatus().startHpMpRegeneration();
|
((Attackable) wo).getStatus().startHpMpRegeneration();
|
||||||
RandomAnimationTaskManager.getInstance().add((Npc) wo);
|
RandomAnimationTaskManager.getInstance().add((Npc) wo);
|
||||||
}
|
}
|
||||||
else if (wo instanceof Npc)
|
else if (wo.isNpc())
|
||||||
{
|
{
|
||||||
RandomAnimationTaskManager.getInstance().add((Npc) wo);
|
RandomAnimationTaskManager.getInstance().add((Npc) wo);
|
||||||
}
|
}
|
||||||
@@ -110,13 +112,21 @@ public class WorldRegion
|
|||||||
|
|
||||||
public boolean areNeighborsEmpty()
|
public boolean areNeighborsEmpty()
|
||||||
{
|
{
|
||||||
for (WorldRegion worldRegion : _surroundingRegions)
|
for (int i = 0; i < _surroundingRegions.length; i++)
|
||||||
{
|
{
|
||||||
if (worldRegion.isActive() && worldRegion.getVisibleObjects().values().stream().anyMatch(WorldObject::isPlayable))
|
final WorldRegion worldRegion = _surroundingRegions[i];
|
||||||
|
if (worldRegion.isActive())
|
||||||
|
{
|
||||||
|
final List<WorldObject> regionObjects = worldRegion.getVisibleObjects();
|
||||||
|
for (int j = 0; j < regionObjects.size(); j++)
|
||||||
|
{
|
||||||
|
if (regionObjects.get(j).isPlayable())
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -157,9 +167,9 @@ public class WorldRegion
|
|||||||
// Then, set a timer to activate the neighbors.
|
// Then, set a timer to activate the neighbors.
|
||||||
_neighborsTask = ThreadPool.schedule(() ->
|
_neighborsTask = ThreadPool.schedule(() ->
|
||||||
{
|
{
|
||||||
for (WorldRegion worldRegion : _surroundingRegions)
|
for (int i = 0; i < _surroundingRegions.length; i++)
|
||||||
{
|
{
|
||||||
worldRegion.setActive(true);
|
_surroundingRegions[i].setActive(true);
|
||||||
}
|
}
|
||||||
}, 1000 * Config.GRID_NEIGHBOR_TURNON_TIME);
|
}, 1000 * Config.GRID_NEIGHBOR_TURNON_TIME);
|
||||||
}
|
}
|
||||||
@@ -183,8 +193,9 @@ public class WorldRegion
|
|||||||
// Suggest means: first check if a neighbor has PlayerInstances in it. If not, deactivate.
|
// Suggest means: first check if a neighbor has PlayerInstances in it. If not, deactivate.
|
||||||
_neighborsTask = ThreadPool.schedule(() ->
|
_neighborsTask = ThreadPool.schedule(() ->
|
||||||
{
|
{
|
||||||
for (WorldRegion worldRegion : _surroundingRegions)
|
for (int i = 0; i < _surroundingRegions.length; i++)
|
||||||
{
|
{
|
||||||
|
final WorldRegion worldRegion = _surroundingRegions[i];
|
||||||
if (worldRegion.areNeighborsEmpty())
|
if (worldRegion.areNeighborsEmpty())
|
||||||
{
|
{
|
||||||
worldRegion.setActive(false);
|
worldRegion.setActive(false);
|
||||||
@@ -206,7 +217,13 @@ public class WorldRegion
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
_visibleObjects.put(object.getObjectId(), object);
|
synchronized (_visibleObjects)
|
||||||
|
{
|
||||||
|
if (!_visibleObjects.contains(object))
|
||||||
|
{
|
||||||
|
_visibleObjects.add(object);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// If this is the first player to enter the region, activate self and neighbors.
|
// If this is the first player to enter the region, activate self and neighbors.
|
||||||
if (object.isPlayable() && !_active && !Config.GRIDS_ALWAYS_ON)
|
if (object.isPlayable() && !_active && !Config.GRIDS_ALWAYS_ON)
|
||||||
@@ -230,7 +247,11 @@ public class WorldRegion
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_visibleObjects.remove(object.getObjectId());
|
|
||||||
|
synchronized (_visibleObjects)
|
||||||
|
{
|
||||||
|
_visibleObjects.remove(object);
|
||||||
|
}
|
||||||
|
|
||||||
if (object.isPlayable() && areNeighborsEmpty() && !Config.GRIDS_ALWAYS_ON)
|
if (object.isPlayable() && areNeighborsEmpty() && !Config.GRIDS_ALWAYS_ON)
|
||||||
{
|
{
|
||||||
@@ -238,7 +259,7 @@ public class WorldRegion
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<Integer, WorldObject> getVisibleObjects()
|
public List<WorldObject> getVisibleObjects()
|
||||||
{
|
{
|
||||||
return _visibleObjects;
|
return _visibleObjects;
|
||||||
}
|
}
|
||||||
|
@@ -94,7 +94,7 @@ sp_cleanup.always_use_parentheses_in_expressions=true
|
|||||||
sp_cleanup.always_use_this_for_non_static_field_access=false
|
sp_cleanup.always_use_this_for_non_static_field_access=false
|
||||||
sp_cleanup.always_use_this_for_non_static_method_access=false
|
sp_cleanup.always_use_this_for_non_static_method_access=false
|
||||||
sp_cleanup.convert_functional_interfaces=true
|
sp_cleanup.convert_functional_interfaces=true
|
||||||
sp_cleanup.convert_to_enhanced_for_loop=true
|
sp_cleanup.convert_to_enhanced_for_loop=false
|
||||||
sp_cleanup.correct_indentation=false
|
sp_cleanup.correct_indentation=false
|
||||||
sp_cleanup.format_source_code=true
|
sp_cleanup.format_source_code=true
|
||||||
sp_cleanup.format_source_code_changes_only=false
|
sp_cleanup.format_source_code_changes_only=false
|
||||||
@@ -106,18 +106,23 @@ sp_cleanup.make_type_abstract_if_missing_method=false
|
|||||||
sp_cleanup.make_variable_declarations_final=true
|
sp_cleanup.make_variable_declarations_final=true
|
||||||
sp_cleanup.never_use_blocks=false
|
sp_cleanup.never_use_blocks=false
|
||||||
sp_cleanup.never_use_parentheses_in_expressions=false
|
sp_cleanup.never_use_parentheses_in_expressions=false
|
||||||
|
sp_cleanup.number_suffix=false
|
||||||
sp_cleanup.on_save_use_additional_actions=true
|
sp_cleanup.on_save_use_additional_actions=true
|
||||||
sp_cleanup.organize_imports=true
|
sp_cleanup.organize_imports=true
|
||||||
|
sp_cleanup.push_down_negation=false
|
||||||
sp_cleanup.qualify_static_field_accesses_with_declaring_class=false
|
sp_cleanup.qualify_static_field_accesses_with_declaring_class=false
|
||||||
sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true
|
sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true
|
||||||
sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true
|
sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true
|
||||||
sp_cleanup.qualify_static_member_accesses_with_declaring_class=true
|
sp_cleanup.qualify_static_member_accesses_with_declaring_class=true
|
||||||
sp_cleanup.qualify_static_method_accesses_with_declaring_class=false
|
sp_cleanup.qualify_static_method_accesses_with_declaring_class=false
|
||||||
sp_cleanup.remove_private_constructors=true
|
sp_cleanup.remove_private_constructors=true
|
||||||
|
sp_cleanup.remove_redundant_modifiers=false
|
||||||
|
sp_cleanup.remove_redundant_semicolons=false
|
||||||
sp_cleanup.remove_redundant_type_arguments=false
|
sp_cleanup.remove_redundant_type_arguments=false
|
||||||
sp_cleanup.remove_trailing_whitespaces=false
|
sp_cleanup.remove_trailing_whitespaces=false
|
||||||
sp_cleanup.remove_trailing_whitespaces_all=true
|
sp_cleanup.remove_trailing_whitespaces_all=true
|
||||||
sp_cleanup.remove_trailing_whitespaces_ignore_empty=true
|
sp_cleanup.remove_trailing_whitespaces_ignore_empty=true
|
||||||
|
sp_cleanup.remove_unnecessary_array_creation=false
|
||||||
sp_cleanup.remove_unnecessary_casts=true
|
sp_cleanup.remove_unnecessary_casts=true
|
||||||
sp_cleanup.remove_unnecessary_nls_tags=true
|
sp_cleanup.remove_unnecessary_nls_tags=true
|
||||||
sp_cleanup.remove_unused_imports=true
|
sp_cleanup.remove_unused_imports=true
|
||||||
@@ -126,11 +131,14 @@ sp_cleanup.remove_unused_private_fields=true
|
|||||||
sp_cleanup.remove_unused_private_members=false
|
sp_cleanup.remove_unused_private_members=false
|
||||||
sp_cleanup.remove_unused_private_methods=true
|
sp_cleanup.remove_unused_private_methods=true
|
||||||
sp_cleanup.remove_unused_private_types=true
|
sp_cleanup.remove_unused_private_types=true
|
||||||
|
sp_cleanup.simplify_lambda_expression_and_method_ref=false
|
||||||
sp_cleanup.sort_members=false
|
sp_cleanup.sort_members=false
|
||||||
sp_cleanup.sort_members_all=false
|
sp_cleanup.sort_members_all=false
|
||||||
sp_cleanup.use_anonymous_class_creation=false
|
sp_cleanup.use_anonymous_class_creation=false
|
||||||
|
sp_cleanup.use_autoboxing=false
|
||||||
sp_cleanup.use_blocks=true
|
sp_cleanup.use_blocks=true
|
||||||
sp_cleanup.use_blocks_only_for_return_and_throw=false
|
sp_cleanup.use_blocks_only_for_return_and_throw=false
|
||||||
|
sp_cleanup.use_directly_map_method=false
|
||||||
sp_cleanup.use_lambda=true
|
sp_cleanup.use_lambda=true
|
||||||
sp_cleanup.use_parentheses_in_expressions=true
|
sp_cleanup.use_parentheses_in_expressions=true
|
||||||
sp_cleanup.use_this_for_non_static_field_access=false
|
sp_cleanup.use_this_for_non_static_field_access=false
|
||||||
@@ -138,3 +146,4 @@ sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true
|
|||||||
sp_cleanup.use_this_for_non_static_method_access=false
|
sp_cleanup.use_this_for_non_static_method_access=false
|
||||||
sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true
|
sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true
|
||||||
sp_cleanup.use_type_arguments=false
|
sp_cleanup.use_type_arguments=false
|
||||||
|
sp_cleanup.use_unboxing=false
|
||||||
|
@@ -406,10 +406,13 @@ public class World
|
|||||||
oldRegion.removeVisibleObject(object);
|
oldRegion.removeVisibleObject(object);
|
||||||
|
|
||||||
// Go through all surrounding WorldRegion Creatures
|
// Go through all surrounding WorldRegion Creatures
|
||||||
for (WorldRegion worldRegion : oldRegion.getSurroundingRegions())
|
final WorldRegion[] surroundingRegions = oldRegion.getSurroundingRegions();
|
||||||
|
for (int i = 0; i < surroundingRegions.length; i++)
|
||||||
{
|
{
|
||||||
for (WorldObject wo : worldRegion.getVisibleObjects().values())
|
final List<WorldObject> visibleObjects = surroundingRegions[i].getVisibleObjects();
|
||||||
|
for (int j = 0; j < visibleObjects.size(); j++)
|
||||||
{
|
{
|
||||||
|
final WorldObject wo = visibleObjects.get(j);
|
||||||
if (wo == object)
|
if (wo == object)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
@@ -466,15 +469,19 @@ public class World
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (WorldRegion worldRegion : oldRegion.getSurroundingRegions())
|
final WorldRegion[] oldSurroundingRegions = oldRegion.getSurroundingRegions();
|
||||||
|
for (int i = 0; i < oldSurroundingRegions.length; i++)
|
||||||
{
|
{
|
||||||
|
final WorldRegion worldRegion = oldSurroundingRegions[i];
|
||||||
if (newRegion.isSurroundingRegion(worldRegion))
|
if (newRegion.isSurroundingRegion(worldRegion))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (WorldObject wo : worldRegion.getVisibleObjects().values())
|
final List<WorldObject> visibleObjects = worldRegion.getVisibleObjects();
|
||||||
|
for (int j = 0; j < visibleObjects.size(); j++)
|
||||||
{
|
{
|
||||||
|
final WorldObject wo = visibleObjects.get(j);
|
||||||
if (wo == object)
|
if (wo == object)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
@@ -522,15 +529,19 @@ public class World
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (WorldRegion worldRegion : newRegion.getSurroundingRegions())
|
final WorldRegion[] newSurroundingRegions = newRegion.getSurroundingRegions();
|
||||||
|
for (int i = 0; i < newSurroundingRegions.length; i++)
|
||||||
{
|
{
|
||||||
|
final WorldRegion worldRegion = newSurroundingRegions[i];
|
||||||
if (oldRegion.isSurroundingRegion(worldRegion))
|
if (oldRegion.isSurroundingRegion(worldRegion))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (WorldObject wo : worldRegion.getVisibleObjects().values())
|
final List<WorldObject> visibleObjects = worldRegion.getVisibleObjects();
|
||||||
|
for (int j = 0; j < visibleObjects.size(); j++)
|
||||||
{
|
{
|
||||||
|
final WorldObject wo = visibleObjects.get(j);
|
||||||
if ((wo == object) || (wo.getInstanceWorld() != object.getInstanceWorld()))
|
if ((wo == object) || (wo.getInstanceWorld() != object.getInstanceWorld()))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
@@ -610,27 +621,30 @@ public class World
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final WorldRegion centerWorldRegion = getRegion(object);
|
final WorldRegion worldRegion = getRegion(object);
|
||||||
if (centerWorldRegion == null)
|
if (worldRegion == null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (WorldRegion region : centerWorldRegion.getSurroundingRegions())
|
final WorldRegion[] surroundingRegions = worldRegion.getSurroundingRegions();
|
||||||
|
for (int i = 0; i < surroundingRegions.length; i++)
|
||||||
{
|
{
|
||||||
for (WorldObject visibleObject : region.getVisibleObjects().values())
|
final List<WorldObject> visibleObjects = surroundingRegions[i].getVisibleObjects();
|
||||||
|
for (int j = 0; j < visibleObjects.size(); j++)
|
||||||
{
|
{
|
||||||
if ((visibleObject == null) || (visibleObject == object) || !clazz.isInstance(visibleObject))
|
final WorldObject wo = visibleObjects.get(j);
|
||||||
|
if ((wo == null) || (wo == object) || !clazz.isInstance(wo))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (visibleObject.getInstanceWorld() != object.getInstanceWorld())
|
if (wo.getInstanceWorld() != object.getInstanceWorld())
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
c.accept(clazz.cast(visibleObject));
|
c.accept(clazz.cast(wo));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -662,29 +676,32 @@ public class World
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final WorldRegion centerWorldRegion = getRegion(object);
|
final WorldRegion worldRegion = getRegion(object);
|
||||||
if (centerWorldRegion == null)
|
if (worldRegion == null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (WorldRegion region : centerWorldRegion.getSurroundingRegions())
|
final WorldRegion[] surroundingRegions = worldRegion.getSurroundingRegions();
|
||||||
|
for (int i = 0; i < surroundingRegions.length; i++)
|
||||||
{
|
{
|
||||||
for (WorldObject visibleObject : region.getVisibleObjects().values())
|
final List<WorldObject> visibleObjects = surroundingRegions[i].getVisibleObjects();
|
||||||
|
for (int j = 0; j < visibleObjects.size(); j++)
|
||||||
{
|
{
|
||||||
if ((visibleObject == null) || (visibleObject == object) || !clazz.isInstance(visibleObject))
|
final WorldObject wo = visibleObjects.get(j);
|
||||||
|
if ((wo == null) || (wo == object) || !clazz.isInstance(wo))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (visibleObject.getInstanceWorld() != object.getInstanceWorld())
|
if (wo.getInstanceWorld() != object.getInstanceWorld())
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (visibleObject.calculateDistance3D(object) <= range)
|
if (wo.calculateDistance3D(object) <= range)
|
||||||
{
|
{
|
||||||
c.accept(clazz.cast(visibleObject));
|
c.accept(clazz.cast(wo));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -16,8 +16,8 @@
|
|||||||
*/
|
*/
|
||||||
package org.l2jmobius.gameserver.model;
|
package org.l2jmobius.gameserver.model;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.ArrayList;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.List;
|
||||||
import java.util.concurrent.ScheduledFuture;
|
import java.util.concurrent.ScheduledFuture;
|
||||||
|
|
||||||
import org.l2jmobius.Config;
|
import org.l2jmobius.Config;
|
||||||
@@ -28,9 +28,9 @@ import org.l2jmobius.gameserver.taskmanager.RandomAnimationTaskManager;
|
|||||||
|
|
||||||
public class WorldRegion
|
public class WorldRegion
|
||||||
{
|
{
|
||||||
/** Map containing visible objects in this world region. */
|
/** List containing visible objects in this world region. */
|
||||||
private final Map<Integer, WorldObject> _visibleObjects = new ConcurrentHashMap<>();
|
private final List<WorldObject> _visibleObjects = new ArrayList<>();
|
||||||
/** Map containing nearby regions forming this world region's effective area. */
|
/** Array containing nearby regions forming this world region's effective area. */
|
||||||
private WorldRegion[] _surroundingRegions;
|
private WorldRegion[] _surroundingRegions;
|
||||||
private final int _regionX;
|
private final int _regionX;
|
||||||
private final int _regionY;
|
private final int _regionY;
|
||||||
@@ -52,8 +52,9 @@ public class WorldRegion
|
|||||||
|
|
||||||
if (!isOn)
|
if (!isOn)
|
||||||
{
|
{
|
||||||
for (WorldObject wo : _visibleObjects.values())
|
for (int i = 0; i < _visibleObjects.size(); i++)
|
||||||
{
|
{
|
||||||
|
final WorldObject wo = _visibleObjects.get(i);
|
||||||
if (wo.isAttackable())
|
if (wo.isAttackable())
|
||||||
{
|
{
|
||||||
final Attackable mob = (Attackable) wo;
|
final Attackable mob = (Attackable) wo;
|
||||||
@@ -87,15 +88,16 @@ public class WorldRegion
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for (WorldObject wo : _visibleObjects.values())
|
for (int i = 0; i < _visibleObjects.size(); i++)
|
||||||
{
|
{
|
||||||
|
final WorldObject wo = _visibleObjects.get(i);
|
||||||
if (wo.isAttackable())
|
if (wo.isAttackable())
|
||||||
{
|
{
|
||||||
// Start HP/MP/CP regeneration task.
|
// Start HP/MP/CP regeneration task.
|
||||||
((Attackable) wo).getStatus().startHpMpRegeneration();
|
((Attackable) wo).getStatus().startHpMpRegeneration();
|
||||||
RandomAnimationTaskManager.getInstance().add((Npc) wo);
|
RandomAnimationTaskManager.getInstance().add((Npc) wo);
|
||||||
}
|
}
|
||||||
else if (wo instanceof Npc)
|
else if (wo.isNpc())
|
||||||
{
|
{
|
||||||
RandomAnimationTaskManager.getInstance().add((Npc) wo);
|
RandomAnimationTaskManager.getInstance().add((Npc) wo);
|
||||||
}
|
}
|
||||||
@@ -110,13 +112,21 @@ public class WorldRegion
|
|||||||
|
|
||||||
public boolean areNeighborsEmpty()
|
public boolean areNeighborsEmpty()
|
||||||
{
|
{
|
||||||
for (WorldRegion worldRegion : _surroundingRegions)
|
for (int i = 0; i < _surroundingRegions.length; i++)
|
||||||
{
|
{
|
||||||
if (worldRegion.isActive() && worldRegion.getVisibleObjects().values().stream().anyMatch(WorldObject::isPlayable))
|
final WorldRegion worldRegion = _surroundingRegions[i];
|
||||||
|
if (worldRegion.isActive())
|
||||||
|
{
|
||||||
|
final List<WorldObject> regionObjects = worldRegion.getVisibleObjects();
|
||||||
|
for (int j = 0; j < regionObjects.size(); j++)
|
||||||
|
{
|
||||||
|
if (regionObjects.get(j).isPlayable())
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -157,9 +167,9 @@ public class WorldRegion
|
|||||||
// Then, set a timer to activate the neighbors.
|
// Then, set a timer to activate the neighbors.
|
||||||
_neighborsTask = ThreadPool.schedule(() ->
|
_neighborsTask = ThreadPool.schedule(() ->
|
||||||
{
|
{
|
||||||
for (WorldRegion worldRegion : _surroundingRegions)
|
for (int i = 0; i < _surroundingRegions.length; i++)
|
||||||
{
|
{
|
||||||
worldRegion.setActive(true);
|
_surroundingRegions[i].setActive(true);
|
||||||
}
|
}
|
||||||
}, 1000 * Config.GRID_NEIGHBOR_TURNON_TIME);
|
}, 1000 * Config.GRID_NEIGHBOR_TURNON_TIME);
|
||||||
}
|
}
|
||||||
@@ -183,8 +193,9 @@ public class WorldRegion
|
|||||||
// Suggest means: first check if a neighbor has PlayerInstances in it. If not, deactivate.
|
// Suggest means: first check if a neighbor has PlayerInstances in it. If not, deactivate.
|
||||||
_neighborsTask = ThreadPool.schedule(() ->
|
_neighborsTask = ThreadPool.schedule(() ->
|
||||||
{
|
{
|
||||||
for (WorldRegion worldRegion : _surroundingRegions)
|
for (int i = 0; i < _surroundingRegions.length; i++)
|
||||||
{
|
{
|
||||||
|
final WorldRegion worldRegion = _surroundingRegions[i];
|
||||||
if (worldRegion.areNeighborsEmpty())
|
if (worldRegion.areNeighborsEmpty())
|
||||||
{
|
{
|
||||||
worldRegion.setActive(false);
|
worldRegion.setActive(false);
|
||||||
@@ -206,7 +217,13 @@ public class WorldRegion
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
_visibleObjects.put(object.getObjectId(), object);
|
synchronized (_visibleObjects)
|
||||||
|
{
|
||||||
|
if (!_visibleObjects.contains(object))
|
||||||
|
{
|
||||||
|
_visibleObjects.add(object);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// If this is the first player to enter the region, activate self and neighbors.
|
// If this is the first player to enter the region, activate self and neighbors.
|
||||||
if (object.isPlayable() && !_active && !Config.GRIDS_ALWAYS_ON)
|
if (object.isPlayable() && !_active && !Config.GRIDS_ALWAYS_ON)
|
||||||
@@ -230,7 +247,11 @@ public class WorldRegion
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_visibleObjects.remove(object.getObjectId());
|
|
||||||
|
synchronized (_visibleObjects)
|
||||||
|
{
|
||||||
|
_visibleObjects.remove(object);
|
||||||
|
}
|
||||||
|
|
||||||
if (object.isPlayable() && areNeighborsEmpty() && !Config.GRIDS_ALWAYS_ON)
|
if (object.isPlayable() && areNeighborsEmpty() && !Config.GRIDS_ALWAYS_ON)
|
||||||
{
|
{
|
||||||
@@ -238,7 +259,7 @@ public class WorldRegion
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<Integer, WorldObject> getVisibleObjects()
|
public List<WorldObject> getVisibleObjects()
|
||||||
{
|
{
|
||||||
return _visibleObjects;
|
return _visibleObjects;
|
||||||
}
|
}
|
||||||
|
@@ -94,7 +94,7 @@ sp_cleanup.always_use_parentheses_in_expressions=true
|
|||||||
sp_cleanup.always_use_this_for_non_static_field_access=false
|
sp_cleanup.always_use_this_for_non_static_field_access=false
|
||||||
sp_cleanup.always_use_this_for_non_static_method_access=false
|
sp_cleanup.always_use_this_for_non_static_method_access=false
|
||||||
sp_cleanup.convert_functional_interfaces=true
|
sp_cleanup.convert_functional_interfaces=true
|
||||||
sp_cleanup.convert_to_enhanced_for_loop=true
|
sp_cleanup.convert_to_enhanced_for_loop=false
|
||||||
sp_cleanup.correct_indentation=false
|
sp_cleanup.correct_indentation=false
|
||||||
sp_cleanup.format_source_code=true
|
sp_cleanup.format_source_code=true
|
||||||
sp_cleanup.format_source_code_changes_only=false
|
sp_cleanup.format_source_code_changes_only=false
|
||||||
@@ -106,18 +106,23 @@ sp_cleanup.make_type_abstract_if_missing_method=false
|
|||||||
sp_cleanup.make_variable_declarations_final=true
|
sp_cleanup.make_variable_declarations_final=true
|
||||||
sp_cleanup.never_use_blocks=false
|
sp_cleanup.never_use_blocks=false
|
||||||
sp_cleanup.never_use_parentheses_in_expressions=false
|
sp_cleanup.never_use_parentheses_in_expressions=false
|
||||||
|
sp_cleanup.number_suffix=false
|
||||||
sp_cleanup.on_save_use_additional_actions=true
|
sp_cleanup.on_save_use_additional_actions=true
|
||||||
sp_cleanup.organize_imports=true
|
sp_cleanup.organize_imports=true
|
||||||
|
sp_cleanup.push_down_negation=false
|
||||||
sp_cleanup.qualify_static_field_accesses_with_declaring_class=false
|
sp_cleanup.qualify_static_field_accesses_with_declaring_class=false
|
||||||
sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true
|
sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true
|
||||||
sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true
|
sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true
|
||||||
sp_cleanup.qualify_static_member_accesses_with_declaring_class=true
|
sp_cleanup.qualify_static_member_accesses_with_declaring_class=true
|
||||||
sp_cleanup.qualify_static_method_accesses_with_declaring_class=false
|
sp_cleanup.qualify_static_method_accesses_with_declaring_class=false
|
||||||
sp_cleanup.remove_private_constructors=true
|
sp_cleanup.remove_private_constructors=true
|
||||||
|
sp_cleanup.remove_redundant_modifiers=false
|
||||||
|
sp_cleanup.remove_redundant_semicolons=false
|
||||||
sp_cleanup.remove_redundant_type_arguments=false
|
sp_cleanup.remove_redundant_type_arguments=false
|
||||||
sp_cleanup.remove_trailing_whitespaces=false
|
sp_cleanup.remove_trailing_whitespaces=false
|
||||||
sp_cleanup.remove_trailing_whitespaces_all=true
|
sp_cleanup.remove_trailing_whitespaces_all=true
|
||||||
sp_cleanup.remove_trailing_whitespaces_ignore_empty=true
|
sp_cleanup.remove_trailing_whitespaces_ignore_empty=true
|
||||||
|
sp_cleanup.remove_unnecessary_array_creation=false
|
||||||
sp_cleanup.remove_unnecessary_casts=true
|
sp_cleanup.remove_unnecessary_casts=true
|
||||||
sp_cleanup.remove_unnecessary_nls_tags=true
|
sp_cleanup.remove_unnecessary_nls_tags=true
|
||||||
sp_cleanup.remove_unused_imports=true
|
sp_cleanup.remove_unused_imports=true
|
||||||
@@ -126,11 +131,14 @@ sp_cleanup.remove_unused_private_fields=true
|
|||||||
sp_cleanup.remove_unused_private_members=false
|
sp_cleanup.remove_unused_private_members=false
|
||||||
sp_cleanup.remove_unused_private_methods=true
|
sp_cleanup.remove_unused_private_methods=true
|
||||||
sp_cleanup.remove_unused_private_types=true
|
sp_cleanup.remove_unused_private_types=true
|
||||||
|
sp_cleanup.simplify_lambda_expression_and_method_ref=false
|
||||||
sp_cleanup.sort_members=false
|
sp_cleanup.sort_members=false
|
||||||
sp_cleanup.sort_members_all=false
|
sp_cleanup.sort_members_all=false
|
||||||
sp_cleanup.use_anonymous_class_creation=false
|
sp_cleanup.use_anonymous_class_creation=false
|
||||||
|
sp_cleanup.use_autoboxing=false
|
||||||
sp_cleanup.use_blocks=true
|
sp_cleanup.use_blocks=true
|
||||||
sp_cleanup.use_blocks_only_for_return_and_throw=false
|
sp_cleanup.use_blocks_only_for_return_and_throw=false
|
||||||
|
sp_cleanup.use_directly_map_method=false
|
||||||
sp_cleanup.use_lambda=true
|
sp_cleanup.use_lambda=true
|
||||||
sp_cleanup.use_parentheses_in_expressions=true
|
sp_cleanup.use_parentheses_in_expressions=true
|
||||||
sp_cleanup.use_this_for_non_static_field_access=false
|
sp_cleanup.use_this_for_non_static_field_access=false
|
||||||
@@ -138,3 +146,4 @@ sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true
|
|||||||
sp_cleanup.use_this_for_non_static_method_access=false
|
sp_cleanup.use_this_for_non_static_method_access=false
|
||||||
sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true
|
sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true
|
||||||
sp_cleanup.use_type_arguments=false
|
sp_cleanup.use_type_arguments=false
|
||||||
|
sp_cleanup.use_unboxing=false
|
||||||
|
@@ -406,10 +406,13 @@ public class World
|
|||||||
oldRegion.removeVisibleObject(object);
|
oldRegion.removeVisibleObject(object);
|
||||||
|
|
||||||
// Go through all surrounding WorldRegion Creatures
|
// Go through all surrounding WorldRegion Creatures
|
||||||
for (WorldRegion worldRegion : oldRegion.getSurroundingRegions())
|
final WorldRegion[] surroundingRegions = oldRegion.getSurroundingRegions();
|
||||||
|
for (int i = 0; i < surroundingRegions.length; i++)
|
||||||
{
|
{
|
||||||
for (WorldObject wo : worldRegion.getVisibleObjects().values())
|
final List<WorldObject> visibleObjects = surroundingRegions[i].getVisibleObjects();
|
||||||
|
for (int j = 0; j < visibleObjects.size(); j++)
|
||||||
{
|
{
|
||||||
|
final WorldObject wo = visibleObjects.get(j);
|
||||||
if (wo == object)
|
if (wo == object)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
@@ -466,15 +469,19 @@ public class World
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (WorldRegion worldRegion : oldRegion.getSurroundingRegions())
|
final WorldRegion[] oldSurroundingRegions = oldRegion.getSurroundingRegions();
|
||||||
|
for (int i = 0; i < oldSurroundingRegions.length; i++)
|
||||||
{
|
{
|
||||||
|
final WorldRegion worldRegion = oldSurroundingRegions[i];
|
||||||
if (newRegion.isSurroundingRegion(worldRegion))
|
if (newRegion.isSurroundingRegion(worldRegion))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (WorldObject wo : worldRegion.getVisibleObjects().values())
|
final List<WorldObject> visibleObjects = worldRegion.getVisibleObjects();
|
||||||
|
for (int j = 0; j < visibleObjects.size(); j++)
|
||||||
{
|
{
|
||||||
|
final WorldObject wo = visibleObjects.get(j);
|
||||||
if (wo == object)
|
if (wo == object)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
@@ -522,15 +529,19 @@ public class World
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (WorldRegion worldRegion : newRegion.getSurroundingRegions())
|
final WorldRegion[] newSurroundingRegions = newRegion.getSurroundingRegions();
|
||||||
|
for (int i = 0; i < newSurroundingRegions.length; i++)
|
||||||
{
|
{
|
||||||
|
final WorldRegion worldRegion = newSurroundingRegions[i];
|
||||||
if (oldRegion.isSurroundingRegion(worldRegion))
|
if (oldRegion.isSurroundingRegion(worldRegion))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (WorldObject wo : worldRegion.getVisibleObjects().values())
|
final List<WorldObject> visibleObjects = worldRegion.getVisibleObjects();
|
||||||
|
for (int j = 0; j < visibleObjects.size(); j++)
|
||||||
{
|
{
|
||||||
|
final WorldObject wo = visibleObjects.get(j);
|
||||||
if ((wo == object) || (wo.getInstanceWorld() != object.getInstanceWorld()))
|
if ((wo == object) || (wo.getInstanceWorld() != object.getInstanceWorld()))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
@@ -610,27 +621,30 @@ public class World
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final WorldRegion centerWorldRegion = getRegion(object);
|
final WorldRegion worldRegion = getRegion(object);
|
||||||
if (centerWorldRegion == null)
|
if (worldRegion == null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (WorldRegion region : centerWorldRegion.getSurroundingRegions())
|
final WorldRegion[] surroundingRegions = worldRegion.getSurroundingRegions();
|
||||||
|
for (int i = 0; i < surroundingRegions.length; i++)
|
||||||
{
|
{
|
||||||
for (WorldObject visibleObject : region.getVisibleObjects().values())
|
final List<WorldObject> visibleObjects = surroundingRegions[i].getVisibleObjects();
|
||||||
|
for (int j = 0; j < visibleObjects.size(); j++)
|
||||||
{
|
{
|
||||||
if ((visibleObject == null) || (visibleObject == object) || !clazz.isInstance(visibleObject))
|
final WorldObject wo = visibleObjects.get(j);
|
||||||
|
if ((wo == null) || (wo == object) || !clazz.isInstance(wo))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (visibleObject.getInstanceWorld() != object.getInstanceWorld())
|
if (wo.getInstanceWorld() != object.getInstanceWorld())
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
c.accept(clazz.cast(visibleObject));
|
c.accept(clazz.cast(wo));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -662,29 +676,32 @@ public class World
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final WorldRegion centerWorldRegion = getRegion(object);
|
final WorldRegion worldRegion = getRegion(object);
|
||||||
if (centerWorldRegion == null)
|
if (worldRegion == null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (WorldRegion region : centerWorldRegion.getSurroundingRegions())
|
final WorldRegion[] surroundingRegions = worldRegion.getSurroundingRegions();
|
||||||
|
for (int i = 0; i < surroundingRegions.length; i++)
|
||||||
{
|
{
|
||||||
for (WorldObject visibleObject : region.getVisibleObjects().values())
|
final List<WorldObject> visibleObjects = surroundingRegions[i].getVisibleObjects();
|
||||||
|
for (int j = 0; j < visibleObjects.size(); j++)
|
||||||
{
|
{
|
||||||
if ((visibleObject == null) || (visibleObject == object) || !clazz.isInstance(visibleObject))
|
final WorldObject wo = visibleObjects.get(j);
|
||||||
|
if ((wo == null) || (wo == object) || !clazz.isInstance(wo))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (visibleObject.getInstanceWorld() != object.getInstanceWorld())
|
if (wo.getInstanceWorld() != object.getInstanceWorld())
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (visibleObject.calculateDistance3D(object) <= range)
|
if (wo.calculateDistance3D(object) <= range)
|
||||||
{
|
{
|
||||||
c.accept(clazz.cast(visibleObject));
|
c.accept(clazz.cast(wo));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -16,8 +16,8 @@
|
|||||||
*/
|
*/
|
||||||
package org.l2jmobius.gameserver.model;
|
package org.l2jmobius.gameserver.model;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.ArrayList;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.List;
|
||||||
import java.util.concurrent.ScheduledFuture;
|
import java.util.concurrent.ScheduledFuture;
|
||||||
|
|
||||||
import org.l2jmobius.Config;
|
import org.l2jmobius.Config;
|
||||||
@@ -28,9 +28,9 @@ import org.l2jmobius.gameserver.taskmanager.RandomAnimationTaskManager;
|
|||||||
|
|
||||||
public class WorldRegion
|
public class WorldRegion
|
||||||
{
|
{
|
||||||
/** Map containing visible objects in this world region. */
|
/** List containing visible objects in this world region. */
|
||||||
private final Map<Integer, WorldObject> _visibleObjects = new ConcurrentHashMap<>();
|
private final List<WorldObject> _visibleObjects = new ArrayList<>();
|
||||||
/** Map containing nearby regions forming this world region's effective area. */
|
/** Array containing nearby regions forming this world region's effective area. */
|
||||||
private WorldRegion[] _surroundingRegions;
|
private WorldRegion[] _surroundingRegions;
|
||||||
private final int _regionX;
|
private final int _regionX;
|
||||||
private final int _regionY;
|
private final int _regionY;
|
||||||
@@ -52,8 +52,9 @@ public class WorldRegion
|
|||||||
|
|
||||||
if (!isOn)
|
if (!isOn)
|
||||||
{
|
{
|
||||||
for (WorldObject wo : _visibleObjects.values())
|
for (int i = 0; i < _visibleObjects.size(); i++)
|
||||||
{
|
{
|
||||||
|
final WorldObject wo = _visibleObjects.get(i);
|
||||||
if (wo.isAttackable())
|
if (wo.isAttackable())
|
||||||
{
|
{
|
||||||
final Attackable mob = (Attackable) wo;
|
final Attackable mob = (Attackable) wo;
|
||||||
@@ -87,15 +88,16 @@ public class WorldRegion
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for (WorldObject wo : _visibleObjects.values())
|
for (int i = 0; i < _visibleObjects.size(); i++)
|
||||||
{
|
{
|
||||||
|
final WorldObject wo = _visibleObjects.get(i);
|
||||||
if (wo.isAttackable())
|
if (wo.isAttackable())
|
||||||
{
|
{
|
||||||
// Start HP/MP/CP regeneration task.
|
// Start HP/MP/CP regeneration task.
|
||||||
((Attackable) wo).getStatus().startHpMpRegeneration();
|
((Attackable) wo).getStatus().startHpMpRegeneration();
|
||||||
RandomAnimationTaskManager.getInstance().add((Npc) wo);
|
RandomAnimationTaskManager.getInstance().add((Npc) wo);
|
||||||
}
|
}
|
||||||
else if (wo instanceof Npc)
|
else if (wo.isNpc())
|
||||||
{
|
{
|
||||||
RandomAnimationTaskManager.getInstance().add((Npc) wo);
|
RandomAnimationTaskManager.getInstance().add((Npc) wo);
|
||||||
}
|
}
|
||||||
@@ -110,13 +112,21 @@ public class WorldRegion
|
|||||||
|
|
||||||
public boolean areNeighborsEmpty()
|
public boolean areNeighborsEmpty()
|
||||||
{
|
{
|
||||||
for (WorldRegion worldRegion : _surroundingRegions)
|
for (int i = 0; i < _surroundingRegions.length; i++)
|
||||||
{
|
{
|
||||||
if (worldRegion.isActive() && worldRegion.getVisibleObjects().values().stream().anyMatch(WorldObject::isPlayable))
|
final WorldRegion worldRegion = _surroundingRegions[i];
|
||||||
|
if (worldRegion.isActive())
|
||||||
|
{
|
||||||
|
final List<WorldObject> regionObjects = worldRegion.getVisibleObjects();
|
||||||
|
for (int j = 0; j < regionObjects.size(); j++)
|
||||||
|
{
|
||||||
|
if (regionObjects.get(j).isPlayable())
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -157,9 +167,9 @@ public class WorldRegion
|
|||||||
// Then, set a timer to activate the neighbors.
|
// Then, set a timer to activate the neighbors.
|
||||||
_neighborsTask = ThreadPool.schedule(() ->
|
_neighborsTask = ThreadPool.schedule(() ->
|
||||||
{
|
{
|
||||||
for (WorldRegion worldRegion : _surroundingRegions)
|
for (int i = 0; i < _surroundingRegions.length; i++)
|
||||||
{
|
{
|
||||||
worldRegion.setActive(true);
|
_surroundingRegions[i].setActive(true);
|
||||||
}
|
}
|
||||||
}, 1000 * Config.GRID_NEIGHBOR_TURNON_TIME);
|
}, 1000 * Config.GRID_NEIGHBOR_TURNON_TIME);
|
||||||
}
|
}
|
||||||
@@ -183,8 +193,9 @@ public class WorldRegion
|
|||||||
// Suggest means: first check if a neighbor has PlayerInstances in it. If not, deactivate.
|
// Suggest means: first check if a neighbor has PlayerInstances in it. If not, deactivate.
|
||||||
_neighborsTask = ThreadPool.schedule(() ->
|
_neighborsTask = ThreadPool.schedule(() ->
|
||||||
{
|
{
|
||||||
for (WorldRegion worldRegion : _surroundingRegions)
|
for (int i = 0; i < _surroundingRegions.length; i++)
|
||||||
{
|
{
|
||||||
|
final WorldRegion worldRegion = _surroundingRegions[i];
|
||||||
if (worldRegion.areNeighborsEmpty())
|
if (worldRegion.areNeighborsEmpty())
|
||||||
{
|
{
|
||||||
worldRegion.setActive(false);
|
worldRegion.setActive(false);
|
||||||
@@ -206,7 +217,13 @@ public class WorldRegion
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
_visibleObjects.put(object.getObjectId(), object);
|
synchronized (_visibleObjects)
|
||||||
|
{
|
||||||
|
if (!_visibleObjects.contains(object))
|
||||||
|
{
|
||||||
|
_visibleObjects.add(object);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// If this is the first player to enter the region, activate self and neighbors.
|
// If this is the first player to enter the region, activate self and neighbors.
|
||||||
if (object.isPlayable() && !_active && !Config.GRIDS_ALWAYS_ON)
|
if (object.isPlayable() && !_active && !Config.GRIDS_ALWAYS_ON)
|
||||||
@@ -230,7 +247,11 @@ public class WorldRegion
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_visibleObjects.remove(object.getObjectId());
|
|
||||||
|
synchronized (_visibleObjects)
|
||||||
|
{
|
||||||
|
_visibleObjects.remove(object);
|
||||||
|
}
|
||||||
|
|
||||||
if (object.isPlayable() && areNeighborsEmpty() && !Config.GRIDS_ALWAYS_ON)
|
if (object.isPlayable() && areNeighborsEmpty() && !Config.GRIDS_ALWAYS_ON)
|
||||||
{
|
{
|
||||||
@@ -238,7 +259,7 @@ public class WorldRegion
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<Integer, WorldObject> getVisibleObjects()
|
public List<WorldObject> getVisibleObjects()
|
||||||
{
|
{
|
||||||
return _visibleObjects;
|
return _visibleObjects;
|
||||||
}
|
}
|
||||||
|
@@ -94,7 +94,7 @@ sp_cleanup.always_use_parentheses_in_expressions=true
|
|||||||
sp_cleanup.always_use_this_for_non_static_field_access=false
|
sp_cleanup.always_use_this_for_non_static_field_access=false
|
||||||
sp_cleanup.always_use_this_for_non_static_method_access=false
|
sp_cleanup.always_use_this_for_non_static_method_access=false
|
||||||
sp_cleanup.convert_functional_interfaces=true
|
sp_cleanup.convert_functional_interfaces=true
|
||||||
sp_cleanup.convert_to_enhanced_for_loop=true
|
sp_cleanup.convert_to_enhanced_for_loop=false
|
||||||
sp_cleanup.correct_indentation=false
|
sp_cleanup.correct_indentation=false
|
||||||
sp_cleanup.format_source_code=true
|
sp_cleanup.format_source_code=true
|
||||||
sp_cleanup.format_source_code_changes_only=false
|
sp_cleanup.format_source_code_changes_only=false
|
||||||
@@ -106,18 +106,23 @@ sp_cleanup.make_type_abstract_if_missing_method=false
|
|||||||
sp_cleanup.make_variable_declarations_final=true
|
sp_cleanup.make_variable_declarations_final=true
|
||||||
sp_cleanup.never_use_blocks=false
|
sp_cleanup.never_use_blocks=false
|
||||||
sp_cleanup.never_use_parentheses_in_expressions=false
|
sp_cleanup.never_use_parentheses_in_expressions=false
|
||||||
|
sp_cleanup.number_suffix=false
|
||||||
sp_cleanup.on_save_use_additional_actions=true
|
sp_cleanup.on_save_use_additional_actions=true
|
||||||
sp_cleanup.organize_imports=true
|
sp_cleanup.organize_imports=true
|
||||||
|
sp_cleanup.push_down_negation=false
|
||||||
sp_cleanup.qualify_static_field_accesses_with_declaring_class=false
|
sp_cleanup.qualify_static_field_accesses_with_declaring_class=false
|
||||||
sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true
|
sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true
|
||||||
sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true
|
sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true
|
||||||
sp_cleanup.qualify_static_member_accesses_with_declaring_class=true
|
sp_cleanup.qualify_static_member_accesses_with_declaring_class=true
|
||||||
sp_cleanup.qualify_static_method_accesses_with_declaring_class=false
|
sp_cleanup.qualify_static_method_accesses_with_declaring_class=false
|
||||||
sp_cleanup.remove_private_constructors=true
|
sp_cleanup.remove_private_constructors=true
|
||||||
|
sp_cleanup.remove_redundant_modifiers=false
|
||||||
|
sp_cleanup.remove_redundant_semicolons=false
|
||||||
sp_cleanup.remove_redundant_type_arguments=false
|
sp_cleanup.remove_redundant_type_arguments=false
|
||||||
sp_cleanup.remove_trailing_whitespaces=false
|
sp_cleanup.remove_trailing_whitespaces=false
|
||||||
sp_cleanup.remove_trailing_whitespaces_all=true
|
sp_cleanup.remove_trailing_whitespaces_all=true
|
||||||
sp_cleanup.remove_trailing_whitespaces_ignore_empty=true
|
sp_cleanup.remove_trailing_whitespaces_ignore_empty=true
|
||||||
|
sp_cleanup.remove_unnecessary_array_creation=false
|
||||||
sp_cleanup.remove_unnecessary_casts=true
|
sp_cleanup.remove_unnecessary_casts=true
|
||||||
sp_cleanup.remove_unnecessary_nls_tags=true
|
sp_cleanup.remove_unnecessary_nls_tags=true
|
||||||
sp_cleanup.remove_unused_imports=true
|
sp_cleanup.remove_unused_imports=true
|
||||||
@@ -126,11 +131,14 @@ sp_cleanup.remove_unused_private_fields=true
|
|||||||
sp_cleanup.remove_unused_private_members=false
|
sp_cleanup.remove_unused_private_members=false
|
||||||
sp_cleanup.remove_unused_private_methods=true
|
sp_cleanup.remove_unused_private_methods=true
|
||||||
sp_cleanup.remove_unused_private_types=true
|
sp_cleanup.remove_unused_private_types=true
|
||||||
|
sp_cleanup.simplify_lambda_expression_and_method_ref=false
|
||||||
sp_cleanup.sort_members=false
|
sp_cleanup.sort_members=false
|
||||||
sp_cleanup.sort_members_all=false
|
sp_cleanup.sort_members_all=false
|
||||||
sp_cleanup.use_anonymous_class_creation=false
|
sp_cleanup.use_anonymous_class_creation=false
|
||||||
|
sp_cleanup.use_autoboxing=false
|
||||||
sp_cleanup.use_blocks=true
|
sp_cleanup.use_blocks=true
|
||||||
sp_cleanup.use_blocks_only_for_return_and_throw=false
|
sp_cleanup.use_blocks_only_for_return_and_throw=false
|
||||||
|
sp_cleanup.use_directly_map_method=false
|
||||||
sp_cleanup.use_lambda=true
|
sp_cleanup.use_lambda=true
|
||||||
sp_cleanup.use_parentheses_in_expressions=true
|
sp_cleanup.use_parentheses_in_expressions=true
|
||||||
sp_cleanup.use_this_for_non_static_field_access=false
|
sp_cleanup.use_this_for_non_static_field_access=false
|
||||||
@@ -138,3 +146,4 @@ sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true
|
|||||||
sp_cleanup.use_this_for_non_static_method_access=false
|
sp_cleanup.use_this_for_non_static_method_access=false
|
||||||
sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true
|
sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true
|
||||||
sp_cleanup.use_type_arguments=false
|
sp_cleanup.use_type_arguments=false
|
||||||
|
sp_cleanup.use_unboxing=false
|
||||||
|
@@ -406,10 +406,13 @@ public class World
|
|||||||
oldRegion.removeVisibleObject(object);
|
oldRegion.removeVisibleObject(object);
|
||||||
|
|
||||||
// Go through all surrounding WorldRegion Creatures
|
// Go through all surrounding WorldRegion Creatures
|
||||||
for (WorldRegion worldRegion : oldRegion.getSurroundingRegions())
|
final WorldRegion[] surroundingRegions = oldRegion.getSurroundingRegions();
|
||||||
|
for (int i = 0; i < surroundingRegions.length; i++)
|
||||||
{
|
{
|
||||||
for (WorldObject wo : worldRegion.getVisibleObjects().values())
|
final List<WorldObject> visibleObjects = surroundingRegions[i].getVisibleObjects();
|
||||||
|
for (int j = 0; j < visibleObjects.size(); j++)
|
||||||
{
|
{
|
||||||
|
final WorldObject wo = visibleObjects.get(j);
|
||||||
if (wo == object)
|
if (wo == object)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
@@ -466,15 +469,19 @@ public class World
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (WorldRegion worldRegion : oldRegion.getSurroundingRegions())
|
final WorldRegion[] oldSurroundingRegions = oldRegion.getSurroundingRegions();
|
||||||
|
for (int i = 0; i < oldSurroundingRegions.length; i++)
|
||||||
{
|
{
|
||||||
|
final WorldRegion worldRegion = oldSurroundingRegions[i];
|
||||||
if (newRegion.isSurroundingRegion(worldRegion))
|
if (newRegion.isSurroundingRegion(worldRegion))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (WorldObject wo : worldRegion.getVisibleObjects().values())
|
final List<WorldObject> visibleObjects = worldRegion.getVisibleObjects();
|
||||||
|
for (int j = 0; j < visibleObjects.size(); j++)
|
||||||
{
|
{
|
||||||
|
final WorldObject wo = visibleObjects.get(j);
|
||||||
if (wo == object)
|
if (wo == object)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
@@ -522,15 +529,19 @@ public class World
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (WorldRegion worldRegion : newRegion.getSurroundingRegions())
|
final WorldRegion[] newSurroundingRegions = newRegion.getSurroundingRegions();
|
||||||
|
for (int i = 0; i < newSurroundingRegions.length; i++)
|
||||||
{
|
{
|
||||||
|
final WorldRegion worldRegion = newSurroundingRegions[i];
|
||||||
if (oldRegion.isSurroundingRegion(worldRegion))
|
if (oldRegion.isSurroundingRegion(worldRegion))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (WorldObject wo : worldRegion.getVisibleObjects().values())
|
final List<WorldObject> visibleObjects = worldRegion.getVisibleObjects();
|
||||||
|
for (int j = 0; j < visibleObjects.size(); j++)
|
||||||
{
|
{
|
||||||
|
final WorldObject wo = visibleObjects.get(j);
|
||||||
if ((wo == object) || (wo.getInstanceWorld() != object.getInstanceWorld()))
|
if ((wo == object) || (wo.getInstanceWorld() != object.getInstanceWorld()))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
@@ -610,27 +621,30 @@ public class World
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final WorldRegion centerWorldRegion = getRegion(object);
|
final WorldRegion worldRegion = getRegion(object);
|
||||||
if (centerWorldRegion == null)
|
if (worldRegion == null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (WorldRegion region : centerWorldRegion.getSurroundingRegions())
|
final WorldRegion[] surroundingRegions = worldRegion.getSurroundingRegions();
|
||||||
|
for (int i = 0; i < surroundingRegions.length; i++)
|
||||||
{
|
{
|
||||||
for (WorldObject visibleObject : region.getVisibleObjects().values())
|
final List<WorldObject> visibleObjects = surroundingRegions[i].getVisibleObjects();
|
||||||
|
for (int j = 0; j < visibleObjects.size(); j++)
|
||||||
{
|
{
|
||||||
if ((visibleObject == null) || (visibleObject == object) || !clazz.isInstance(visibleObject))
|
final WorldObject wo = visibleObjects.get(j);
|
||||||
|
if ((wo == null) || (wo == object) || !clazz.isInstance(wo))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (visibleObject.getInstanceWorld() != object.getInstanceWorld())
|
if (wo.getInstanceWorld() != object.getInstanceWorld())
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
c.accept(clazz.cast(visibleObject));
|
c.accept(clazz.cast(wo));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -662,29 +676,32 @@ public class World
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final WorldRegion centerWorldRegion = getRegion(object);
|
final WorldRegion worldRegion = getRegion(object);
|
||||||
if (centerWorldRegion == null)
|
if (worldRegion == null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (WorldRegion region : centerWorldRegion.getSurroundingRegions())
|
final WorldRegion[] surroundingRegions = worldRegion.getSurroundingRegions();
|
||||||
|
for (int i = 0; i < surroundingRegions.length; i++)
|
||||||
{
|
{
|
||||||
for (WorldObject visibleObject : region.getVisibleObjects().values())
|
final List<WorldObject> visibleObjects = surroundingRegions[i].getVisibleObjects();
|
||||||
|
for (int j = 0; j < visibleObjects.size(); j++)
|
||||||
{
|
{
|
||||||
if ((visibleObject == null) || (visibleObject == object) || !clazz.isInstance(visibleObject))
|
final WorldObject wo = visibleObjects.get(j);
|
||||||
|
if ((wo == null) || (wo == object) || !clazz.isInstance(wo))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (visibleObject.getInstanceWorld() != object.getInstanceWorld())
|
if (wo.getInstanceWorld() != object.getInstanceWorld())
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (visibleObject.calculateDistance3D(object) <= range)
|
if (wo.calculateDistance3D(object) <= range)
|
||||||
{
|
{
|
||||||
c.accept(clazz.cast(visibleObject));
|
c.accept(clazz.cast(wo));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -16,8 +16,8 @@
|
|||||||
*/
|
*/
|
||||||
package org.l2jmobius.gameserver.model;
|
package org.l2jmobius.gameserver.model;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.ArrayList;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.List;
|
||||||
import java.util.concurrent.ScheduledFuture;
|
import java.util.concurrent.ScheduledFuture;
|
||||||
|
|
||||||
import org.l2jmobius.Config;
|
import org.l2jmobius.Config;
|
||||||
@@ -28,9 +28,9 @@ import org.l2jmobius.gameserver.taskmanager.RandomAnimationTaskManager;
|
|||||||
|
|
||||||
public class WorldRegion
|
public class WorldRegion
|
||||||
{
|
{
|
||||||
/** Map containing visible objects in this world region. */
|
/** List containing visible objects in this world region. */
|
||||||
private final Map<Integer, WorldObject> _visibleObjects = new ConcurrentHashMap<>();
|
private final List<WorldObject> _visibleObjects = new ArrayList<>();
|
||||||
/** Map containing nearby regions forming this world region's effective area. */
|
/** Array containing nearby regions forming this world region's effective area. */
|
||||||
private WorldRegion[] _surroundingRegions;
|
private WorldRegion[] _surroundingRegions;
|
||||||
private final int _regionX;
|
private final int _regionX;
|
||||||
private final int _regionY;
|
private final int _regionY;
|
||||||
@@ -52,8 +52,9 @@ public class WorldRegion
|
|||||||
|
|
||||||
if (!isOn)
|
if (!isOn)
|
||||||
{
|
{
|
||||||
for (WorldObject wo : _visibleObjects.values())
|
for (int i = 0; i < _visibleObjects.size(); i++)
|
||||||
{
|
{
|
||||||
|
final WorldObject wo = _visibleObjects.get(i);
|
||||||
if (wo.isAttackable())
|
if (wo.isAttackable())
|
||||||
{
|
{
|
||||||
final Attackable mob = (Attackable) wo;
|
final Attackable mob = (Attackable) wo;
|
||||||
@@ -87,15 +88,16 @@ public class WorldRegion
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for (WorldObject wo : _visibleObjects.values())
|
for (int i = 0; i < _visibleObjects.size(); i++)
|
||||||
{
|
{
|
||||||
|
final WorldObject wo = _visibleObjects.get(i);
|
||||||
if (wo.isAttackable())
|
if (wo.isAttackable())
|
||||||
{
|
{
|
||||||
// Start HP/MP/CP regeneration task.
|
// Start HP/MP/CP regeneration task.
|
||||||
((Attackable) wo).getStatus().startHpMpRegeneration();
|
((Attackable) wo).getStatus().startHpMpRegeneration();
|
||||||
RandomAnimationTaskManager.getInstance().add((Npc) wo);
|
RandomAnimationTaskManager.getInstance().add((Npc) wo);
|
||||||
}
|
}
|
||||||
else if (wo instanceof Npc)
|
else if (wo.isNpc())
|
||||||
{
|
{
|
||||||
RandomAnimationTaskManager.getInstance().add((Npc) wo);
|
RandomAnimationTaskManager.getInstance().add((Npc) wo);
|
||||||
}
|
}
|
||||||
@@ -110,13 +112,21 @@ public class WorldRegion
|
|||||||
|
|
||||||
public boolean areNeighborsEmpty()
|
public boolean areNeighborsEmpty()
|
||||||
{
|
{
|
||||||
for (WorldRegion worldRegion : _surroundingRegions)
|
for (int i = 0; i < _surroundingRegions.length; i++)
|
||||||
{
|
{
|
||||||
if (worldRegion.isActive() && worldRegion.getVisibleObjects().values().stream().anyMatch(WorldObject::isPlayable))
|
final WorldRegion worldRegion = _surroundingRegions[i];
|
||||||
|
if (worldRegion.isActive())
|
||||||
|
{
|
||||||
|
final List<WorldObject> regionObjects = worldRegion.getVisibleObjects();
|
||||||
|
for (int j = 0; j < regionObjects.size(); j++)
|
||||||
|
{
|
||||||
|
if (regionObjects.get(j).isPlayable())
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -157,9 +167,9 @@ public class WorldRegion
|
|||||||
// Then, set a timer to activate the neighbors.
|
// Then, set a timer to activate the neighbors.
|
||||||
_neighborsTask = ThreadPool.schedule(() ->
|
_neighborsTask = ThreadPool.schedule(() ->
|
||||||
{
|
{
|
||||||
for (WorldRegion worldRegion : _surroundingRegions)
|
for (int i = 0; i < _surroundingRegions.length; i++)
|
||||||
{
|
{
|
||||||
worldRegion.setActive(true);
|
_surroundingRegions[i].setActive(true);
|
||||||
}
|
}
|
||||||
}, 1000 * Config.GRID_NEIGHBOR_TURNON_TIME);
|
}, 1000 * Config.GRID_NEIGHBOR_TURNON_TIME);
|
||||||
}
|
}
|
||||||
@@ -183,8 +193,9 @@ public class WorldRegion
|
|||||||
// Suggest means: first check if a neighbor has PlayerInstances in it. If not, deactivate.
|
// Suggest means: first check if a neighbor has PlayerInstances in it. If not, deactivate.
|
||||||
_neighborsTask = ThreadPool.schedule(() ->
|
_neighborsTask = ThreadPool.schedule(() ->
|
||||||
{
|
{
|
||||||
for (WorldRegion worldRegion : _surroundingRegions)
|
for (int i = 0; i < _surroundingRegions.length; i++)
|
||||||
{
|
{
|
||||||
|
final WorldRegion worldRegion = _surroundingRegions[i];
|
||||||
if (worldRegion.areNeighborsEmpty())
|
if (worldRegion.areNeighborsEmpty())
|
||||||
{
|
{
|
||||||
worldRegion.setActive(false);
|
worldRegion.setActive(false);
|
||||||
@@ -206,7 +217,13 @@ public class WorldRegion
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
_visibleObjects.put(object.getObjectId(), object);
|
synchronized (_visibleObjects)
|
||||||
|
{
|
||||||
|
if (!_visibleObjects.contains(object))
|
||||||
|
{
|
||||||
|
_visibleObjects.add(object);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// If this is the first player to enter the region, activate self and neighbors.
|
// If this is the first player to enter the region, activate self and neighbors.
|
||||||
if (object.isPlayable() && !_active && !Config.GRIDS_ALWAYS_ON)
|
if (object.isPlayable() && !_active && !Config.GRIDS_ALWAYS_ON)
|
||||||
@@ -230,7 +247,11 @@ public class WorldRegion
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_visibleObjects.remove(object.getObjectId());
|
|
||||||
|
synchronized (_visibleObjects)
|
||||||
|
{
|
||||||
|
_visibleObjects.remove(object);
|
||||||
|
}
|
||||||
|
|
||||||
if (object.isPlayable() && areNeighborsEmpty() && !Config.GRIDS_ALWAYS_ON)
|
if (object.isPlayable() && areNeighborsEmpty() && !Config.GRIDS_ALWAYS_ON)
|
||||||
{
|
{
|
||||||
@@ -238,7 +259,7 @@ public class WorldRegion
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<Integer, WorldObject> getVisibleObjects()
|
public List<WorldObject> getVisibleObjects()
|
||||||
{
|
{
|
||||||
return _visibleObjects;
|
return _visibleObjects;
|
||||||
}
|
}
|
||||||
|
@@ -406,10 +406,13 @@ public class World
|
|||||||
oldRegion.removeVisibleObject(object);
|
oldRegion.removeVisibleObject(object);
|
||||||
|
|
||||||
// Go through all surrounding WorldRegion Creatures
|
// Go through all surrounding WorldRegion Creatures
|
||||||
for (WorldRegion worldRegion : oldRegion.getSurroundingRegions())
|
final WorldRegion[] surroundingRegions = oldRegion.getSurroundingRegions();
|
||||||
|
for (int i = 0; i < surroundingRegions.length; i++)
|
||||||
{
|
{
|
||||||
for (WorldObject wo : worldRegion.getVisibleObjects().values())
|
final List<WorldObject> visibleObjects = surroundingRegions[i].getVisibleObjects();
|
||||||
|
for (int j = 0; j < visibleObjects.size(); j++)
|
||||||
{
|
{
|
||||||
|
final WorldObject wo = visibleObjects.get(j);
|
||||||
if (wo == object)
|
if (wo == object)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
@@ -466,15 +469,19 @@ public class World
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (WorldRegion worldRegion : oldRegion.getSurroundingRegions())
|
final WorldRegion[] oldSurroundingRegions = oldRegion.getSurroundingRegions();
|
||||||
|
for (int i = 0; i < oldSurroundingRegions.length; i++)
|
||||||
{
|
{
|
||||||
|
final WorldRegion worldRegion = oldSurroundingRegions[i];
|
||||||
if (newRegion.isSurroundingRegion(worldRegion))
|
if (newRegion.isSurroundingRegion(worldRegion))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (WorldObject wo : worldRegion.getVisibleObjects().values())
|
final List<WorldObject> visibleObjects = worldRegion.getVisibleObjects();
|
||||||
|
for (int j = 0; j < visibleObjects.size(); j++)
|
||||||
{
|
{
|
||||||
|
final WorldObject wo = visibleObjects.get(j);
|
||||||
if (wo == object)
|
if (wo == object)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
@@ -522,15 +529,19 @@ public class World
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (WorldRegion worldRegion : newRegion.getSurroundingRegions())
|
final WorldRegion[] newSurroundingRegions = newRegion.getSurroundingRegions();
|
||||||
|
for (int i = 0; i < newSurroundingRegions.length; i++)
|
||||||
{
|
{
|
||||||
|
final WorldRegion worldRegion = newSurroundingRegions[i];
|
||||||
if (oldRegion.isSurroundingRegion(worldRegion))
|
if (oldRegion.isSurroundingRegion(worldRegion))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (WorldObject wo : worldRegion.getVisibleObjects().values())
|
final List<WorldObject> visibleObjects = worldRegion.getVisibleObjects();
|
||||||
|
for (int j = 0; j < visibleObjects.size(); j++)
|
||||||
{
|
{
|
||||||
|
final WorldObject wo = visibleObjects.get(j);
|
||||||
if ((wo == object) || (wo.getInstanceWorld() != object.getInstanceWorld()))
|
if ((wo == object) || (wo.getInstanceWorld() != object.getInstanceWorld()))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
@@ -610,27 +621,30 @@ public class World
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final WorldRegion centerWorldRegion = getRegion(object);
|
final WorldRegion worldRegion = getRegion(object);
|
||||||
if (centerWorldRegion == null)
|
if (worldRegion == null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (WorldRegion region : centerWorldRegion.getSurroundingRegions())
|
final WorldRegion[] surroundingRegions = worldRegion.getSurroundingRegions();
|
||||||
|
for (int i = 0; i < surroundingRegions.length; i++)
|
||||||
{
|
{
|
||||||
for (WorldObject visibleObject : region.getVisibleObjects().values())
|
final List<WorldObject> visibleObjects = surroundingRegions[i].getVisibleObjects();
|
||||||
|
for (int j = 0; j < visibleObjects.size(); j++)
|
||||||
{
|
{
|
||||||
if ((visibleObject == null) || (visibleObject == object) || !clazz.isInstance(visibleObject))
|
final WorldObject wo = visibleObjects.get(j);
|
||||||
|
if ((wo == null) || (wo == object) || !clazz.isInstance(wo))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (visibleObject.getInstanceWorld() != object.getInstanceWorld())
|
if (wo.getInstanceWorld() != object.getInstanceWorld())
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
c.accept(clazz.cast(visibleObject));
|
c.accept(clazz.cast(wo));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -662,29 +676,32 @@ public class World
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final WorldRegion centerWorldRegion = getRegion(object);
|
final WorldRegion worldRegion = getRegion(object);
|
||||||
if (centerWorldRegion == null)
|
if (worldRegion == null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (WorldRegion region : centerWorldRegion.getSurroundingRegions())
|
final WorldRegion[] surroundingRegions = worldRegion.getSurroundingRegions();
|
||||||
|
for (int i = 0; i < surroundingRegions.length; i++)
|
||||||
{
|
{
|
||||||
for (WorldObject visibleObject : region.getVisibleObjects().values())
|
final List<WorldObject> visibleObjects = surroundingRegions[i].getVisibleObjects();
|
||||||
|
for (int j = 0; j < visibleObjects.size(); j++)
|
||||||
{
|
{
|
||||||
if ((visibleObject == null) || (visibleObject == object) || !clazz.isInstance(visibleObject))
|
final WorldObject wo = visibleObjects.get(j);
|
||||||
|
if ((wo == null) || (wo == object) || !clazz.isInstance(wo))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (visibleObject.getInstanceWorld() != object.getInstanceWorld())
|
if (wo.getInstanceWorld() != object.getInstanceWorld())
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (visibleObject.calculateDistance3D(object) <= range)
|
if (wo.calculateDistance3D(object) <= range)
|
||||||
{
|
{
|
||||||
c.accept(clazz.cast(visibleObject));
|
c.accept(clazz.cast(wo));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -16,8 +16,8 @@
|
|||||||
*/
|
*/
|
||||||
package org.l2jmobius.gameserver.model;
|
package org.l2jmobius.gameserver.model;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.ArrayList;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.List;
|
||||||
import java.util.concurrent.ScheduledFuture;
|
import java.util.concurrent.ScheduledFuture;
|
||||||
|
|
||||||
import org.l2jmobius.Config;
|
import org.l2jmobius.Config;
|
||||||
@@ -28,9 +28,9 @@ import org.l2jmobius.gameserver.taskmanager.RandomAnimationTaskManager;
|
|||||||
|
|
||||||
public class WorldRegion
|
public class WorldRegion
|
||||||
{
|
{
|
||||||
/** Map containing visible objects in this world region. */
|
/** List containing visible objects in this world region. */
|
||||||
private final Map<Integer, WorldObject> _visibleObjects = new ConcurrentHashMap<>();
|
private final List<WorldObject> _visibleObjects = new ArrayList<>();
|
||||||
/** Map containing nearby regions forming this world region's effective area. */
|
/** Array containing nearby regions forming this world region's effective area. */
|
||||||
private WorldRegion[] _surroundingRegions;
|
private WorldRegion[] _surroundingRegions;
|
||||||
private final int _regionX;
|
private final int _regionX;
|
||||||
private final int _regionY;
|
private final int _regionY;
|
||||||
@@ -52,8 +52,9 @@ public class WorldRegion
|
|||||||
|
|
||||||
if (!isOn)
|
if (!isOn)
|
||||||
{
|
{
|
||||||
for (WorldObject wo : _visibleObjects.values())
|
for (int i = 0; i < _visibleObjects.size(); i++)
|
||||||
{
|
{
|
||||||
|
final WorldObject wo = _visibleObjects.get(i);
|
||||||
if (wo.isAttackable())
|
if (wo.isAttackable())
|
||||||
{
|
{
|
||||||
final Attackable mob = (Attackable) wo;
|
final Attackable mob = (Attackable) wo;
|
||||||
@@ -87,15 +88,16 @@ public class WorldRegion
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for (WorldObject wo : _visibleObjects.values())
|
for (int i = 0; i < _visibleObjects.size(); i++)
|
||||||
{
|
{
|
||||||
|
final WorldObject wo = _visibleObjects.get(i);
|
||||||
if (wo.isAttackable())
|
if (wo.isAttackable())
|
||||||
{
|
{
|
||||||
// Start HP/MP/CP regeneration task.
|
// Start HP/MP/CP regeneration task.
|
||||||
((Attackable) wo).getStatus().startHpMpRegeneration();
|
((Attackable) wo).getStatus().startHpMpRegeneration();
|
||||||
RandomAnimationTaskManager.getInstance().add((Npc) wo);
|
RandomAnimationTaskManager.getInstance().add((Npc) wo);
|
||||||
}
|
}
|
||||||
else if (wo instanceof Npc)
|
else if (wo.isNpc())
|
||||||
{
|
{
|
||||||
RandomAnimationTaskManager.getInstance().add((Npc) wo);
|
RandomAnimationTaskManager.getInstance().add((Npc) wo);
|
||||||
}
|
}
|
||||||
@@ -110,13 +112,21 @@ public class WorldRegion
|
|||||||
|
|
||||||
public boolean areNeighborsEmpty()
|
public boolean areNeighborsEmpty()
|
||||||
{
|
{
|
||||||
for (WorldRegion worldRegion : _surroundingRegions)
|
for (int i = 0; i < _surroundingRegions.length; i++)
|
||||||
{
|
{
|
||||||
if (worldRegion.isActive() && worldRegion.getVisibleObjects().values().stream().anyMatch(WorldObject::isPlayable))
|
final WorldRegion worldRegion = _surroundingRegions[i];
|
||||||
|
if (worldRegion.isActive())
|
||||||
|
{
|
||||||
|
final List<WorldObject> regionObjects = worldRegion.getVisibleObjects();
|
||||||
|
for (int j = 0; j < regionObjects.size(); j++)
|
||||||
|
{
|
||||||
|
if (regionObjects.get(j).isPlayable())
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -157,9 +167,9 @@ public class WorldRegion
|
|||||||
// Then, set a timer to activate the neighbors.
|
// Then, set a timer to activate the neighbors.
|
||||||
_neighborsTask = ThreadPool.schedule(() ->
|
_neighborsTask = ThreadPool.schedule(() ->
|
||||||
{
|
{
|
||||||
for (WorldRegion worldRegion : _surroundingRegions)
|
for (int i = 0; i < _surroundingRegions.length; i++)
|
||||||
{
|
{
|
||||||
worldRegion.setActive(true);
|
_surroundingRegions[i].setActive(true);
|
||||||
}
|
}
|
||||||
}, 1000 * Config.GRID_NEIGHBOR_TURNON_TIME);
|
}, 1000 * Config.GRID_NEIGHBOR_TURNON_TIME);
|
||||||
}
|
}
|
||||||
@@ -183,8 +193,9 @@ public class WorldRegion
|
|||||||
// Suggest means: first check if a neighbor has PlayerInstances in it. If not, deactivate.
|
// Suggest means: first check if a neighbor has PlayerInstances in it. If not, deactivate.
|
||||||
_neighborsTask = ThreadPool.schedule(() ->
|
_neighborsTask = ThreadPool.schedule(() ->
|
||||||
{
|
{
|
||||||
for (WorldRegion worldRegion : _surroundingRegions)
|
for (int i = 0; i < _surroundingRegions.length; i++)
|
||||||
{
|
{
|
||||||
|
final WorldRegion worldRegion = _surroundingRegions[i];
|
||||||
if (worldRegion.areNeighborsEmpty())
|
if (worldRegion.areNeighborsEmpty())
|
||||||
{
|
{
|
||||||
worldRegion.setActive(false);
|
worldRegion.setActive(false);
|
||||||
@@ -206,7 +217,13 @@ public class WorldRegion
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
_visibleObjects.put(object.getObjectId(), object);
|
synchronized (_visibleObjects)
|
||||||
|
{
|
||||||
|
if (!_visibleObjects.contains(object))
|
||||||
|
{
|
||||||
|
_visibleObjects.add(object);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// If this is the first player to enter the region, activate self and neighbors.
|
// If this is the first player to enter the region, activate self and neighbors.
|
||||||
if (object.isPlayable() && !_active && !Config.GRIDS_ALWAYS_ON)
|
if (object.isPlayable() && !_active && !Config.GRIDS_ALWAYS_ON)
|
||||||
@@ -230,7 +247,11 @@ public class WorldRegion
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_visibleObjects.remove(object.getObjectId());
|
|
||||||
|
synchronized (_visibleObjects)
|
||||||
|
{
|
||||||
|
_visibleObjects.remove(object);
|
||||||
|
}
|
||||||
|
|
||||||
if (object.isPlayable() && areNeighborsEmpty() && !Config.GRIDS_ALWAYS_ON)
|
if (object.isPlayable() && areNeighborsEmpty() && !Config.GRIDS_ALWAYS_ON)
|
||||||
{
|
{
|
||||||
@@ -238,7 +259,7 @@ public class WorldRegion
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<Integer, WorldObject> getVisibleObjects()
|
public List<WorldObject> getVisibleObjects()
|
||||||
{
|
{
|
||||||
return _visibleObjects;
|
return _visibleObjects;
|
||||||
}
|
}
|
||||||
|
@@ -94,7 +94,7 @@ sp_cleanup.always_use_parentheses_in_expressions=true
|
|||||||
sp_cleanup.always_use_this_for_non_static_field_access=false
|
sp_cleanup.always_use_this_for_non_static_field_access=false
|
||||||
sp_cleanup.always_use_this_for_non_static_method_access=false
|
sp_cleanup.always_use_this_for_non_static_method_access=false
|
||||||
sp_cleanup.convert_functional_interfaces=true
|
sp_cleanup.convert_functional_interfaces=true
|
||||||
sp_cleanup.convert_to_enhanced_for_loop=true
|
sp_cleanup.convert_to_enhanced_for_loop=false
|
||||||
sp_cleanup.correct_indentation=false
|
sp_cleanup.correct_indentation=false
|
||||||
sp_cleanup.format_source_code=true
|
sp_cleanup.format_source_code=true
|
||||||
sp_cleanup.format_source_code_changes_only=false
|
sp_cleanup.format_source_code_changes_only=false
|
||||||
@@ -106,18 +106,23 @@ sp_cleanup.make_type_abstract_if_missing_method=false
|
|||||||
sp_cleanup.make_variable_declarations_final=true
|
sp_cleanup.make_variable_declarations_final=true
|
||||||
sp_cleanup.never_use_blocks=false
|
sp_cleanup.never_use_blocks=false
|
||||||
sp_cleanup.never_use_parentheses_in_expressions=false
|
sp_cleanup.never_use_parentheses_in_expressions=false
|
||||||
|
sp_cleanup.number_suffix=false
|
||||||
sp_cleanup.on_save_use_additional_actions=true
|
sp_cleanup.on_save_use_additional_actions=true
|
||||||
sp_cleanup.organize_imports=true
|
sp_cleanup.organize_imports=true
|
||||||
|
sp_cleanup.push_down_negation=false
|
||||||
sp_cleanup.qualify_static_field_accesses_with_declaring_class=false
|
sp_cleanup.qualify_static_field_accesses_with_declaring_class=false
|
||||||
sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true
|
sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true
|
||||||
sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true
|
sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true
|
||||||
sp_cleanup.qualify_static_member_accesses_with_declaring_class=true
|
sp_cleanup.qualify_static_member_accesses_with_declaring_class=true
|
||||||
sp_cleanup.qualify_static_method_accesses_with_declaring_class=false
|
sp_cleanup.qualify_static_method_accesses_with_declaring_class=false
|
||||||
sp_cleanup.remove_private_constructors=true
|
sp_cleanup.remove_private_constructors=true
|
||||||
|
sp_cleanup.remove_redundant_modifiers=false
|
||||||
|
sp_cleanup.remove_redundant_semicolons=false
|
||||||
sp_cleanup.remove_redundant_type_arguments=false
|
sp_cleanup.remove_redundant_type_arguments=false
|
||||||
sp_cleanup.remove_trailing_whitespaces=false
|
sp_cleanup.remove_trailing_whitespaces=false
|
||||||
sp_cleanup.remove_trailing_whitespaces_all=true
|
sp_cleanup.remove_trailing_whitespaces_all=true
|
||||||
sp_cleanup.remove_trailing_whitespaces_ignore_empty=true
|
sp_cleanup.remove_trailing_whitespaces_ignore_empty=true
|
||||||
|
sp_cleanup.remove_unnecessary_array_creation=false
|
||||||
sp_cleanup.remove_unnecessary_casts=true
|
sp_cleanup.remove_unnecessary_casts=true
|
||||||
sp_cleanup.remove_unnecessary_nls_tags=true
|
sp_cleanup.remove_unnecessary_nls_tags=true
|
||||||
sp_cleanup.remove_unused_imports=true
|
sp_cleanup.remove_unused_imports=true
|
||||||
@@ -126,11 +131,14 @@ sp_cleanup.remove_unused_private_fields=true
|
|||||||
sp_cleanup.remove_unused_private_members=false
|
sp_cleanup.remove_unused_private_members=false
|
||||||
sp_cleanup.remove_unused_private_methods=true
|
sp_cleanup.remove_unused_private_methods=true
|
||||||
sp_cleanup.remove_unused_private_types=true
|
sp_cleanup.remove_unused_private_types=true
|
||||||
|
sp_cleanup.simplify_lambda_expression_and_method_ref=false
|
||||||
sp_cleanup.sort_members=false
|
sp_cleanup.sort_members=false
|
||||||
sp_cleanup.sort_members_all=false
|
sp_cleanup.sort_members_all=false
|
||||||
sp_cleanup.use_anonymous_class_creation=false
|
sp_cleanup.use_anonymous_class_creation=false
|
||||||
|
sp_cleanup.use_autoboxing=false
|
||||||
sp_cleanup.use_blocks=true
|
sp_cleanup.use_blocks=true
|
||||||
sp_cleanup.use_blocks_only_for_return_and_throw=false
|
sp_cleanup.use_blocks_only_for_return_and_throw=false
|
||||||
|
sp_cleanup.use_directly_map_method=false
|
||||||
sp_cleanup.use_lambda=true
|
sp_cleanup.use_lambda=true
|
||||||
sp_cleanup.use_parentheses_in_expressions=true
|
sp_cleanup.use_parentheses_in_expressions=true
|
||||||
sp_cleanup.use_this_for_non_static_field_access=false
|
sp_cleanup.use_this_for_non_static_field_access=false
|
||||||
@@ -138,3 +146,4 @@ sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true
|
|||||||
sp_cleanup.use_this_for_non_static_method_access=false
|
sp_cleanup.use_this_for_non_static_method_access=false
|
||||||
sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true
|
sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true
|
||||||
sp_cleanup.use_type_arguments=false
|
sp_cleanup.use_type_arguments=false
|
||||||
|
sp_cleanup.use_unboxing=false
|
||||||
|
@@ -94,7 +94,7 @@ sp_cleanup.always_use_parentheses_in_expressions=true
|
|||||||
sp_cleanup.always_use_this_for_non_static_field_access=false
|
sp_cleanup.always_use_this_for_non_static_field_access=false
|
||||||
sp_cleanup.always_use_this_for_non_static_method_access=false
|
sp_cleanup.always_use_this_for_non_static_method_access=false
|
||||||
sp_cleanup.convert_functional_interfaces=true
|
sp_cleanup.convert_functional_interfaces=true
|
||||||
sp_cleanup.convert_to_enhanced_for_loop=true
|
sp_cleanup.convert_to_enhanced_for_loop=false
|
||||||
sp_cleanup.correct_indentation=false
|
sp_cleanup.correct_indentation=false
|
||||||
sp_cleanup.format_source_code=true
|
sp_cleanup.format_source_code=true
|
||||||
sp_cleanup.format_source_code_changes_only=false
|
sp_cleanup.format_source_code_changes_only=false
|
||||||
@@ -106,18 +106,23 @@ sp_cleanup.make_type_abstract_if_missing_method=false
|
|||||||
sp_cleanup.make_variable_declarations_final=true
|
sp_cleanup.make_variable_declarations_final=true
|
||||||
sp_cleanup.never_use_blocks=false
|
sp_cleanup.never_use_blocks=false
|
||||||
sp_cleanup.never_use_parentheses_in_expressions=false
|
sp_cleanup.never_use_parentheses_in_expressions=false
|
||||||
|
sp_cleanup.number_suffix=false
|
||||||
sp_cleanup.on_save_use_additional_actions=true
|
sp_cleanup.on_save_use_additional_actions=true
|
||||||
sp_cleanup.organize_imports=true
|
sp_cleanup.organize_imports=true
|
||||||
|
sp_cleanup.push_down_negation=false
|
||||||
sp_cleanup.qualify_static_field_accesses_with_declaring_class=false
|
sp_cleanup.qualify_static_field_accesses_with_declaring_class=false
|
||||||
sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true
|
sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true
|
||||||
sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true
|
sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true
|
||||||
sp_cleanup.qualify_static_member_accesses_with_declaring_class=true
|
sp_cleanup.qualify_static_member_accesses_with_declaring_class=true
|
||||||
sp_cleanup.qualify_static_method_accesses_with_declaring_class=false
|
sp_cleanup.qualify_static_method_accesses_with_declaring_class=false
|
||||||
sp_cleanup.remove_private_constructors=true
|
sp_cleanup.remove_private_constructors=true
|
||||||
|
sp_cleanup.remove_redundant_modifiers=false
|
||||||
|
sp_cleanup.remove_redundant_semicolons=false
|
||||||
sp_cleanup.remove_redundant_type_arguments=false
|
sp_cleanup.remove_redundant_type_arguments=false
|
||||||
sp_cleanup.remove_trailing_whitespaces=false
|
sp_cleanup.remove_trailing_whitespaces=false
|
||||||
sp_cleanup.remove_trailing_whitespaces_all=true
|
sp_cleanup.remove_trailing_whitespaces_all=true
|
||||||
sp_cleanup.remove_trailing_whitespaces_ignore_empty=true
|
sp_cleanup.remove_trailing_whitespaces_ignore_empty=true
|
||||||
|
sp_cleanup.remove_unnecessary_array_creation=false
|
||||||
sp_cleanup.remove_unnecessary_casts=true
|
sp_cleanup.remove_unnecessary_casts=true
|
||||||
sp_cleanup.remove_unnecessary_nls_tags=true
|
sp_cleanup.remove_unnecessary_nls_tags=true
|
||||||
sp_cleanup.remove_unused_imports=true
|
sp_cleanup.remove_unused_imports=true
|
||||||
@@ -126,11 +131,14 @@ sp_cleanup.remove_unused_private_fields=true
|
|||||||
sp_cleanup.remove_unused_private_members=false
|
sp_cleanup.remove_unused_private_members=false
|
||||||
sp_cleanup.remove_unused_private_methods=true
|
sp_cleanup.remove_unused_private_methods=true
|
||||||
sp_cleanup.remove_unused_private_types=true
|
sp_cleanup.remove_unused_private_types=true
|
||||||
|
sp_cleanup.simplify_lambda_expression_and_method_ref=false
|
||||||
sp_cleanup.sort_members=false
|
sp_cleanup.sort_members=false
|
||||||
sp_cleanup.sort_members_all=false
|
sp_cleanup.sort_members_all=false
|
||||||
sp_cleanup.use_anonymous_class_creation=false
|
sp_cleanup.use_anonymous_class_creation=false
|
||||||
|
sp_cleanup.use_autoboxing=false
|
||||||
sp_cleanup.use_blocks=true
|
sp_cleanup.use_blocks=true
|
||||||
sp_cleanup.use_blocks_only_for_return_and_throw=false
|
sp_cleanup.use_blocks_only_for_return_and_throw=false
|
||||||
|
sp_cleanup.use_directly_map_method=false
|
||||||
sp_cleanup.use_lambda=true
|
sp_cleanup.use_lambda=true
|
||||||
sp_cleanup.use_parentheses_in_expressions=true
|
sp_cleanup.use_parentheses_in_expressions=true
|
||||||
sp_cleanup.use_this_for_non_static_field_access=false
|
sp_cleanup.use_this_for_non_static_field_access=false
|
||||||
@@ -138,3 +146,4 @@ sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true
|
|||||||
sp_cleanup.use_this_for_non_static_method_access=false
|
sp_cleanup.use_this_for_non_static_method_access=false
|
||||||
sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true
|
sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true
|
||||||
sp_cleanup.use_type_arguments=false
|
sp_cleanup.use_type_arguments=false
|
||||||
|
sp_cleanup.use_unboxing=false
|
||||||
|
@@ -16,7 +16,6 @@
|
|||||||
*/
|
*/
|
||||||
package org.l2jmobius.gameserver.handler;
|
package org.l2jmobius.gameserver.handler;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.l2jmobius.gameserver.model.Skill;
|
import org.l2jmobius.gameserver.model.Skill;
|
||||||
@@ -30,9 +29,8 @@ public interface ISkillHandler
|
|||||||
* @param creature
|
* @param creature
|
||||||
* @param skill
|
* @param skill
|
||||||
* @param targets
|
* @param targets
|
||||||
* @throws IOException
|
|
||||||
*/
|
*/
|
||||||
void useSkill(Creature creature, Skill skill, List<Creature> targets) throws IOException;
|
void useSkill(Creature creature, Skill skill, List<Creature> targets);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* this method is called at initialization to register all the item ids automatically
|
* this method is called at initialization to register all the item ids automatically
|
||||||
|
@@ -16,7 +16,6 @@
|
|||||||
*/
|
*/
|
||||||
package org.l2jmobius.gameserver.handler.skillhandlers;
|
package org.l2jmobius.gameserver.handler.skillhandlers;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
@@ -675,14 +674,14 @@ public class Disablers implements ISkillHandler
|
|||||||
final List<Creature> tgts = new ArrayList<>();
|
final List<Creature> tgts = new ArrayList<>();
|
||||||
tgts.add(target);
|
tgts.add(target);
|
||||||
|
|
||||||
try
|
// try
|
||||||
{
|
// {
|
||||||
healhandler.useSkill(creature, skill, tgts);
|
healhandler.useSkill(creature, skill, tgts);
|
||||||
}
|
// }
|
||||||
catch (IOException e)
|
// catch (IOException e)
|
||||||
{
|
// {
|
||||||
LOGGER.warning(e.getMessage());
|
// LOGGER.warning(e.getMessage());
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (String stat : negateEffectTypes)
|
for (String stat : negateEffectTypes)
|
||||||
|
@@ -115,21 +115,9 @@ public class World
|
|||||||
*/
|
*/
|
||||||
public void removeObjects(List<WorldObject> list)
|
public void removeObjects(List<WorldObject> list)
|
||||||
{
|
{
|
||||||
for (WorldObject o : list)
|
for (int i = 0; i < list.size(); i++)
|
||||||
{
|
{
|
||||||
_allObjects.remove(o.getObjectId());
|
_allObjects.remove(list.get(i).getObjectId());
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Removes the objects.
|
|
||||||
* @param objects the objects
|
|
||||||
*/
|
|
||||||
public void removeObjects(WorldObject[] objects)
|
|
||||||
{
|
|
||||||
for (WorldObject o : objects)
|
|
||||||
{
|
|
||||||
_allObjects.remove(o.getObjectId());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -138,12 +126,12 @@ public class World
|
|||||||
* <br>
|
* <br>
|
||||||
* <b><u>Example of use</u>:</b><br>
|
* <b><u>Example of use</u>:</b><br>
|
||||||
* <li>Client packets : Action, AttackRequest, RequestJoinParty, RequestJoinPledge...</li><br>
|
* <li>Client packets : Action, AttackRequest, RequestJoinParty, RequestJoinPledge...</li><br>
|
||||||
* @param oID Identifier of the WorldObject
|
* @param objectId Identifier of the WorldObject
|
||||||
* @return the object
|
* @return the object
|
||||||
*/
|
*/
|
||||||
public WorldObject findObject(int oID)
|
public WorldObject findObject(int objectId)
|
||||||
{
|
{
|
||||||
return _allObjects.get(oID);
|
return _allObjects.get(objectId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -308,12 +296,10 @@ public class World
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Go through the visible objects contained in the circular area
|
// Go through the visible objects contained in the circular area
|
||||||
for (WorldObject wo : getVisibleObjects(object, 2000))
|
final List<WorldObject> visibleObjects = getVisibleObjects(object, 2000);
|
||||||
|
for (int i = 0; i < visibleObjects.size(); i++)
|
||||||
{
|
{
|
||||||
if (wo == null)
|
final WorldObject wo = visibleObjects.get(i);
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add the object in WorldObjectHashSet(WorldObject) _knownObjects of the visible Creature according to conditions :
|
// Add the object in WorldObjectHashSet(WorldObject) _knownObjects of the visible Creature according to conditions :
|
||||||
// - Creature is visible
|
// - Creature is visible
|
||||||
@@ -342,8 +328,11 @@ public class World
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Go through the visible objects contained in the circular area
|
// Go through the visible objects contained in the circular area
|
||||||
for (WorldObject wo : getVisibleObjects(object, 2000))
|
final List<WorldObject> visibleObjects = getVisibleObjects(object, 2000);
|
||||||
|
for (int i = 0; i < visibleObjects.size(); i++)
|
||||||
{
|
{
|
||||||
|
final WorldObject wo = visibleObjects.get(i);
|
||||||
|
|
||||||
// Add the object in WorldObjectHashSet(WorldObject) _knownObjects of the visible Creature according to conditions :
|
// Add the object in WorldObjectHashSet(WorldObject) _knownObjects of the visible Creature according to conditions :
|
||||||
// - Creature is visible
|
// - Creature is visible
|
||||||
// - object is not already known
|
// - object is not already known
|
||||||
@@ -417,10 +406,14 @@ public class World
|
|||||||
oldRegion.removeVisibleObject(object);
|
oldRegion.removeVisibleObject(object);
|
||||||
|
|
||||||
// Go through all surrounding WorldRegion Creatures
|
// Go through all surrounding WorldRegion Creatures
|
||||||
for (WorldRegion worldRegion : oldRegion.getSurroundingRegions())
|
final WorldRegion[] surroundingRegions = oldRegion.getSurroundingRegions();
|
||||||
|
for (int i = 0; i < surroundingRegions.length; i++)
|
||||||
{
|
{
|
||||||
for (WorldObject wo : worldRegion.getVisibleObjects())
|
final List<WorldObject> visibleObjects = surroundingRegions[i].getVisibleObjects();
|
||||||
|
for (int j = 0; j < visibleObjects.size(); j++)
|
||||||
{
|
{
|
||||||
|
final WorldObject wo = visibleObjects.get(j);
|
||||||
|
|
||||||
// Remove the WorldObject from the WorldObjectHashSet(WorldObject) _knownObjects of the surrounding WorldRegion Creatures
|
// Remove the WorldObject from the WorldObjectHashSet(WorldObject) _knownObjects of the surrounding WorldRegion Creatures
|
||||||
// If object is a PlayerInstance, remove the WorldObject from the WorldObjectHashSet(PlayerInstance) _knownPlayer of the surrounding WorldRegion Creatures
|
// If object is a PlayerInstance, remove the WorldObject from the WorldObjectHashSet(PlayerInstance) _knownPlayer of the surrounding WorldRegion Creatures
|
||||||
// If object is targeted by one of the surrounding WorldRegion Creatures, cancel ATTACK and cast
|
// If object is targeted by one of the surrounding WorldRegion Creatures, cancel ATTACK and cast
|
||||||
@@ -489,10 +482,13 @@ public class World
|
|||||||
final List<WorldObject> result = new ArrayList<>();
|
final List<WorldObject> result = new ArrayList<>();
|
||||||
|
|
||||||
// Go through the list of region
|
// Go through the list of region
|
||||||
for (WorldRegion worldRegion : region.getSurroundingRegions())
|
final WorldRegion[] surroundingRegions = region.getSurroundingRegions();
|
||||||
|
for (int i = 0; i < surroundingRegions.length; i++)
|
||||||
{
|
{
|
||||||
for (WorldObject wo : worldRegion.getVisibleObjects())
|
final List<WorldObject> visibleObjects = surroundingRegions[i].getVisibleObjects();
|
||||||
|
for (int j = 0; j < visibleObjects.size(); j++)
|
||||||
{
|
{
|
||||||
|
final WorldObject wo = visibleObjects.get(j);
|
||||||
if (wo == null)
|
if (wo == null)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
@@ -552,11 +548,14 @@ public class World
|
|||||||
final List<WorldObject> result = new ArrayList<>();
|
final List<WorldObject> result = new ArrayList<>();
|
||||||
|
|
||||||
// Go through the list of region
|
// Go through the list of region
|
||||||
for (WorldRegion worldRegion : region.getSurroundingRegions())
|
final WorldRegion[] surroundingRegions = region.getSurroundingRegions();
|
||||||
|
for (int i = 0; i < surroundingRegions.length; i++)
|
||||||
{
|
{
|
||||||
// Go through visible objects of the selected region
|
// Go through visible objects of the selected region
|
||||||
for (WorldObject wo : worldRegion.getVisibleObjects())
|
final List<WorldObject> visibleObjects = surroundingRegions[i].getVisibleObjects();
|
||||||
|
for (int j = 0; j < visibleObjects.size(); j++)
|
||||||
{
|
{
|
||||||
|
final WorldObject wo = visibleObjects.get(j);
|
||||||
if (wo == null)
|
if (wo == null)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
@@ -614,10 +613,13 @@ public class World
|
|||||||
final List<WorldObject> result = new ArrayList<>();
|
final List<WorldObject> result = new ArrayList<>();
|
||||||
|
|
||||||
// Go through visible object of the selected region
|
// Go through visible object of the selected region
|
||||||
for (WorldRegion worldRegion : object.getWorldRegion().getSurroundingRegions())
|
final WorldRegion[] surroundingRegions = object.getWorldRegion().getSurroundingRegions();
|
||||||
|
for (int i = 0; i < surroundingRegions.length; i++)
|
||||||
{
|
{
|
||||||
for (WorldObject wo : worldRegion.getVisibleObjects())
|
final List<WorldObject> visibleObjects = surroundingRegions[i].getVisibleObjects();
|
||||||
|
for (int j = 0; j < visibleObjects.size(); j++)
|
||||||
{
|
{
|
||||||
|
final WorldObject wo = visibleObjects.get(j);
|
||||||
if (wo == null)
|
if (wo == null)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
@@ -644,58 +646,6 @@ public class World
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Return all visible players of the WorldRegion object's and of its surrounding WorldRegion.<br>
|
|
||||||
* <br>
|
|
||||||
* <b><u>Concept</u>:</b><br>
|
|
||||||
* <br>
|
|
||||||
* All visible object are identified in <b>_visibleObjects</b> of their current WorldRegion<br>
|
|
||||||
* All surrounding WorldRegion are identified in <b>_surroundingRegions</b> of the selected WorldRegion in order to scan a large area around a WorldObject<br>
|
|
||||||
* <br>
|
|
||||||
* <b><u>Example of use</u>:</b><br>
|
|
||||||
* <li>Find Close Objects for Creature</li><br>
|
|
||||||
* @param object WorldObject that determine the current WorldRegion
|
|
||||||
* @return the visible playable
|
|
||||||
*/
|
|
||||||
public List<PlayerInstance> getVisiblePlayers(WorldObject object)
|
|
||||||
{
|
|
||||||
final WorldRegion region = object.getWorldRegion();
|
|
||||||
if (region == null)
|
|
||||||
{
|
|
||||||
return Collections.emptyList();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create a list in order to contain all visible WorldObject
|
|
||||||
final List<PlayerInstance> result = new ArrayList<>();
|
|
||||||
|
|
||||||
// Go through the list of region
|
|
||||||
for (WorldRegion worldRegion : region.getSurroundingRegions())
|
|
||||||
{
|
|
||||||
// Go through visible object of the selected region
|
|
||||||
for (PlayerInstance playable : worldRegion.getAllPlayers())
|
|
||||||
{
|
|
||||||
if (playable == null)
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (playable.equals(object))
|
|
||||||
{
|
|
||||||
continue; // skip our own character
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!playable.isSpawned())
|
|
||||||
{
|
|
||||||
continue; // skip dying objects
|
|
||||||
}
|
|
||||||
|
|
||||||
result.add(playable);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Calculate the current WorldRegions of the object according to its position (x,y).<br>
|
* Calculate the current WorldRegions of the object according to its position (x,y).<br>
|
||||||
* <br>
|
* <br>
|
||||||
@@ -793,24 +743,6 @@ public class World
|
|||||||
LOGGER.info("All visible NPCs deleted.");
|
LOGGER.info("All visible NPCs deleted.");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the account players.
|
|
||||||
* @param account the account_name
|
|
||||||
* @return the account players
|
|
||||||
*/
|
|
||||||
public List<PlayerInstance> getAccountPlayers(String account)
|
|
||||||
{
|
|
||||||
final List<PlayerInstance> result = new ArrayList<>();
|
|
||||||
for (PlayerInstance actual : _allPlayers.values())
|
|
||||||
{
|
|
||||||
if (actual.getAccountName().equals(account))
|
|
||||||
{
|
|
||||||
result.add(actual);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static World getInstance()
|
public static World getInstance()
|
||||||
{
|
{
|
||||||
return SingletonHolder.INSTANCE;
|
return SingletonHolder.INSTANCE;
|
||||||
|
@@ -16,10 +16,9 @@
|
|||||||
*/
|
*/
|
||||||
package org.l2jmobius.gameserver.model;
|
package org.l2jmobius.gameserver.model;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
|
||||||
import java.util.concurrent.ScheduledFuture;
|
import java.util.concurrent.ScheduledFuture;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
@@ -31,9 +30,7 @@ import org.l2jmobius.gameserver.ai.SiegeGuardAI;
|
|||||||
import org.l2jmobius.gameserver.datatables.sql.SpawnTable;
|
import org.l2jmobius.gameserver.datatables.sql.SpawnTable;
|
||||||
import org.l2jmobius.gameserver.model.actor.Attackable;
|
import org.l2jmobius.gameserver.model.actor.Attackable;
|
||||||
import org.l2jmobius.gameserver.model.actor.Creature;
|
import org.l2jmobius.gameserver.model.actor.Creature;
|
||||||
import org.l2jmobius.gameserver.model.actor.Playable;
|
|
||||||
import org.l2jmobius.gameserver.model.actor.instance.NpcInstance;
|
import org.l2jmobius.gameserver.model.actor.instance.NpcInstance;
|
||||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
|
||||||
import org.l2jmobius.gameserver.model.spawn.Spawn;
|
import org.l2jmobius.gameserver.model.spawn.Spawn;
|
||||||
import org.l2jmobius.gameserver.model.zone.ZoneManager;
|
import org.l2jmobius.gameserver.model.zone.ZoneManager;
|
||||||
import org.l2jmobius.gameserver.model.zone.ZoneType;
|
import org.l2jmobius.gameserver.model.zone.ZoneType;
|
||||||
@@ -44,8 +41,7 @@ public class WorldRegion
|
|||||||
{
|
{
|
||||||
private static final Logger LOGGER = Logger.getLogger(WorldRegion.class.getName());
|
private static final Logger LOGGER = Logger.getLogger(WorldRegion.class.getName());
|
||||||
|
|
||||||
private final Collection<PlayerInstance> _playerObjects = ConcurrentHashMap.newKeySet();
|
private final List<WorldObject> _visibleObjects = new ArrayList<>();
|
||||||
private final Collection<WorldObject> _visibleObjects = ConcurrentHashMap.newKeySet();
|
|
||||||
private WorldRegion[] _surroundingRegions;
|
private WorldRegion[] _surroundingRegions;
|
||||||
private final int _regionX;
|
private final int _regionX;
|
||||||
private final int _regionY;
|
private final int _regionY;
|
||||||
@@ -74,7 +70,6 @@ public class WorldRegion
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
_zoneManager.unregisterZone(zone);
|
_zoneManager.unregisterZone(zone);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -127,8 +122,9 @@ public class WorldRegion
|
|||||||
{
|
{
|
||||||
if (!isOn)
|
if (!isOn)
|
||||||
{
|
{
|
||||||
for (WorldObject wo : _visibleObjects)
|
for (int i = 0; i < _visibleObjects.size(); i++)
|
||||||
{
|
{
|
||||||
|
final WorldObject wo = _visibleObjects.get(i);
|
||||||
if (wo instanceof Attackable)
|
if (wo instanceof Attackable)
|
||||||
{
|
{
|
||||||
final Attackable mob = (Attackable) wo;
|
final Attackable mob = (Attackable) wo;
|
||||||
@@ -174,8 +170,9 @@ public class WorldRegion
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for (WorldObject wo : _visibleObjects)
|
for (int i = 0; i < _visibleObjects.size(); i++)
|
||||||
{
|
{
|
||||||
|
final WorldObject wo = _visibleObjects.get(i);
|
||||||
if (wo instanceof Attackable)
|
if (wo instanceof Attackable)
|
||||||
{
|
{
|
||||||
// Start HP/MP/CP Regeneration task
|
// Start HP/MP/CP Regeneration task
|
||||||
@@ -190,22 +187,30 @@ public class WorldRegion
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Boolean isActive()
|
public boolean isActive()
|
||||||
{
|
{
|
||||||
return _active;
|
return _active;
|
||||||
}
|
}
|
||||||
|
|
||||||
// check if all 9 neighbors (including self) are inactive or active but with no players.
|
// check if all 9 neighbors (including self) are inactive or active but with no players.
|
||||||
// returns true if the above condition is met.
|
// returns true if the above condition is met.
|
||||||
public Boolean areNeighborsEmpty()
|
public boolean areNeighborsEmpty()
|
||||||
{
|
{
|
||||||
for (WorldRegion worldRegion : _surroundingRegions)
|
for (int i = 0; i < _surroundingRegions.length; i++)
|
||||||
{
|
{
|
||||||
if (worldRegion.isActive() && !worldRegion.getAllPlayers().isEmpty())
|
final WorldRegion worldRegion = _surroundingRegions[i];
|
||||||
|
if (worldRegion.isActive())
|
||||||
|
{
|
||||||
|
final List<WorldObject> regionObjects = worldRegion.getVisibleObjects();
|
||||||
|
for (int j = 0; j < regionObjects.size(); j++)
|
||||||
|
{
|
||||||
|
if (regionObjects.get(j).isPlayable())
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -246,9 +251,9 @@ public class WorldRegion
|
|||||||
// Then, set a timer to activate the neighbors.
|
// Then, set a timer to activate the neighbors.
|
||||||
_neighborsTask = ThreadPool.schedule(() ->
|
_neighborsTask = ThreadPool.schedule(() ->
|
||||||
{
|
{
|
||||||
for (WorldRegion worldRegion : _surroundingRegions)
|
for (int i = 0; i < _surroundingRegions.length; i++)
|
||||||
{
|
{
|
||||||
worldRegion.setActive(true);
|
_surroundingRegions[i].setActive(true);
|
||||||
}
|
}
|
||||||
}, 1000 * Config.GRID_NEIGHBOR_TURNON_TIME);
|
}, 1000 * Config.GRID_NEIGHBOR_TURNON_TIME);
|
||||||
}
|
}
|
||||||
@@ -272,8 +277,9 @@ public class WorldRegion
|
|||||||
// Suggest means: first check if a neighbor has PlayerInstances in it. If not, deactivate.
|
// Suggest means: first check if a neighbor has PlayerInstances in it. If not, deactivate.
|
||||||
_neighborsTask = ThreadPool.schedule(() ->
|
_neighborsTask = ThreadPool.schedule(() ->
|
||||||
{
|
{
|
||||||
for (WorldRegion worldRegion : _surroundingRegions)
|
for (int i = 0; i < _surroundingRegions.length; i++)
|
||||||
{
|
{
|
||||||
|
final WorldRegion worldRegion = _surroundingRegions[i];
|
||||||
if (worldRegion.areNeighborsEmpty())
|
if (worldRegion.areNeighborsEmpty())
|
||||||
{
|
{
|
||||||
worldRegion.setActive(false);
|
worldRegion.setActive(false);
|
||||||
@@ -296,19 +302,20 @@ public class WorldRegion
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
_visibleObjects.add(object);
|
synchronized (_visibleObjects)
|
||||||
|
|
||||||
if (object instanceof PlayerInstance)
|
|
||||||
{
|
{
|
||||||
_playerObjects.add((PlayerInstance) object);
|
if (!_visibleObjects.contains(object))
|
||||||
|
{
|
||||||
|
_visibleObjects.add(object);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// if this is the first player to enter the region, activate self & neighbors
|
// If this is the first player to enter the region, activate self and neighbors.
|
||||||
if ((_playerObjects.size() == 1) && !Config.GRIDS_ALWAYS_ON)
|
if (object.isPlayable() && !_active && !Config.GRIDS_ALWAYS_ON)
|
||||||
{
|
{
|
||||||
startActivation();
|
startActivation();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove the WorldObject from the WorldObjectHashSet(WorldObject) _visibleObjects in this WorldRegion<br>
|
* Remove the WorldObject from the WorldObjectHashSet(WorldObject) _visibleObjects in this WorldRegion<br>
|
||||||
@@ -323,22 +330,36 @@ public class WorldRegion
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
_visibleObjects.remove(object);
|
if (_visibleObjects.isEmpty())
|
||||||
|
|
||||||
if (object instanceof Playable)
|
|
||||||
{
|
{
|
||||||
_playerObjects.remove(object);
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (_playerObjects.isEmpty() && !Config.GRIDS_ALWAYS_ON)
|
synchronized (_visibleObjects)
|
||||||
|
{
|
||||||
|
_visibleObjects.remove(object);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (object.isPlayable() && areNeighborsEmpty() && !Config.GRIDS_ALWAYS_ON)
|
||||||
{
|
{
|
||||||
startDeactivation();
|
startDeactivation();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public void setSurroundingRegions(WorldRegion[] regions)
|
public void setSurroundingRegions(WorldRegion[] regions)
|
||||||
{
|
{
|
||||||
_surroundingRegions = regions;
|
_surroundingRegions = regions;
|
||||||
|
|
||||||
|
// Make sure that this region is always the first region to improve bulk operations when this region should be updated first.
|
||||||
|
for (int i = 0; i < _surroundingRegions.length; i++)
|
||||||
|
{
|
||||||
|
if (_surroundingRegions[i] == this)
|
||||||
|
{
|
||||||
|
final WorldRegion first = _surroundingRegions[0];
|
||||||
|
_surroundingRegions[0] = this;
|
||||||
|
_surroundingRegions[i] = first;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -349,12 +370,7 @@ public class WorldRegion
|
|||||||
return _surroundingRegions;
|
return _surroundingRegions;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Collection<PlayerInstance> getAllPlayers()
|
public List<WorldObject> getVisibleObjects()
|
||||||
{
|
|
||||||
return _playerObjects;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Collection<WorldObject> getVisibleObjects()
|
|
||||||
{
|
{
|
||||||
return _visibleObjects;
|
return _visibleObjects;
|
||||||
}
|
}
|
||||||
@@ -370,8 +386,9 @@ public class WorldRegion
|
|||||||
public synchronized void deleteVisibleNpcSpawns()
|
public synchronized void deleteVisibleNpcSpawns()
|
||||||
{
|
{
|
||||||
LOGGER.info("Deleting all visible NPCs in Region: " + getName());
|
LOGGER.info("Deleting all visible NPCs in Region: " + getName());
|
||||||
for (WorldObject obj : _visibleObjects)
|
for (int i = 0; i < _visibleObjects.size(); i++)
|
||||||
{
|
{
|
||||||
|
final WorldObject obj = _visibleObjects.get(i);
|
||||||
if (obj instanceof NpcInstance)
|
if (obj instanceof NpcInstance)
|
||||||
{
|
{
|
||||||
final NpcInstance target = (NpcInstance) obj;
|
final NpcInstance target = (NpcInstance) obj;
|
||||||
@@ -404,8 +421,10 @@ public class WorldRegion
|
|||||||
final int down = y - range;
|
final int down = y - range;
|
||||||
final int left = x + range;
|
final int left = x + range;
|
||||||
final int right = x - range;
|
final int right = x - range;
|
||||||
for (ZoneType e : _zoneManager.getZones())
|
final List<ZoneType> zones = _zoneManager.getZones();
|
||||||
|
for (int i = 0; i < zones.size(); i++)
|
||||||
{
|
{
|
||||||
|
final ZoneType e = zones.get(i);
|
||||||
if (e instanceof PeaceZone)
|
if (e instanceof PeaceZone)
|
||||||
{
|
{
|
||||||
if (e.isInsideZone(x, up, z))
|
if (e.isInsideZone(x, up, z))
|
||||||
|
@@ -2751,17 +2751,17 @@ public abstract class Creature extends WorldObject implements ISkillsHolder
|
|||||||
@Override
|
@Override
|
||||||
public void run()
|
public void run()
|
||||||
{
|
{
|
||||||
try
|
// try
|
||||||
{
|
// {
|
||||||
if (_creature != null)
|
if (_creature != null)
|
||||||
{
|
{
|
||||||
_creature.enableSkill(_skill);
|
_creature.enableSkill(_skill);
|
||||||
}
|
}
|
||||||
}
|
// }
|
||||||
catch (Throwable e)
|
// catch (Throwable e)
|
||||||
{
|
// {
|
||||||
LOGGER.warning(e.getMessage());
|
// LOGGER.warning(e.getMessage());
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2805,14 +2805,14 @@ public abstract class Creature extends WorldObject implements ISkillsHolder
|
|||||||
@Override
|
@Override
|
||||||
public void run()
|
public void run()
|
||||||
{
|
{
|
||||||
try
|
// try
|
||||||
{
|
// {
|
||||||
onHitTimer(_hitTarget, _damage, _crit, _miss, _soulshot, _shld);
|
onHitTimer(_hitTarget, _damage, _crit, _miss, _soulshot, _shld);
|
||||||
}
|
// }
|
||||||
catch (Throwable e)
|
// catch (Throwable e)
|
||||||
{
|
// {
|
||||||
LOGGER.warning("fixme:hit task unhandled exception " + e);
|
// LOGGER.warning("fixme:hit task unhandled exception " + e);
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2905,14 +2905,14 @@ public abstract class Creature extends WorldObject implements ISkillsHolder
|
|||||||
@Override
|
@Override
|
||||||
public void run()
|
public void run()
|
||||||
{
|
{
|
||||||
try
|
// try
|
||||||
{
|
// {
|
||||||
_currPlayer.useMagic(_queuedSkill, _isCtrlPressed, _isShiftPressed);
|
_currPlayer.useMagic(_queuedSkill, _isCtrlPressed, _isShiftPressed);
|
||||||
}
|
// }
|
||||||
catch (Throwable e)
|
// catch (Throwable e)
|
||||||
{
|
// {
|
||||||
LOGGER.warning(e.getMessage());
|
// LOGGER.warning(e.getMessage());
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2935,14 +2935,14 @@ public abstract class Creature extends WorldObject implements ISkillsHolder
|
|||||||
@Override
|
@Override
|
||||||
public void run()
|
public void run()
|
||||||
{
|
{
|
||||||
try
|
// try
|
||||||
{
|
// {
|
||||||
getAI().notifyEvent(_evt, null);
|
getAI().notifyEvent(_evt, null);
|
||||||
}
|
// }
|
||||||
catch (Throwable t)
|
// catch (Throwable t)
|
||||||
{
|
// {
|
||||||
LOGGER.warning(t.getMessage());
|
// LOGGER.warning(t.getMessage());
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2954,8 +2954,8 @@ public abstract class Creature extends WorldObject implements ISkillsHolder
|
|||||||
@Override
|
@Override
|
||||||
public void run()
|
public void run()
|
||||||
{
|
{
|
||||||
try
|
// try
|
||||||
{
|
// {
|
||||||
if (System.currentTimeMillis() > _pvpFlagLasts)
|
if (System.currentTimeMillis() > _pvpFlagLasts)
|
||||||
{
|
{
|
||||||
stopPvPFlag();
|
stopPvPFlag();
|
||||||
@@ -2968,11 +2968,11 @@ public abstract class Creature extends WorldObject implements ISkillsHolder
|
|||||||
{
|
{
|
||||||
updatePvPFlag(1);
|
updatePvPFlag(1);
|
||||||
}
|
}
|
||||||
}
|
// }
|
||||||
catch (Exception e)
|
// catch (Exception e)
|
||||||
{
|
// {
|
||||||
LOGGER.warning("error in pvp flag task: " + e);
|
// LOGGER.warning("error in pvp flag task: " + e);
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4688,14 +4688,14 @@ public abstract class Creature extends WorldObject implements ISkillsHolder
|
|||||||
{
|
{
|
||||||
for (PlayerInstance player : getKnownList().getKnownPlayers().values())
|
for (PlayerInstance player : getKnownList().getKnownPlayers().values())
|
||||||
{
|
{
|
||||||
try
|
// try
|
||||||
{
|
// {
|
||||||
player.sendPacket(su);
|
player.sendPacket(su);
|
||||||
}
|
// }
|
||||||
catch (NullPointerException e)
|
// catch (NullPointerException e)
|
||||||
{
|
// {
|
||||||
LOGGER.warning(e.toString());
|
// LOGGER.warning(e.toString());
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -5507,18 +5507,18 @@ public abstract class Creature extends WorldObject implements ISkillsHolder
|
|||||||
final int gty = (originalY - World.MAP_MIN_Y) >> 4;
|
final int gty = (originalY - World.MAP_MIN_Y) >> 4;
|
||||||
if (isOnGeodataPath())
|
if (isOnGeodataPath())
|
||||||
{
|
{
|
||||||
try
|
// try
|
||||||
{
|
// {
|
||||||
if ((gtx == _move.geoPathGtx) && (gty == _move.geoPathGty))
|
if ((gtx == _move.geoPathGtx) && (gty == _move.geoPathGty))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_move.onGeodataPathIndex = -1; // Set not on geodata path.
|
_move.onGeodataPathIndex = -1; // Set not on geodata path.
|
||||||
}
|
// }
|
||||||
catch (NullPointerException e)
|
// catch (NullPointerException e)
|
||||||
{
|
// {
|
||||||
// nothing
|
// // nothing
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
// Temporary fix for character outside world region errors (should not happen)
|
// Temporary fix for character outside world region errors (should not happen)
|
||||||
@@ -7333,8 +7333,8 @@ public abstract class Creature extends WorldObject implements ISkillsHolder
|
|||||||
}
|
}
|
||||||
|
|
||||||
final List<Creature> targets2 = targets;
|
final List<Creature> targets2 = targets;
|
||||||
try
|
// try
|
||||||
{
|
// {
|
||||||
if ((targets2 != null) && !targets2.isEmpty())
|
if ((targets2 != null) && !targets2.isEmpty())
|
||||||
{
|
{
|
||||||
// Go through targets table
|
// Go through targets table
|
||||||
@@ -7377,14 +7377,14 @@ public abstract class Creature extends WorldObject implements ISkillsHolder
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
// }
|
||||||
catch (Exception e)
|
// catch (Exception e)
|
||||||
{
|
// {
|
||||||
LOGGER.warning(e.toString());
|
// LOGGER.warning(e.toString());
|
||||||
}
|
// }
|
||||||
|
|
||||||
try
|
// try
|
||||||
{
|
// {
|
||||||
final StatusUpdate su = new StatusUpdate(getObjectId());
|
final StatusUpdate su = new StatusUpdate(getObjectId());
|
||||||
boolean isSendStatus = false;
|
boolean isSendStatus = false;
|
||||||
|
|
||||||
@@ -7438,11 +7438,11 @@ public abstract class Creature extends WorldObject implements ISkillsHolder
|
|||||||
|
|
||||||
// Launch the magic skill in order to calculate its effects
|
// Launch the magic skill in order to calculate its effects
|
||||||
callSkill(skill, targets);
|
callSkill(skill, targets);
|
||||||
}
|
// }
|
||||||
catch (Exception e)
|
// catch (Exception e)
|
||||||
{
|
// {
|
||||||
LOGGER.warning(e.toString());
|
// LOGGER.warning(e.toString());
|
||||||
}
|
// }
|
||||||
|
|
||||||
if (instant || (coolTime == 0))
|
if (instant || (coolTime == 0))
|
||||||
{
|
{
|
||||||
@@ -7560,8 +7560,8 @@ public abstract class Creature extends WorldObject implements ISkillsHolder
|
|||||||
// Launch weapon Special ability skill effect if available
|
// Launch weapon Special ability skill effect if available
|
||||||
if (activeWeapon != null)
|
if (activeWeapon != null)
|
||||||
{
|
{
|
||||||
try
|
// try
|
||||||
{
|
// {
|
||||||
if (targets != null)
|
if (targets != null)
|
||||||
{
|
{
|
||||||
for (WorldObject target : targets)
|
for (WorldObject target : targets)
|
||||||
@@ -7572,11 +7572,11 @@ public abstract class Creature extends WorldObject implements ISkillsHolder
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
// }
|
||||||
catch (Exception e)
|
// catch (Exception e)
|
||||||
{
|
// {
|
||||||
LOGGER.warning(e.toString());
|
// LOGGER.warning(e.toString());
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -7755,8 +7755,8 @@ public abstract class Creature extends WorldObject implements ISkillsHolder
|
|||||||
*/
|
*/
|
||||||
public void callSkill(Skill skill, List<Creature> targets)
|
public void callSkill(Skill skill, List<Creature> targets)
|
||||||
{
|
{
|
||||||
try
|
// try
|
||||||
{
|
// {
|
||||||
if (skill.isToggle() && (getFirstEffect(skill.getId()) != null))
|
if (skill.isToggle() && (getFirstEffect(skill.getId()) != null))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
@@ -8113,11 +8113,11 @@ public abstract class Creature extends WorldObject implements ISkillsHolder
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
// }
|
||||||
catch (Exception e)
|
// catch (Exception e)
|
||||||
{
|
// {
|
||||||
LOGGER.warning(e.getMessage());
|
// LOGGER.warning(e.getMessage());
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -141,9 +141,9 @@ public class WorldObjectKnownList
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Go through all visible WorldObject near the Creature
|
// Go through all visible WorldObject near the Creature
|
||||||
for (WorldObject playable : World.getInstance().getVisiblePlayers(_activeObject))
|
for (WorldObject object : World.getInstance().getVisibleObjects(_activeObject))
|
||||||
{
|
{
|
||||||
if (playable == null)
|
if ((object == null) || !object.isPlayable())
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -151,7 +151,7 @@ public class WorldObjectKnownList
|
|||||||
// Try to add object to active object's known objects
|
// Try to add object to active object's known objects
|
||||||
// Creature only needs to see visible PlayerInstance and PlayableInstance, when moving. Other creatures are currently only known from initial spawn area.
|
// Creature only needs to see visible PlayerInstance and PlayableInstance, when moving. Other creatures are currently only known from initial spawn area.
|
||||||
// Possibly look into getDistanceToForgetObject values before modifying this approach...
|
// Possibly look into getDistanceToForgetObject values before modifying this approach...
|
||||||
addKnownObject(playable);
|
addKnownObject(object);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -16,7 +16,6 @@
|
|||||||
*/
|
*/
|
||||||
package org.l2jmobius.gameserver.model.items;
|
package org.l2jmobius.gameserver.model.items;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -404,8 +403,8 @@ public class Weapon extends Item
|
|||||||
continue; // Skill condition not met
|
continue; // Skill condition not met
|
||||||
}
|
}
|
||||||
|
|
||||||
try
|
// try
|
||||||
{
|
// {
|
||||||
// Get the skill handler corresponding to the skill type
|
// Get the skill handler corresponding to the skill type
|
||||||
final ISkillHandler handler = SkillHandler.getInstance().getSkillHandler(skill.getSkillType());
|
final ISkillHandler handler = SkillHandler.getInstance().getSkillHandler(skill.getSkillType());
|
||||||
final List<Creature> targets = new ArrayList<>();
|
final List<Creature> targets = new ArrayList<>();
|
||||||
@@ -430,10 +429,10 @@ public class Weapon extends Item
|
|||||||
}
|
}
|
||||||
|
|
||||||
output = true;
|
output = true;
|
||||||
}
|
// }
|
||||||
catch (IOException e)
|
// catch (IOException e)
|
||||||
{
|
// {
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
return output;
|
return output;
|
||||||
|
@@ -94,7 +94,7 @@ sp_cleanup.always_use_parentheses_in_expressions=true
|
|||||||
sp_cleanup.always_use_this_for_non_static_field_access=false
|
sp_cleanup.always_use_this_for_non_static_field_access=false
|
||||||
sp_cleanup.always_use_this_for_non_static_method_access=false
|
sp_cleanup.always_use_this_for_non_static_method_access=false
|
||||||
sp_cleanup.convert_functional_interfaces=true
|
sp_cleanup.convert_functional_interfaces=true
|
||||||
sp_cleanup.convert_to_enhanced_for_loop=true
|
sp_cleanup.convert_to_enhanced_for_loop=false
|
||||||
sp_cleanup.correct_indentation=false
|
sp_cleanup.correct_indentation=false
|
||||||
sp_cleanup.format_source_code=true
|
sp_cleanup.format_source_code=true
|
||||||
sp_cleanup.format_source_code_changes_only=false
|
sp_cleanup.format_source_code_changes_only=false
|
||||||
@@ -106,18 +106,23 @@ sp_cleanup.make_type_abstract_if_missing_method=false
|
|||||||
sp_cleanup.make_variable_declarations_final=true
|
sp_cleanup.make_variable_declarations_final=true
|
||||||
sp_cleanup.never_use_blocks=false
|
sp_cleanup.never_use_blocks=false
|
||||||
sp_cleanup.never_use_parentheses_in_expressions=false
|
sp_cleanup.never_use_parentheses_in_expressions=false
|
||||||
|
sp_cleanup.number_suffix=false
|
||||||
sp_cleanup.on_save_use_additional_actions=true
|
sp_cleanup.on_save_use_additional_actions=true
|
||||||
sp_cleanup.organize_imports=true
|
sp_cleanup.organize_imports=true
|
||||||
|
sp_cleanup.push_down_negation=false
|
||||||
sp_cleanup.qualify_static_field_accesses_with_declaring_class=false
|
sp_cleanup.qualify_static_field_accesses_with_declaring_class=false
|
||||||
sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true
|
sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true
|
||||||
sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true
|
sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true
|
||||||
sp_cleanup.qualify_static_member_accesses_with_declaring_class=true
|
sp_cleanup.qualify_static_member_accesses_with_declaring_class=true
|
||||||
sp_cleanup.qualify_static_method_accesses_with_declaring_class=false
|
sp_cleanup.qualify_static_method_accesses_with_declaring_class=false
|
||||||
sp_cleanup.remove_private_constructors=true
|
sp_cleanup.remove_private_constructors=true
|
||||||
|
sp_cleanup.remove_redundant_modifiers=false
|
||||||
|
sp_cleanup.remove_redundant_semicolons=false
|
||||||
sp_cleanup.remove_redundant_type_arguments=false
|
sp_cleanup.remove_redundant_type_arguments=false
|
||||||
sp_cleanup.remove_trailing_whitespaces=false
|
sp_cleanup.remove_trailing_whitespaces=false
|
||||||
sp_cleanup.remove_trailing_whitespaces_all=true
|
sp_cleanup.remove_trailing_whitespaces_all=true
|
||||||
sp_cleanup.remove_trailing_whitespaces_ignore_empty=true
|
sp_cleanup.remove_trailing_whitespaces_ignore_empty=true
|
||||||
|
sp_cleanup.remove_unnecessary_array_creation=false
|
||||||
sp_cleanup.remove_unnecessary_casts=true
|
sp_cleanup.remove_unnecessary_casts=true
|
||||||
sp_cleanup.remove_unnecessary_nls_tags=true
|
sp_cleanup.remove_unnecessary_nls_tags=true
|
||||||
sp_cleanup.remove_unused_imports=true
|
sp_cleanup.remove_unused_imports=true
|
||||||
@@ -126,11 +131,14 @@ sp_cleanup.remove_unused_private_fields=true
|
|||||||
sp_cleanup.remove_unused_private_members=false
|
sp_cleanup.remove_unused_private_members=false
|
||||||
sp_cleanup.remove_unused_private_methods=true
|
sp_cleanup.remove_unused_private_methods=true
|
||||||
sp_cleanup.remove_unused_private_types=true
|
sp_cleanup.remove_unused_private_types=true
|
||||||
|
sp_cleanup.simplify_lambda_expression_and_method_ref=false
|
||||||
sp_cleanup.sort_members=false
|
sp_cleanup.sort_members=false
|
||||||
sp_cleanup.sort_members_all=false
|
sp_cleanup.sort_members_all=false
|
||||||
sp_cleanup.use_anonymous_class_creation=false
|
sp_cleanup.use_anonymous_class_creation=false
|
||||||
|
sp_cleanup.use_autoboxing=false
|
||||||
sp_cleanup.use_blocks=true
|
sp_cleanup.use_blocks=true
|
||||||
sp_cleanup.use_blocks_only_for_return_and_throw=false
|
sp_cleanup.use_blocks_only_for_return_and_throw=false
|
||||||
|
sp_cleanup.use_directly_map_method=false
|
||||||
sp_cleanup.use_lambda=true
|
sp_cleanup.use_lambda=true
|
||||||
sp_cleanup.use_parentheses_in_expressions=true
|
sp_cleanup.use_parentheses_in_expressions=true
|
||||||
sp_cleanup.use_this_for_non_static_field_access=false
|
sp_cleanup.use_this_for_non_static_field_access=false
|
||||||
@@ -138,3 +146,4 @@ sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true
|
|||||||
sp_cleanup.use_this_for_non_static_method_access=false
|
sp_cleanup.use_this_for_non_static_method_access=false
|
||||||
sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true
|
sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true
|
||||||
sp_cleanup.use_type_arguments=false
|
sp_cleanup.use_type_arguments=false
|
||||||
|
sp_cleanup.use_unboxing=false
|
||||||
|
@@ -16,7 +16,6 @@
|
|||||||
*/
|
*/
|
||||||
package org.l2jmobius.gameserver.handler;
|
package org.l2jmobius.gameserver.handler;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.l2jmobius.gameserver.model.Skill;
|
import org.l2jmobius.gameserver.model.Skill;
|
||||||
@@ -30,9 +29,8 @@ public interface ISkillHandler
|
|||||||
* @param creature
|
* @param creature
|
||||||
* @param skill
|
* @param skill
|
||||||
* @param targets
|
* @param targets
|
||||||
* @throws IOException
|
|
||||||
*/
|
*/
|
||||||
void useSkill(Creature creature, Skill skill, List<Creature> targets) throws IOException;
|
void useSkill(Creature creature, Skill skill, List<Creature> targets);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* this method is called at initialization to register all the item ids automatically
|
* this method is called at initialization to register all the item ids automatically
|
||||||
|
@@ -16,7 +16,6 @@
|
|||||||
*/
|
*/
|
||||||
package org.l2jmobius.gameserver.handler.skillhandlers;
|
package org.l2jmobius.gameserver.handler.skillhandlers;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
@@ -675,14 +674,14 @@ public class Disablers implements ISkillHandler
|
|||||||
final List<Creature> tgts = new ArrayList<>();
|
final List<Creature> tgts = new ArrayList<>();
|
||||||
tgts.add(target);
|
tgts.add(target);
|
||||||
|
|
||||||
try
|
// try
|
||||||
{
|
// {
|
||||||
healhandler.useSkill(creature, skill, tgts);
|
healhandler.useSkill(creature, skill, tgts);
|
||||||
}
|
// }
|
||||||
catch (IOException e)
|
// catch (IOException e)
|
||||||
{
|
// {
|
||||||
LOGGER.warning(e.getMessage());
|
// LOGGER.warning(e.getMessage());
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (String stat : negateEffectTypes)
|
for (String stat : negateEffectTypes)
|
||||||
|
@@ -115,21 +115,9 @@ public class World
|
|||||||
*/
|
*/
|
||||||
public void removeObjects(List<WorldObject> list)
|
public void removeObjects(List<WorldObject> list)
|
||||||
{
|
{
|
||||||
for (WorldObject o : list)
|
for (int i = 0; i < list.size(); i++)
|
||||||
{
|
{
|
||||||
_allObjects.remove(o.getObjectId());
|
_allObjects.remove(list.get(i).getObjectId());
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Removes the objects.
|
|
||||||
* @param objects the objects
|
|
||||||
*/
|
|
||||||
public void removeObjects(WorldObject[] objects)
|
|
||||||
{
|
|
||||||
for (WorldObject o : objects)
|
|
||||||
{
|
|
||||||
_allObjects.remove(o.getObjectId());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -138,12 +126,12 @@ public class World
|
|||||||
* <br>
|
* <br>
|
||||||
* <b><u>Example of use</u>:</b><br>
|
* <b><u>Example of use</u>:</b><br>
|
||||||
* <li>Client packets : Action, AttackRequest, RequestJoinParty, RequestJoinPledge...</li><br>
|
* <li>Client packets : Action, AttackRequest, RequestJoinParty, RequestJoinPledge...</li><br>
|
||||||
* @param oID Identifier of the WorldObject
|
* @param objectId Identifier of the WorldObject
|
||||||
* @return the object
|
* @return the object
|
||||||
*/
|
*/
|
||||||
public WorldObject findObject(int oID)
|
public WorldObject findObject(int objectId)
|
||||||
{
|
{
|
||||||
return _allObjects.get(oID);
|
return _allObjects.get(objectId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -308,12 +296,10 @@ public class World
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Go through the visible objects contained in the circular area
|
// Go through the visible objects contained in the circular area
|
||||||
for (WorldObject wo : getVisibleObjects(object, 2000))
|
final List<WorldObject> visibleObjects = getVisibleObjects(object, 2000);
|
||||||
|
for (int i = 0; i < visibleObjects.size(); i++)
|
||||||
{
|
{
|
||||||
if (wo == null)
|
final WorldObject wo = visibleObjects.get(i);
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add the object in WorldObjectHashSet(WorldObject) _knownObjects of the visible Creature according to conditions :
|
// Add the object in WorldObjectHashSet(WorldObject) _knownObjects of the visible Creature according to conditions :
|
||||||
// - Creature is visible
|
// - Creature is visible
|
||||||
@@ -342,8 +328,11 @@ public class World
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Go through the visible objects contained in the circular area
|
// Go through the visible objects contained in the circular area
|
||||||
for (WorldObject wo : getVisibleObjects(object, 2000))
|
final List<WorldObject> visibleObjects = getVisibleObjects(object, 2000);
|
||||||
|
for (int i = 0; i < visibleObjects.size(); i++)
|
||||||
{
|
{
|
||||||
|
final WorldObject wo = visibleObjects.get(i);
|
||||||
|
|
||||||
// Add the object in WorldObjectHashSet(WorldObject) _knownObjects of the visible Creature according to conditions :
|
// Add the object in WorldObjectHashSet(WorldObject) _knownObjects of the visible Creature according to conditions :
|
||||||
// - Creature is visible
|
// - Creature is visible
|
||||||
// - object is not already known
|
// - object is not already known
|
||||||
@@ -417,10 +406,14 @@ public class World
|
|||||||
oldRegion.removeVisibleObject(object);
|
oldRegion.removeVisibleObject(object);
|
||||||
|
|
||||||
// Go through all surrounding WorldRegion Creatures
|
// Go through all surrounding WorldRegion Creatures
|
||||||
for (WorldRegion worldRegion : oldRegion.getSurroundingRegions())
|
final WorldRegion[] surroundingRegions = oldRegion.getSurroundingRegions();
|
||||||
|
for (int i = 0; i < surroundingRegions.length; i++)
|
||||||
{
|
{
|
||||||
for (WorldObject wo : worldRegion.getVisibleObjects())
|
final List<WorldObject> visibleObjects = surroundingRegions[i].getVisibleObjects();
|
||||||
|
for (int j = 0; j < visibleObjects.size(); j++)
|
||||||
{
|
{
|
||||||
|
final WorldObject wo = visibleObjects.get(j);
|
||||||
|
|
||||||
// Remove the WorldObject from the WorldObjectHashSet(WorldObject) _knownObjects of the surrounding WorldRegion Creatures
|
// Remove the WorldObject from the WorldObjectHashSet(WorldObject) _knownObjects of the surrounding WorldRegion Creatures
|
||||||
// If object is a PlayerInstance, remove the WorldObject from the WorldObjectHashSet(PlayerInstance) _knownPlayer of the surrounding WorldRegion Creatures
|
// If object is a PlayerInstance, remove the WorldObject from the WorldObjectHashSet(PlayerInstance) _knownPlayer of the surrounding WorldRegion Creatures
|
||||||
// If object is targeted by one of the surrounding WorldRegion Creatures, cancel ATTACK and cast
|
// If object is targeted by one of the surrounding WorldRegion Creatures, cancel ATTACK and cast
|
||||||
@@ -489,10 +482,13 @@ public class World
|
|||||||
final List<WorldObject> result = new ArrayList<>();
|
final List<WorldObject> result = new ArrayList<>();
|
||||||
|
|
||||||
// Go through the list of region
|
// Go through the list of region
|
||||||
for (WorldRegion worldRegion : region.getSurroundingRegions())
|
final WorldRegion[] surroundingRegions = region.getSurroundingRegions();
|
||||||
|
for (int i = 0; i < surroundingRegions.length; i++)
|
||||||
{
|
{
|
||||||
for (WorldObject wo : worldRegion.getVisibleObjects())
|
final List<WorldObject> visibleObjects = surroundingRegions[i].getVisibleObjects();
|
||||||
|
for (int j = 0; j < visibleObjects.size(); j++)
|
||||||
{
|
{
|
||||||
|
final WorldObject wo = visibleObjects.get(j);
|
||||||
if (wo == null)
|
if (wo == null)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
@@ -552,11 +548,14 @@ public class World
|
|||||||
final List<WorldObject> result = new ArrayList<>();
|
final List<WorldObject> result = new ArrayList<>();
|
||||||
|
|
||||||
// Go through the list of region
|
// Go through the list of region
|
||||||
for (WorldRegion worldRegion : region.getSurroundingRegions())
|
final WorldRegion[] surroundingRegions = region.getSurroundingRegions();
|
||||||
|
for (int i = 0; i < surroundingRegions.length; i++)
|
||||||
{
|
{
|
||||||
// Go through visible objects of the selected region
|
// Go through visible objects of the selected region
|
||||||
for (WorldObject wo : worldRegion.getVisibleObjects())
|
final List<WorldObject> visibleObjects = surroundingRegions[i].getVisibleObjects();
|
||||||
|
for (int j = 0; j < visibleObjects.size(); j++)
|
||||||
{
|
{
|
||||||
|
final WorldObject wo = visibleObjects.get(j);
|
||||||
if (wo == null)
|
if (wo == null)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
@@ -614,10 +613,13 @@ public class World
|
|||||||
final List<WorldObject> result = new ArrayList<>();
|
final List<WorldObject> result = new ArrayList<>();
|
||||||
|
|
||||||
// Go through visible object of the selected region
|
// Go through visible object of the selected region
|
||||||
for (WorldRegion worldRegion : object.getWorldRegion().getSurroundingRegions())
|
final WorldRegion[] surroundingRegions = object.getWorldRegion().getSurroundingRegions();
|
||||||
|
for (int i = 0; i < surroundingRegions.length; i++)
|
||||||
{
|
{
|
||||||
for (WorldObject wo : worldRegion.getVisibleObjects())
|
final List<WorldObject> visibleObjects = surroundingRegions[i].getVisibleObjects();
|
||||||
|
for (int j = 0; j < visibleObjects.size(); j++)
|
||||||
{
|
{
|
||||||
|
final WorldObject wo = visibleObjects.get(j);
|
||||||
if (wo == null)
|
if (wo == null)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
@@ -644,58 +646,6 @@ public class World
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Return all visible players of the WorldRegion object's and of its surrounding WorldRegion.<br>
|
|
||||||
* <br>
|
|
||||||
* <b><u>Concept</u>:</b><br>
|
|
||||||
* <br>
|
|
||||||
* All visible object are identified in <b>_visibleObjects</b> of their current WorldRegion<br>
|
|
||||||
* All surrounding WorldRegion are identified in <b>_surroundingRegions</b> of the selected WorldRegion in order to scan a large area around a WorldObject<br>
|
|
||||||
* <br>
|
|
||||||
* <b><u>Example of use</u>:</b><br>
|
|
||||||
* <li>Find Close Objects for Creature</li><br>
|
|
||||||
* @param object WorldObject that determine the current WorldRegion
|
|
||||||
* @return the visible playable
|
|
||||||
*/
|
|
||||||
public List<PlayerInstance> getVisiblePlayers(WorldObject object)
|
|
||||||
{
|
|
||||||
final WorldRegion region = object.getWorldRegion();
|
|
||||||
if (region == null)
|
|
||||||
{
|
|
||||||
return Collections.emptyList();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create a list in order to contain all visible WorldObject
|
|
||||||
final List<PlayerInstance> result = new ArrayList<>();
|
|
||||||
|
|
||||||
// Go through the list of region
|
|
||||||
for (WorldRegion worldRegion : region.getSurroundingRegions())
|
|
||||||
{
|
|
||||||
// Go through visible object of the selected region
|
|
||||||
for (PlayerInstance playable : worldRegion.getAllPlayers())
|
|
||||||
{
|
|
||||||
if (playable == null)
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (playable.equals(object))
|
|
||||||
{
|
|
||||||
continue; // skip our own character
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!playable.isSpawned())
|
|
||||||
{
|
|
||||||
continue; // skip dying objects
|
|
||||||
}
|
|
||||||
|
|
||||||
result.add(playable);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Calculate the current WorldRegions of the object according to its position (x,y).<br>
|
* Calculate the current WorldRegions of the object according to its position (x,y).<br>
|
||||||
* <br>
|
* <br>
|
||||||
@@ -793,24 +743,6 @@ public class World
|
|||||||
LOGGER.info("All visible NPCs deleted.");
|
LOGGER.info("All visible NPCs deleted.");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the account players.
|
|
||||||
* @param account the account_name
|
|
||||||
* @return the account players
|
|
||||||
*/
|
|
||||||
public List<PlayerInstance> getAccountPlayers(String account)
|
|
||||||
{
|
|
||||||
final List<PlayerInstance> result = new ArrayList<>();
|
|
||||||
for (PlayerInstance actual : _allPlayers.values())
|
|
||||||
{
|
|
||||||
if (actual.getAccountName().equals(account))
|
|
||||||
{
|
|
||||||
result.add(actual);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static World getInstance()
|
public static World getInstance()
|
||||||
{
|
{
|
||||||
return SingletonHolder.INSTANCE;
|
return SingletonHolder.INSTANCE;
|
||||||
|
@@ -16,10 +16,9 @@
|
|||||||
*/
|
*/
|
||||||
package org.l2jmobius.gameserver.model;
|
package org.l2jmobius.gameserver.model;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
|
||||||
import java.util.concurrent.ScheduledFuture;
|
import java.util.concurrent.ScheduledFuture;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
@@ -31,9 +30,7 @@ import org.l2jmobius.gameserver.ai.SiegeGuardAI;
|
|||||||
import org.l2jmobius.gameserver.datatables.sql.SpawnTable;
|
import org.l2jmobius.gameserver.datatables.sql.SpawnTable;
|
||||||
import org.l2jmobius.gameserver.model.actor.Attackable;
|
import org.l2jmobius.gameserver.model.actor.Attackable;
|
||||||
import org.l2jmobius.gameserver.model.actor.Creature;
|
import org.l2jmobius.gameserver.model.actor.Creature;
|
||||||
import org.l2jmobius.gameserver.model.actor.Playable;
|
|
||||||
import org.l2jmobius.gameserver.model.actor.instance.NpcInstance;
|
import org.l2jmobius.gameserver.model.actor.instance.NpcInstance;
|
||||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
|
||||||
import org.l2jmobius.gameserver.model.spawn.Spawn;
|
import org.l2jmobius.gameserver.model.spawn.Spawn;
|
||||||
import org.l2jmobius.gameserver.model.zone.ZoneManager;
|
import org.l2jmobius.gameserver.model.zone.ZoneManager;
|
||||||
import org.l2jmobius.gameserver.model.zone.ZoneType;
|
import org.l2jmobius.gameserver.model.zone.ZoneType;
|
||||||
@@ -44,8 +41,7 @@ public class WorldRegion
|
|||||||
{
|
{
|
||||||
private static final Logger LOGGER = Logger.getLogger(WorldRegion.class.getName());
|
private static final Logger LOGGER = Logger.getLogger(WorldRegion.class.getName());
|
||||||
|
|
||||||
private final Collection<PlayerInstance> _playerObjects = ConcurrentHashMap.newKeySet();
|
private final List<WorldObject> _visibleObjects = new ArrayList<>();
|
||||||
private final Collection<WorldObject> _visibleObjects = ConcurrentHashMap.newKeySet();
|
|
||||||
private WorldRegion[] _surroundingRegions;
|
private WorldRegion[] _surroundingRegions;
|
||||||
private final int _regionX;
|
private final int _regionX;
|
||||||
private final int _regionY;
|
private final int _regionY;
|
||||||
@@ -74,7 +70,6 @@ public class WorldRegion
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
_zoneManager.unregisterZone(zone);
|
_zoneManager.unregisterZone(zone);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -127,8 +122,9 @@ public class WorldRegion
|
|||||||
{
|
{
|
||||||
if (!isOn)
|
if (!isOn)
|
||||||
{
|
{
|
||||||
for (WorldObject wo : _visibleObjects)
|
for (int i = 0; i < _visibleObjects.size(); i++)
|
||||||
{
|
{
|
||||||
|
final WorldObject wo = _visibleObjects.get(i);
|
||||||
if (wo instanceof Attackable)
|
if (wo instanceof Attackable)
|
||||||
{
|
{
|
||||||
final Attackable mob = (Attackable) wo;
|
final Attackable mob = (Attackable) wo;
|
||||||
@@ -174,8 +170,9 @@ public class WorldRegion
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for (WorldObject wo : _visibleObjects)
|
for (int i = 0; i < _visibleObjects.size(); i++)
|
||||||
{
|
{
|
||||||
|
final WorldObject wo = _visibleObjects.get(i);
|
||||||
if (wo instanceof Attackable)
|
if (wo instanceof Attackable)
|
||||||
{
|
{
|
||||||
// Start HP/MP/CP Regeneration task
|
// Start HP/MP/CP Regeneration task
|
||||||
@@ -190,22 +187,30 @@ public class WorldRegion
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Boolean isActive()
|
public boolean isActive()
|
||||||
{
|
{
|
||||||
return _active;
|
return _active;
|
||||||
}
|
}
|
||||||
|
|
||||||
// check if all 9 neighbors (including self) are inactive or active but with no players.
|
// check if all 9 neighbors (including self) are inactive or active but with no players.
|
||||||
// returns true if the above condition is met.
|
// returns true if the above condition is met.
|
||||||
public Boolean areNeighborsEmpty()
|
public boolean areNeighborsEmpty()
|
||||||
{
|
{
|
||||||
for (WorldRegion worldRegion : _surroundingRegions)
|
for (int i = 0; i < _surroundingRegions.length; i++)
|
||||||
{
|
{
|
||||||
if (worldRegion.isActive() && !worldRegion.getAllPlayers().isEmpty())
|
final WorldRegion worldRegion = _surroundingRegions[i];
|
||||||
|
if (worldRegion.isActive())
|
||||||
|
{
|
||||||
|
final List<WorldObject> regionObjects = worldRegion.getVisibleObjects();
|
||||||
|
for (int j = 0; j < regionObjects.size(); j++)
|
||||||
|
{
|
||||||
|
if (regionObjects.get(j).isPlayable())
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -246,9 +251,9 @@ public class WorldRegion
|
|||||||
// Then, set a timer to activate the neighbors.
|
// Then, set a timer to activate the neighbors.
|
||||||
_neighborsTask = ThreadPool.schedule(() ->
|
_neighborsTask = ThreadPool.schedule(() ->
|
||||||
{
|
{
|
||||||
for (WorldRegion worldRegion : _surroundingRegions)
|
for (int i = 0; i < _surroundingRegions.length; i++)
|
||||||
{
|
{
|
||||||
worldRegion.setActive(true);
|
_surroundingRegions[i].setActive(true);
|
||||||
}
|
}
|
||||||
}, 1000 * Config.GRID_NEIGHBOR_TURNON_TIME);
|
}, 1000 * Config.GRID_NEIGHBOR_TURNON_TIME);
|
||||||
}
|
}
|
||||||
@@ -272,8 +277,9 @@ public class WorldRegion
|
|||||||
// Suggest means: first check if a neighbor has PlayerInstances in it. If not, deactivate.
|
// Suggest means: first check if a neighbor has PlayerInstances in it. If not, deactivate.
|
||||||
_neighborsTask = ThreadPool.schedule(() ->
|
_neighborsTask = ThreadPool.schedule(() ->
|
||||||
{
|
{
|
||||||
for (WorldRegion worldRegion : _surroundingRegions)
|
for (int i = 0; i < _surroundingRegions.length; i++)
|
||||||
{
|
{
|
||||||
|
final WorldRegion worldRegion = _surroundingRegions[i];
|
||||||
if (worldRegion.areNeighborsEmpty())
|
if (worldRegion.areNeighborsEmpty())
|
||||||
{
|
{
|
||||||
worldRegion.setActive(false);
|
worldRegion.setActive(false);
|
||||||
@@ -296,19 +302,20 @@ public class WorldRegion
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
_visibleObjects.add(object);
|
synchronized (_visibleObjects)
|
||||||
|
|
||||||
if (object instanceof PlayerInstance)
|
|
||||||
{
|
{
|
||||||
_playerObjects.add((PlayerInstance) object);
|
if (!_visibleObjects.contains(object))
|
||||||
|
{
|
||||||
|
_visibleObjects.add(object);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// if this is the first player to enter the region, activate self & neighbors
|
// If this is the first player to enter the region, activate self and neighbors.
|
||||||
if ((_playerObjects.size() == 1) && !Config.GRIDS_ALWAYS_ON)
|
if (object.isPlayable() && !_active && !Config.GRIDS_ALWAYS_ON)
|
||||||
{
|
{
|
||||||
startActivation();
|
startActivation();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove the WorldObject from the WorldObjectHashSet(WorldObject) _visibleObjects in this WorldRegion<br>
|
* Remove the WorldObject from the WorldObjectHashSet(WorldObject) _visibleObjects in this WorldRegion<br>
|
||||||
@@ -323,22 +330,36 @@ public class WorldRegion
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
_visibleObjects.remove(object);
|
if (_visibleObjects.isEmpty())
|
||||||
|
|
||||||
if (object instanceof Playable)
|
|
||||||
{
|
{
|
||||||
_playerObjects.remove(object);
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (_playerObjects.isEmpty() && !Config.GRIDS_ALWAYS_ON)
|
synchronized (_visibleObjects)
|
||||||
|
{
|
||||||
|
_visibleObjects.remove(object);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (object.isPlayable() && areNeighborsEmpty() && !Config.GRIDS_ALWAYS_ON)
|
||||||
{
|
{
|
||||||
startDeactivation();
|
startDeactivation();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public void setSurroundingRegions(WorldRegion[] regions)
|
public void setSurroundingRegions(WorldRegion[] regions)
|
||||||
{
|
{
|
||||||
_surroundingRegions = regions;
|
_surroundingRegions = regions;
|
||||||
|
|
||||||
|
// Make sure that this region is always the first region to improve bulk operations when this region should be updated first.
|
||||||
|
for (int i = 0; i < _surroundingRegions.length; i++)
|
||||||
|
{
|
||||||
|
if (_surroundingRegions[i] == this)
|
||||||
|
{
|
||||||
|
final WorldRegion first = _surroundingRegions[0];
|
||||||
|
_surroundingRegions[0] = this;
|
||||||
|
_surroundingRegions[i] = first;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -349,12 +370,7 @@ public class WorldRegion
|
|||||||
return _surroundingRegions;
|
return _surroundingRegions;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Collection<PlayerInstance> getAllPlayers()
|
public List<WorldObject> getVisibleObjects()
|
||||||
{
|
|
||||||
return _playerObjects;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Collection<WorldObject> getVisibleObjects()
|
|
||||||
{
|
{
|
||||||
return _visibleObjects;
|
return _visibleObjects;
|
||||||
}
|
}
|
||||||
@@ -370,8 +386,9 @@ public class WorldRegion
|
|||||||
public synchronized void deleteVisibleNpcSpawns()
|
public synchronized void deleteVisibleNpcSpawns()
|
||||||
{
|
{
|
||||||
LOGGER.info("Deleting all visible NPCs in Region: " + getName());
|
LOGGER.info("Deleting all visible NPCs in Region: " + getName());
|
||||||
for (WorldObject obj : _visibleObjects)
|
for (int i = 0; i < _visibleObjects.size(); i++)
|
||||||
{
|
{
|
||||||
|
final WorldObject obj = _visibleObjects.get(i);
|
||||||
if (obj instanceof NpcInstance)
|
if (obj instanceof NpcInstance)
|
||||||
{
|
{
|
||||||
final NpcInstance target = (NpcInstance) obj;
|
final NpcInstance target = (NpcInstance) obj;
|
||||||
@@ -404,8 +421,10 @@ public class WorldRegion
|
|||||||
final int down = y - range;
|
final int down = y - range;
|
||||||
final int left = x + range;
|
final int left = x + range;
|
||||||
final int right = x - range;
|
final int right = x - range;
|
||||||
for (ZoneType e : _zoneManager.getZones())
|
final List<ZoneType> zones = _zoneManager.getZones();
|
||||||
|
for (int i = 0; i < zones.size(); i++)
|
||||||
{
|
{
|
||||||
|
final ZoneType e = zones.get(i);
|
||||||
if (e instanceof PeaceZone)
|
if (e instanceof PeaceZone)
|
||||||
{
|
{
|
||||||
if (e.isInsideZone(x, up, z))
|
if (e.isInsideZone(x, up, z))
|
||||||
|
@@ -2796,17 +2796,17 @@ public abstract class Creature extends WorldObject implements ISkillsHolder
|
|||||||
@Override
|
@Override
|
||||||
public void run()
|
public void run()
|
||||||
{
|
{
|
||||||
try
|
// try
|
||||||
{
|
// {
|
||||||
if (_creature != null)
|
if (_creature != null)
|
||||||
{
|
{
|
||||||
_creature.enableSkill(_skill);
|
_creature.enableSkill(_skill);
|
||||||
}
|
}
|
||||||
}
|
// }
|
||||||
catch (Throwable e)
|
// catch (Throwable e)
|
||||||
{
|
// {
|
||||||
LOGGER.warning(e.getMessage());
|
// LOGGER.warning(e.getMessage());
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2850,14 +2850,14 @@ public abstract class Creature extends WorldObject implements ISkillsHolder
|
|||||||
@Override
|
@Override
|
||||||
public void run()
|
public void run()
|
||||||
{
|
{
|
||||||
try
|
// try
|
||||||
{
|
// {
|
||||||
onHitTimer(_hitTarget, _damage, _crit, _miss, _soulshot, _shld);
|
onHitTimer(_hitTarget, _damage, _crit, _miss, _soulshot, _shld);
|
||||||
}
|
// }
|
||||||
catch (Throwable e)
|
// catch (Throwable e)
|
||||||
{
|
// {
|
||||||
LOGGER.warning("fixme:hit task unhandled exception " + e);
|
// LOGGER.warning("fixme:hit task unhandled exception " + e);
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2950,14 +2950,14 @@ public abstract class Creature extends WorldObject implements ISkillsHolder
|
|||||||
@Override
|
@Override
|
||||||
public void run()
|
public void run()
|
||||||
{
|
{
|
||||||
try
|
// try
|
||||||
{
|
// {
|
||||||
_currPlayer.useMagic(_queuedSkill, _isCtrlPressed, _isShiftPressed);
|
_currPlayer.useMagic(_queuedSkill, _isCtrlPressed, _isShiftPressed);
|
||||||
}
|
// }
|
||||||
catch (Throwable e)
|
// catch (Throwable e)
|
||||||
{
|
// {
|
||||||
LOGGER.warning(e.getMessage());
|
// LOGGER.warning(e.getMessage());
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2980,14 +2980,14 @@ public abstract class Creature extends WorldObject implements ISkillsHolder
|
|||||||
@Override
|
@Override
|
||||||
public void run()
|
public void run()
|
||||||
{
|
{
|
||||||
try
|
// try
|
||||||
{
|
// {
|
||||||
getAI().notifyEvent(_evt, null);
|
getAI().notifyEvent(_evt, null);
|
||||||
}
|
// }
|
||||||
catch (Throwable t)
|
// catch (Throwable t)
|
||||||
{
|
// {
|
||||||
LOGGER.warning(t.getMessage());
|
// LOGGER.warning(t.getMessage());
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2999,8 +2999,8 @@ public abstract class Creature extends WorldObject implements ISkillsHolder
|
|||||||
@Override
|
@Override
|
||||||
public void run()
|
public void run()
|
||||||
{
|
{
|
||||||
try
|
// try
|
||||||
{
|
// {
|
||||||
if (System.currentTimeMillis() > _pvpFlagLasts)
|
if (System.currentTimeMillis() > _pvpFlagLasts)
|
||||||
{
|
{
|
||||||
stopPvPFlag();
|
stopPvPFlag();
|
||||||
@@ -3013,11 +3013,11 @@ public abstract class Creature extends WorldObject implements ISkillsHolder
|
|||||||
{
|
{
|
||||||
updatePvPFlag(1);
|
updatePvPFlag(1);
|
||||||
}
|
}
|
||||||
}
|
// }
|
||||||
catch (Exception e)
|
// catch (Exception e)
|
||||||
{
|
// {
|
||||||
LOGGER.warning("error in pvp flag task: " + e);
|
// LOGGER.warning("error in pvp flag task: " + e);
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4736,14 +4736,14 @@ public abstract class Creature extends WorldObject implements ISkillsHolder
|
|||||||
{
|
{
|
||||||
for (PlayerInstance player : getKnownList().getKnownPlayers().values())
|
for (PlayerInstance player : getKnownList().getKnownPlayers().values())
|
||||||
{
|
{
|
||||||
try
|
// try
|
||||||
{
|
// {
|
||||||
player.sendPacket(su);
|
player.sendPacket(su);
|
||||||
}
|
// }
|
||||||
catch (NullPointerException e)
|
// catch (NullPointerException e)
|
||||||
{
|
// {
|
||||||
LOGGER.warning(e.toString());
|
// LOGGER.warning(e.toString());
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -5555,18 +5555,18 @@ public abstract class Creature extends WorldObject implements ISkillsHolder
|
|||||||
final int gty = (originalY - World.MAP_MIN_Y) >> 4;
|
final int gty = (originalY - World.MAP_MIN_Y) >> 4;
|
||||||
if (isOnGeodataPath())
|
if (isOnGeodataPath())
|
||||||
{
|
{
|
||||||
try
|
// try
|
||||||
{
|
// {
|
||||||
if ((gtx == _move.geoPathGtx) && (gty == _move.geoPathGty))
|
if ((gtx == _move.geoPathGtx) && (gty == _move.geoPathGty))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_move.onGeodataPathIndex = -1; // Set not on geodata path.
|
_move.onGeodataPathIndex = -1; // Set not on geodata path.
|
||||||
}
|
// }
|
||||||
catch (NullPointerException e)
|
// catch (NullPointerException e)
|
||||||
{
|
// {
|
||||||
// nothing
|
// // nothing
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
// Temporary fix for character outside world region errors (should not happen)
|
// Temporary fix for character outside world region errors (should not happen)
|
||||||
@@ -7382,8 +7382,8 @@ public abstract class Creature extends WorldObject implements ISkillsHolder
|
|||||||
}
|
}
|
||||||
|
|
||||||
final List<Creature> targets2 = targets;
|
final List<Creature> targets2 = targets;
|
||||||
try
|
// try
|
||||||
{
|
// {
|
||||||
if ((targets2 != null) && !targets2.isEmpty())
|
if ((targets2 != null) && !targets2.isEmpty())
|
||||||
{
|
{
|
||||||
// Go through targets table
|
// Go through targets table
|
||||||
@@ -7426,14 +7426,14 @@ public abstract class Creature extends WorldObject implements ISkillsHolder
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
// }
|
||||||
catch (Exception e)
|
// catch (Exception e)
|
||||||
{
|
// {
|
||||||
LOGGER.warning(e.toString());
|
// LOGGER.warning(e.toString());
|
||||||
}
|
// }
|
||||||
|
|
||||||
try
|
// try
|
||||||
{
|
// {
|
||||||
final StatusUpdate su = new StatusUpdate(getObjectId());
|
final StatusUpdate su = new StatusUpdate(getObjectId());
|
||||||
boolean isSendStatus = false;
|
boolean isSendStatus = false;
|
||||||
|
|
||||||
@@ -7487,11 +7487,11 @@ public abstract class Creature extends WorldObject implements ISkillsHolder
|
|||||||
|
|
||||||
// Launch the magic skill in order to calculate its effects
|
// Launch the magic skill in order to calculate its effects
|
||||||
callSkill(skill, targets);
|
callSkill(skill, targets);
|
||||||
}
|
// }
|
||||||
catch (Exception e)
|
// catch (Exception e)
|
||||||
{
|
// {
|
||||||
LOGGER.warning(e.toString());
|
// LOGGER.warning(e.toString());
|
||||||
}
|
// }
|
||||||
|
|
||||||
if (instant || (coolTime == 0))
|
if (instant || (coolTime == 0))
|
||||||
{
|
{
|
||||||
@@ -7609,8 +7609,8 @@ public abstract class Creature extends WorldObject implements ISkillsHolder
|
|||||||
// Launch weapon Special ability skill effect if available
|
// Launch weapon Special ability skill effect if available
|
||||||
if (activeWeapon != null)
|
if (activeWeapon != null)
|
||||||
{
|
{
|
||||||
try
|
// try
|
||||||
{
|
// {
|
||||||
if (targets != null)
|
if (targets != null)
|
||||||
{
|
{
|
||||||
for (WorldObject target : targets)
|
for (WorldObject target : targets)
|
||||||
@@ -7621,11 +7621,11 @@ public abstract class Creature extends WorldObject implements ISkillsHolder
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
// }
|
||||||
catch (Exception e)
|
// catch (Exception e)
|
||||||
{
|
// {
|
||||||
LOGGER.warning(e.toString());
|
// LOGGER.warning(e.toString());
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -7804,8 +7804,8 @@ public abstract class Creature extends WorldObject implements ISkillsHolder
|
|||||||
*/
|
*/
|
||||||
public void callSkill(Skill skill, List<Creature> targets)
|
public void callSkill(Skill skill, List<Creature> targets)
|
||||||
{
|
{
|
||||||
try
|
// try
|
||||||
{
|
// {
|
||||||
if (skill.isToggle() && (getFirstEffect(skill.getId()) != null))
|
if (skill.isToggle() && (getFirstEffect(skill.getId()) != null))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
@@ -8162,11 +8162,11 @@ public abstract class Creature extends WorldObject implements ISkillsHolder
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
// }
|
||||||
catch (Exception e)
|
// catch (Exception e)
|
||||||
{
|
// {
|
||||||
LOGGER.warning(e.getMessage());
|
// LOGGER.warning(e.getMessage());
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -141,9 +141,9 @@ public class WorldObjectKnownList
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Go through all visible WorldObject near the Creature
|
// Go through all visible WorldObject near the Creature
|
||||||
for (WorldObject playable : World.getInstance().getVisiblePlayers(_activeObject))
|
for (WorldObject object : World.getInstance().getVisibleObjects(_activeObject))
|
||||||
{
|
{
|
||||||
if (playable == null)
|
if ((object == null) || !object.isPlayable())
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -151,7 +151,7 @@ public class WorldObjectKnownList
|
|||||||
// Try to add object to active object's known objects
|
// Try to add object to active object's known objects
|
||||||
// Creature only needs to see visible PlayerInstance and PlayableInstance, when moving. Other creatures are currently only known from initial spawn area.
|
// Creature only needs to see visible PlayerInstance and PlayableInstance, when moving. Other creatures are currently only known from initial spawn area.
|
||||||
// Possibly look into getDistanceToForgetObject values before modifying this approach...
|
// Possibly look into getDistanceToForgetObject values before modifying this approach...
|
||||||
addKnownObject(playable);
|
addKnownObject(object);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -16,7 +16,6 @@
|
|||||||
*/
|
*/
|
||||||
package org.l2jmobius.gameserver.model.items;
|
package org.l2jmobius.gameserver.model.items;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -404,8 +403,8 @@ public class Weapon extends Item
|
|||||||
continue; // Skill condition not met
|
continue; // Skill condition not met
|
||||||
}
|
}
|
||||||
|
|
||||||
try
|
// try
|
||||||
{
|
// {
|
||||||
// Get the skill handler corresponding to the skill type
|
// Get the skill handler corresponding to the skill type
|
||||||
final ISkillHandler handler = SkillHandler.getInstance().getSkillHandler(skill.getSkillType());
|
final ISkillHandler handler = SkillHandler.getInstance().getSkillHandler(skill.getSkillType());
|
||||||
final List<Creature> targets = new ArrayList<>();
|
final List<Creature> targets = new ArrayList<>();
|
||||||
@@ -430,10 +429,10 @@ public class Weapon extends Item
|
|||||||
}
|
}
|
||||||
|
|
||||||
output = true;
|
output = true;
|
||||||
}
|
// }
|
||||||
catch (IOException e)
|
// catch (IOException e)
|
||||||
{
|
// {
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
return output;
|
return output;
|
||||||
|
@@ -94,7 +94,7 @@ sp_cleanup.always_use_parentheses_in_expressions=true
|
|||||||
sp_cleanup.always_use_this_for_non_static_field_access=false
|
sp_cleanup.always_use_this_for_non_static_field_access=false
|
||||||
sp_cleanup.always_use_this_for_non_static_method_access=false
|
sp_cleanup.always_use_this_for_non_static_method_access=false
|
||||||
sp_cleanup.convert_functional_interfaces=true
|
sp_cleanup.convert_functional_interfaces=true
|
||||||
sp_cleanup.convert_to_enhanced_for_loop=true
|
sp_cleanup.convert_to_enhanced_for_loop=false
|
||||||
sp_cleanup.correct_indentation=false
|
sp_cleanup.correct_indentation=false
|
||||||
sp_cleanup.format_source_code=true
|
sp_cleanup.format_source_code=true
|
||||||
sp_cleanup.format_source_code_changes_only=false
|
sp_cleanup.format_source_code_changes_only=false
|
||||||
@@ -106,18 +106,23 @@ sp_cleanup.make_type_abstract_if_missing_method=false
|
|||||||
sp_cleanup.make_variable_declarations_final=true
|
sp_cleanup.make_variable_declarations_final=true
|
||||||
sp_cleanup.never_use_blocks=false
|
sp_cleanup.never_use_blocks=false
|
||||||
sp_cleanup.never_use_parentheses_in_expressions=false
|
sp_cleanup.never_use_parentheses_in_expressions=false
|
||||||
|
sp_cleanup.number_suffix=false
|
||||||
sp_cleanup.on_save_use_additional_actions=true
|
sp_cleanup.on_save_use_additional_actions=true
|
||||||
sp_cleanup.organize_imports=true
|
sp_cleanup.organize_imports=true
|
||||||
|
sp_cleanup.push_down_negation=false
|
||||||
sp_cleanup.qualify_static_field_accesses_with_declaring_class=false
|
sp_cleanup.qualify_static_field_accesses_with_declaring_class=false
|
||||||
sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true
|
sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true
|
||||||
sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true
|
sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true
|
||||||
sp_cleanup.qualify_static_member_accesses_with_declaring_class=true
|
sp_cleanup.qualify_static_member_accesses_with_declaring_class=true
|
||||||
sp_cleanup.qualify_static_method_accesses_with_declaring_class=false
|
sp_cleanup.qualify_static_method_accesses_with_declaring_class=false
|
||||||
sp_cleanup.remove_private_constructors=true
|
sp_cleanup.remove_private_constructors=true
|
||||||
|
sp_cleanup.remove_redundant_modifiers=false
|
||||||
|
sp_cleanup.remove_redundant_semicolons=false
|
||||||
sp_cleanup.remove_redundant_type_arguments=false
|
sp_cleanup.remove_redundant_type_arguments=false
|
||||||
sp_cleanup.remove_trailing_whitespaces=false
|
sp_cleanup.remove_trailing_whitespaces=false
|
||||||
sp_cleanup.remove_trailing_whitespaces_all=true
|
sp_cleanup.remove_trailing_whitespaces_all=true
|
||||||
sp_cleanup.remove_trailing_whitespaces_ignore_empty=true
|
sp_cleanup.remove_trailing_whitespaces_ignore_empty=true
|
||||||
|
sp_cleanup.remove_unnecessary_array_creation=false
|
||||||
sp_cleanup.remove_unnecessary_casts=true
|
sp_cleanup.remove_unnecessary_casts=true
|
||||||
sp_cleanup.remove_unnecessary_nls_tags=true
|
sp_cleanup.remove_unnecessary_nls_tags=true
|
||||||
sp_cleanup.remove_unused_imports=true
|
sp_cleanup.remove_unused_imports=true
|
||||||
@@ -126,11 +131,14 @@ sp_cleanup.remove_unused_private_fields=true
|
|||||||
sp_cleanup.remove_unused_private_members=false
|
sp_cleanup.remove_unused_private_members=false
|
||||||
sp_cleanup.remove_unused_private_methods=true
|
sp_cleanup.remove_unused_private_methods=true
|
||||||
sp_cleanup.remove_unused_private_types=true
|
sp_cleanup.remove_unused_private_types=true
|
||||||
|
sp_cleanup.simplify_lambda_expression_and_method_ref=false
|
||||||
sp_cleanup.sort_members=false
|
sp_cleanup.sort_members=false
|
||||||
sp_cleanup.sort_members_all=false
|
sp_cleanup.sort_members_all=false
|
||||||
sp_cleanup.use_anonymous_class_creation=false
|
sp_cleanup.use_anonymous_class_creation=false
|
||||||
|
sp_cleanup.use_autoboxing=false
|
||||||
sp_cleanup.use_blocks=true
|
sp_cleanup.use_blocks=true
|
||||||
sp_cleanup.use_blocks_only_for_return_and_throw=false
|
sp_cleanup.use_blocks_only_for_return_and_throw=false
|
||||||
|
sp_cleanup.use_directly_map_method=false
|
||||||
sp_cleanup.use_lambda=true
|
sp_cleanup.use_lambda=true
|
||||||
sp_cleanup.use_parentheses_in_expressions=true
|
sp_cleanup.use_parentheses_in_expressions=true
|
||||||
sp_cleanup.use_this_for_non_static_field_access=false
|
sp_cleanup.use_this_for_non_static_field_access=false
|
||||||
@@ -138,3 +146,4 @@ sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true
|
|||||||
sp_cleanup.use_this_for_non_static_method_access=false
|
sp_cleanup.use_this_for_non_static_method_access=false
|
||||||
sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true
|
sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true
|
||||||
sp_cleanup.use_type_arguments=false
|
sp_cleanup.use_type_arguments=false
|
||||||
|
sp_cleanup.use_unboxing=false
|
||||||
|
@@ -402,10 +402,13 @@ public class World
|
|||||||
oldRegion.removeVisibleObject(object);
|
oldRegion.removeVisibleObject(object);
|
||||||
|
|
||||||
// Go through all surrounding WorldRegion Creatures
|
// Go through all surrounding WorldRegion Creatures
|
||||||
for (WorldRegion worldRegion : oldRegion.getSurroundingRegions())
|
final WorldRegion[] surroundingRegions = oldRegion.getSurroundingRegions();
|
||||||
|
for (int i = 0; i < surroundingRegions.length; i++)
|
||||||
{
|
{
|
||||||
for (WorldObject wo : worldRegion.getVisibleObjects().values())
|
final List<WorldObject> visibleObjects = surroundingRegions[i].getVisibleObjects();
|
||||||
|
for (int j = 0; j < visibleObjects.size(); j++)
|
||||||
{
|
{
|
||||||
|
final WorldObject wo = visibleObjects.get(j);
|
||||||
if (wo == object)
|
if (wo == object)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
@@ -462,15 +465,19 @@ public class World
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (WorldRegion worldRegion : oldRegion.getSurroundingRegions())
|
final WorldRegion[] oldSurroundingRegions = oldRegion.getSurroundingRegions();
|
||||||
|
for (int i = 0; i < oldSurroundingRegions.length; i++)
|
||||||
{
|
{
|
||||||
|
final WorldRegion worldRegion = oldSurroundingRegions[i];
|
||||||
if (newRegion.isSurroundingRegion(worldRegion))
|
if (newRegion.isSurroundingRegion(worldRegion))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (WorldObject wo : worldRegion.getVisibleObjects().values())
|
final List<WorldObject> visibleObjects = worldRegion.getVisibleObjects();
|
||||||
|
for (int j = 0; j < visibleObjects.size(); j++)
|
||||||
{
|
{
|
||||||
|
final WorldObject wo = visibleObjects.get(j);
|
||||||
if (wo == object)
|
if (wo == object)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
@@ -518,15 +525,19 @@ public class World
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (WorldRegion worldRegion : newRegion.getSurroundingRegions())
|
final WorldRegion[] newSurroundingRegions = newRegion.getSurroundingRegions();
|
||||||
|
for (int i = 0; i < newSurroundingRegions.length; i++)
|
||||||
{
|
{
|
||||||
|
final WorldRegion worldRegion = newSurroundingRegions[i];
|
||||||
if (oldRegion.isSurroundingRegion(worldRegion))
|
if (oldRegion.isSurroundingRegion(worldRegion))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (WorldObject wo : worldRegion.getVisibleObjects().values())
|
final List<WorldObject> visibleObjects = worldRegion.getVisibleObjects();
|
||||||
|
for (int j = 0; j < visibleObjects.size(); j++)
|
||||||
{
|
{
|
||||||
|
final WorldObject wo = visibleObjects.get(j);
|
||||||
if ((wo == object) || (wo.getInstanceId() != object.getInstanceId()))
|
if ((wo == object) || (wo.getInstanceId() != object.getInstanceId()))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
@@ -606,27 +617,30 @@ public class World
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final WorldRegion centerWorldRegion = getRegion(object);
|
final WorldRegion worldRegion = getRegion(object);
|
||||||
if (centerWorldRegion == null)
|
if (worldRegion == null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (WorldRegion region : centerWorldRegion.getSurroundingRegions())
|
final WorldRegion[] surroundingRegions = worldRegion.getSurroundingRegions();
|
||||||
|
for (int i = 0; i < surroundingRegions.length; i++)
|
||||||
{
|
{
|
||||||
for (WorldObject visibleObject : region.getVisibleObjects().values())
|
final List<WorldObject> visibleObjects = surroundingRegions[i].getVisibleObjects();
|
||||||
|
for (int j = 0; j < visibleObjects.size(); j++)
|
||||||
{
|
{
|
||||||
if ((visibleObject == null) || (visibleObject == object) || !clazz.isInstance(visibleObject))
|
final WorldObject wo = visibleObjects.get(j);
|
||||||
|
if ((wo == null) || (wo == object) || !clazz.isInstance(wo))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (visibleObject.getInstanceId() != object.getInstanceId())
|
if (wo.getInstanceId() != object.getInstanceId())
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
c.accept(clazz.cast(visibleObject));
|
c.accept(clazz.cast(wo));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -658,29 +672,32 @@ public class World
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final WorldRegion centerWorldRegion = getRegion(object);
|
final WorldRegion worldRegion = getRegion(object);
|
||||||
if (centerWorldRegion == null)
|
if (worldRegion == null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (WorldRegion region : centerWorldRegion.getSurroundingRegions())
|
final WorldRegion[] surroundingRegions = worldRegion.getSurroundingRegions();
|
||||||
|
for (int i = 0; i < surroundingRegions.length; i++)
|
||||||
{
|
{
|
||||||
for (WorldObject visibleObject : region.getVisibleObjects().values())
|
final List<WorldObject> visibleObjects = surroundingRegions[i].getVisibleObjects();
|
||||||
|
for (int j = 0; j < visibleObjects.size(); j++)
|
||||||
{
|
{
|
||||||
if ((visibleObject == null) || (visibleObject == object) || !clazz.isInstance(visibleObject))
|
final WorldObject wo = visibleObjects.get(j);
|
||||||
|
if ((wo == null) || (wo == object) || !clazz.isInstance(wo))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (visibleObject.getInstanceId() != object.getInstanceId())
|
if (wo.getInstanceId() != object.getInstanceId())
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (visibleObject.calculateDistance3D(object) <= range)
|
if (wo.calculateDistance3D(object) <= range)
|
||||||
{
|
{
|
||||||
c.accept(clazz.cast(visibleObject));
|
c.accept(clazz.cast(wo));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -16,8 +16,8 @@
|
|||||||
*/
|
*/
|
||||||
package org.l2jmobius.gameserver.model;
|
package org.l2jmobius.gameserver.model;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.ArrayList;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.List;
|
||||||
import java.util.concurrent.ScheduledFuture;
|
import java.util.concurrent.ScheduledFuture;
|
||||||
|
|
||||||
import org.l2jmobius.Config;
|
import org.l2jmobius.Config;
|
||||||
@@ -28,9 +28,9 @@ import org.l2jmobius.gameserver.taskmanager.RandomAnimationTaskManager;
|
|||||||
|
|
||||||
public class WorldRegion
|
public class WorldRegion
|
||||||
{
|
{
|
||||||
/** Map containing visible objects in this world region. */
|
/** List containing visible objects in this world region. */
|
||||||
private final Map<Integer, WorldObject> _visibleObjects = new ConcurrentHashMap<>();
|
private final List<WorldObject> _visibleObjects = new ArrayList<>();
|
||||||
/** Map containing nearby regions forming this world region's effective area. */
|
/** Array containing nearby regions forming this world region's effective area. */
|
||||||
private WorldRegion[] _surroundingRegions;
|
private WorldRegion[] _surroundingRegions;
|
||||||
private final int _regionX;
|
private final int _regionX;
|
||||||
private final int _regionY;
|
private final int _regionY;
|
||||||
@@ -52,8 +52,9 @@ public class WorldRegion
|
|||||||
|
|
||||||
if (!isOn)
|
if (!isOn)
|
||||||
{
|
{
|
||||||
for (WorldObject wo : _visibleObjects.values())
|
for (int i = 0; i < _visibleObjects.size(); i++)
|
||||||
{
|
{
|
||||||
|
final WorldObject wo = _visibleObjects.get(i);
|
||||||
if (wo.isAttackable())
|
if (wo.isAttackable())
|
||||||
{
|
{
|
||||||
final Attackable mob = (Attackable) wo;
|
final Attackable mob = (Attackable) wo;
|
||||||
@@ -87,15 +88,16 @@ public class WorldRegion
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for (WorldObject wo : _visibleObjects.values())
|
for (int i = 0; i < _visibleObjects.size(); i++)
|
||||||
{
|
{
|
||||||
|
final WorldObject wo = _visibleObjects.get(i);
|
||||||
if (wo.isAttackable())
|
if (wo.isAttackable())
|
||||||
{
|
{
|
||||||
// Start HP/MP/CP regeneration task.
|
// Start HP/MP/CP regeneration task.
|
||||||
((Attackable) wo).getStatus().startHpMpRegeneration();
|
((Attackable) wo).getStatus().startHpMpRegeneration();
|
||||||
RandomAnimationTaskManager.getInstance().add((Npc) wo);
|
RandomAnimationTaskManager.getInstance().add((Npc) wo);
|
||||||
}
|
}
|
||||||
else if (wo instanceof Npc)
|
else if (wo.isNpc())
|
||||||
{
|
{
|
||||||
RandomAnimationTaskManager.getInstance().add((Npc) wo);
|
RandomAnimationTaskManager.getInstance().add((Npc) wo);
|
||||||
}
|
}
|
||||||
@@ -110,13 +112,21 @@ public class WorldRegion
|
|||||||
|
|
||||||
public boolean areNeighborsEmpty()
|
public boolean areNeighborsEmpty()
|
||||||
{
|
{
|
||||||
for (WorldRegion worldRegion : _surroundingRegions)
|
for (int i = 0; i < _surroundingRegions.length; i++)
|
||||||
{
|
{
|
||||||
if (worldRegion.isActive() && worldRegion.getVisibleObjects().values().stream().anyMatch(WorldObject::isPlayable))
|
final WorldRegion worldRegion = _surroundingRegions[i];
|
||||||
|
if (worldRegion.isActive())
|
||||||
|
{
|
||||||
|
final List<WorldObject> regionObjects = worldRegion.getVisibleObjects();
|
||||||
|
for (int j = 0; j < regionObjects.size(); j++)
|
||||||
|
{
|
||||||
|
if (regionObjects.get(j).isPlayable())
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -157,9 +167,9 @@ public class WorldRegion
|
|||||||
// Then, set a timer to activate the neighbors.
|
// Then, set a timer to activate the neighbors.
|
||||||
_neighborsTask = ThreadPool.schedule(() ->
|
_neighborsTask = ThreadPool.schedule(() ->
|
||||||
{
|
{
|
||||||
for (WorldRegion worldRegion : _surroundingRegions)
|
for (int i = 0; i < _surroundingRegions.length; i++)
|
||||||
{
|
{
|
||||||
worldRegion.setActive(true);
|
_surroundingRegions[i].setActive(true);
|
||||||
}
|
}
|
||||||
}, 1000 * Config.GRID_NEIGHBOR_TURNON_TIME);
|
}, 1000 * Config.GRID_NEIGHBOR_TURNON_TIME);
|
||||||
}
|
}
|
||||||
@@ -183,8 +193,9 @@ public class WorldRegion
|
|||||||
// Suggest means: first check if a neighbor has PlayerInstances in it. If not, deactivate.
|
// Suggest means: first check if a neighbor has PlayerInstances in it. If not, deactivate.
|
||||||
_neighborsTask = ThreadPool.schedule(() ->
|
_neighborsTask = ThreadPool.schedule(() ->
|
||||||
{
|
{
|
||||||
for (WorldRegion worldRegion : _surroundingRegions)
|
for (int i = 0; i < _surroundingRegions.length; i++)
|
||||||
{
|
{
|
||||||
|
final WorldRegion worldRegion = _surroundingRegions[i];
|
||||||
if (worldRegion.areNeighborsEmpty())
|
if (worldRegion.areNeighborsEmpty())
|
||||||
{
|
{
|
||||||
worldRegion.setActive(false);
|
worldRegion.setActive(false);
|
||||||
@@ -206,7 +217,13 @@ public class WorldRegion
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
_visibleObjects.put(object.getObjectId(), object);
|
synchronized (_visibleObjects)
|
||||||
|
{
|
||||||
|
if (!_visibleObjects.contains(object))
|
||||||
|
{
|
||||||
|
_visibleObjects.add(object);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// If this is the first player to enter the region, activate self and neighbors.
|
// If this is the first player to enter the region, activate self and neighbors.
|
||||||
if (object.isPlayable() && !_active && !Config.GRIDS_ALWAYS_ON)
|
if (object.isPlayable() && !_active && !Config.GRIDS_ALWAYS_ON)
|
||||||
@@ -230,7 +247,11 @@ public class WorldRegion
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_visibleObjects.remove(object.getObjectId());
|
|
||||||
|
synchronized (_visibleObjects)
|
||||||
|
{
|
||||||
|
_visibleObjects.remove(object);
|
||||||
|
}
|
||||||
|
|
||||||
if (object.isPlayable() && areNeighborsEmpty() && !Config.GRIDS_ALWAYS_ON)
|
if (object.isPlayable() && areNeighborsEmpty() && !Config.GRIDS_ALWAYS_ON)
|
||||||
{
|
{
|
||||||
@@ -238,7 +259,7 @@ public class WorldRegion
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<Integer, WorldObject> getVisibleObjects()
|
public List<WorldObject> getVisibleObjects()
|
||||||
{
|
{
|
||||||
return _visibleObjects;
|
return _visibleObjects;
|
||||||
}
|
}
|
||||||
|
@@ -94,7 +94,7 @@ sp_cleanup.always_use_parentheses_in_expressions=true
|
|||||||
sp_cleanup.always_use_this_for_non_static_field_access=false
|
sp_cleanup.always_use_this_for_non_static_field_access=false
|
||||||
sp_cleanup.always_use_this_for_non_static_method_access=false
|
sp_cleanup.always_use_this_for_non_static_method_access=false
|
||||||
sp_cleanup.convert_functional_interfaces=true
|
sp_cleanup.convert_functional_interfaces=true
|
||||||
sp_cleanup.convert_to_enhanced_for_loop=true
|
sp_cleanup.convert_to_enhanced_for_loop=false
|
||||||
sp_cleanup.correct_indentation=false
|
sp_cleanup.correct_indentation=false
|
||||||
sp_cleanup.format_source_code=true
|
sp_cleanup.format_source_code=true
|
||||||
sp_cleanup.format_source_code_changes_only=false
|
sp_cleanup.format_source_code_changes_only=false
|
||||||
@@ -106,18 +106,23 @@ sp_cleanup.make_type_abstract_if_missing_method=false
|
|||||||
sp_cleanup.make_variable_declarations_final=true
|
sp_cleanup.make_variable_declarations_final=true
|
||||||
sp_cleanup.never_use_blocks=false
|
sp_cleanup.never_use_blocks=false
|
||||||
sp_cleanup.never_use_parentheses_in_expressions=false
|
sp_cleanup.never_use_parentheses_in_expressions=false
|
||||||
|
sp_cleanup.number_suffix=false
|
||||||
sp_cleanup.on_save_use_additional_actions=true
|
sp_cleanup.on_save_use_additional_actions=true
|
||||||
sp_cleanup.organize_imports=true
|
sp_cleanup.organize_imports=true
|
||||||
|
sp_cleanup.push_down_negation=false
|
||||||
sp_cleanup.qualify_static_field_accesses_with_declaring_class=false
|
sp_cleanup.qualify_static_field_accesses_with_declaring_class=false
|
||||||
sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true
|
sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true
|
||||||
sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true
|
sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true
|
||||||
sp_cleanup.qualify_static_member_accesses_with_declaring_class=true
|
sp_cleanup.qualify_static_member_accesses_with_declaring_class=true
|
||||||
sp_cleanup.qualify_static_method_accesses_with_declaring_class=false
|
sp_cleanup.qualify_static_method_accesses_with_declaring_class=false
|
||||||
sp_cleanup.remove_private_constructors=true
|
sp_cleanup.remove_private_constructors=true
|
||||||
|
sp_cleanup.remove_redundant_modifiers=false
|
||||||
|
sp_cleanup.remove_redundant_semicolons=false
|
||||||
sp_cleanup.remove_redundant_type_arguments=false
|
sp_cleanup.remove_redundant_type_arguments=false
|
||||||
sp_cleanup.remove_trailing_whitespaces=false
|
sp_cleanup.remove_trailing_whitespaces=false
|
||||||
sp_cleanup.remove_trailing_whitespaces_all=true
|
sp_cleanup.remove_trailing_whitespaces_all=true
|
||||||
sp_cleanup.remove_trailing_whitespaces_ignore_empty=true
|
sp_cleanup.remove_trailing_whitespaces_ignore_empty=true
|
||||||
|
sp_cleanup.remove_unnecessary_array_creation=false
|
||||||
sp_cleanup.remove_unnecessary_casts=true
|
sp_cleanup.remove_unnecessary_casts=true
|
||||||
sp_cleanup.remove_unnecessary_nls_tags=true
|
sp_cleanup.remove_unnecessary_nls_tags=true
|
||||||
sp_cleanup.remove_unused_imports=true
|
sp_cleanup.remove_unused_imports=true
|
||||||
@@ -126,11 +131,14 @@ sp_cleanup.remove_unused_private_fields=true
|
|||||||
sp_cleanup.remove_unused_private_members=false
|
sp_cleanup.remove_unused_private_members=false
|
||||||
sp_cleanup.remove_unused_private_methods=true
|
sp_cleanup.remove_unused_private_methods=true
|
||||||
sp_cleanup.remove_unused_private_types=true
|
sp_cleanup.remove_unused_private_types=true
|
||||||
|
sp_cleanup.simplify_lambda_expression_and_method_ref=false
|
||||||
sp_cleanup.sort_members=false
|
sp_cleanup.sort_members=false
|
||||||
sp_cleanup.sort_members_all=false
|
sp_cleanup.sort_members_all=false
|
||||||
sp_cleanup.use_anonymous_class_creation=false
|
sp_cleanup.use_anonymous_class_creation=false
|
||||||
|
sp_cleanup.use_autoboxing=false
|
||||||
sp_cleanup.use_blocks=true
|
sp_cleanup.use_blocks=true
|
||||||
sp_cleanup.use_blocks_only_for_return_and_throw=false
|
sp_cleanup.use_blocks_only_for_return_and_throw=false
|
||||||
|
sp_cleanup.use_directly_map_method=false
|
||||||
sp_cleanup.use_lambda=true
|
sp_cleanup.use_lambda=true
|
||||||
sp_cleanup.use_parentheses_in_expressions=true
|
sp_cleanup.use_parentheses_in_expressions=true
|
||||||
sp_cleanup.use_this_for_non_static_field_access=false
|
sp_cleanup.use_this_for_non_static_field_access=false
|
||||||
@@ -138,3 +146,4 @@ sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true
|
|||||||
sp_cleanup.use_this_for_non_static_method_access=false
|
sp_cleanup.use_this_for_non_static_method_access=false
|
||||||
sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true
|
sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true
|
||||||
sp_cleanup.use_type_arguments=false
|
sp_cleanup.use_type_arguments=false
|
||||||
|
sp_cleanup.use_unboxing=false
|
||||||
|
@@ -402,10 +402,13 @@ public class World
|
|||||||
oldRegion.removeVisibleObject(object);
|
oldRegion.removeVisibleObject(object);
|
||||||
|
|
||||||
// Go through all surrounding WorldRegion Creatures
|
// Go through all surrounding WorldRegion Creatures
|
||||||
for (WorldRegion worldRegion : oldRegion.getSurroundingRegions())
|
final WorldRegion[] surroundingRegions = oldRegion.getSurroundingRegions();
|
||||||
|
for (int i = 0; i < surroundingRegions.length; i++)
|
||||||
{
|
{
|
||||||
for (WorldObject wo : worldRegion.getVisibleObjects().values())
|
final List<WorldObject> visibleObjects = surroundingRegions[i].getVisibleObjects();
|
||||||
|
for (int j = 0; j < visibleObjects.size(); j++)
|
||||||
{
|
{
|
||||||
|
final WorldObject wo = visibleObjects.get(j);
|
||||||
if (wo == object)
|
if (wo == object)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
@@ -462,15 +465,19 @@ public class World
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (WorldRegion worldRegion : oldRegion.getSurroundingRegions())
|
final WorldRegion[] oldSurroundingRegions = oldRegion.getSurroundingRegions();
|
||||||
|
for (int i = 0; i < oldSurroundingRegions.length; i++)
|
||||||
{
|
{
|
||||||
|
final WorldRegion worldRegion = oldSurroundingRegions[i];
|
||||||
if (newRegion.isSurroundingRegion(worldRegion))
|
if (newRegion.isSurroundingRegion(worldRegion))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (WorldObject wo : worldRegion.getVisibleObjects().values())
|
final List<WorldObject> visibleObjects = worldRegion.getVisibleObjects();
|
||||||
|
for (int j = 0; j < visibleObjects.size(); j++)
|
||||||
{
|
{
|
||||||
|
final WorldObject wo = visibleObjects.get(j);
|
||||||
if (wo == object)
|
if (wo == object)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
@@ -518,15 +525,19 @@ public class World
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (WorldRegion worldRegion : newRegion.getSurroundingRegions())
|
final WorldRegion[] newSurroundingRegions = newRegion.getSurroundingRegions();
|
||||||
|
for (int i = 0; i < newSurroundingRegions.length; i++)
|
||||||
{
|
{
|
||||||
|
final WorldRegion worldRegion = newSurroundingRegions[i];
|
||||||
if (oldRegion.isSurroundingRegion(worldRegion))
|
if (oldRegion.isSurroundingRegion(worldRegion))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (WorldObject wo : worldRegion.getVisibleObjects().values())
|
final List<WorldObject> visibleObjects = worldRegion.getVisibleObjects();
|
||||||
|
for (int j = 0; j < visibleObjects.size(); j++)
|
||||||
{
|
{
|
||||||
|
final WorldObject wo = visibleObjects.get(j);
|
||||||
if ((wo == object) || (wo.getInstanceId() != object.getInstanceId()))
|
if ((wo == object) || (wo.getInstanceId() != object.getInstanceId()))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
@@ -606,27 +617,30 @@ public class World
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final WorldRegion centerWorldRegion = getRegion(object);
|
final WorldRegion worldRegion = getRegion(object);
|
||||||
if (centerWorldRegion == null)
|
if (worldRegion == null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (WorldRegion region : centerWorldRegion.getSurroundingRegions())
|
final WorldRegion[] surroundingRegions = worldRegion.getSurroundingRegions();
|
||||||
|
for (int i = 0; i < surroundingRegions.length; i++)
|
||||||
{
|
{
|
||||||
for (WorldObject visibleObject : region.getVisibleObjects().values())
|
final List<WorldObject> visibleObjects = surroundingRegions[i].getVisibleObjects();
|
||||||
|
for (int j = 0; j < visibleObjects.size(); j++)
|
||||||
{
|
{
|
||||||
if ((visibleObject == null) || (visibleObject == object) || !clazz.isInstance(visibleObject))
|
final WorldObject wo = visibleObjects.get(j);
|
||||||
|
if ((wo == null) || (wo == object) || !clazz.isInstance(wo))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (visibleObject.getInstanceId() != object.getInstanceId())
|
if (wo.getInstanceId() != object.getInstanceId())
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
c.accept(clazz.cast(visibleObject));
|
c.accept(clazz.cast(wo));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -658,29 +672,32 @@ public class World
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final WorldRegion centerWorldRegion = getRegion(object);
|
final WorldRegion worldRegion = getRegion(object);
|
||||||
if (centerWorldRegion == null)
|
if (worldRegion == null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (WorldRegion region : centerWorldRegion.getSurroundingRegions())
|
final WorldRegion[] surroundingRegions = worldRegion.getSurroundingRegions();
|
||||||
|
for (int i = 0; i < surroundingRegions.length; i++)
|
||||||
{
|
{
|
||||||
for (WorldObject visibleObject : region.getVisibleObjects().values())
|
final List<WorldObject> visibleObjects = surroundingRegions[i].getVisibleObjects();
|
||||||
|
for (int j = 0; j < visibleObjects.size(); j++)
|
||||||
{
|
{
|
||||||
if ((visibleObject == null) || (visibleObject == object) || !clazz.isInstance(visibleObject))
|
final WorldObject wo = visibleObjects.get(j);
|
||||||
|
if ((wo == null) || (wo == object) || !clazz.isInstance(wo))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (visibleObject.getInstanceId() != object.getInstanceId())
|
if (wo.getInstanceId() != object.getInstanceId())
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (visibleObject.calculateDistance3D(object) <= range)
|
if (wo.calculateDistance3D(object) <= range)
|
||||||
{
|
{
|
||||||
c.accept(clazz.cast(visibleObject));
|
c.accept(clazz.cast(wo));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -16,8 +16,8 @@
|
|||||||
*/
|
*/
|
||||||
package org.l2jmobius.gameserver.model;
|
package org.l2jmobius.gameserver.model;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.ArrayList;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.List;
|
||||||
import java.util.concurrent.ScheduledFuture;
|
import java.util.concurrent.ScheduledFuture;
|
||||||
|
|
||||||
import org.l2jmobius.Config;
|
import org.l2jmobius.Config;
|
||||||
@@ -28,9 +28,9 @@ import org.l2jmobius.gameserver.taskmanager.RandomAnimationTaskManager;
|
|||||||
|
|
||||||
public class WorldRegion
|
public class WorldRegion
|
||||||
{
|
{
|
||||||
/** Map containing visible objects in this world region. */
|
/** List containing visible objects in this world region. */
|
||||||
private final Map<Integer, WorldObject> _visibleObjects = new ConcurrentHashMap<>();
|
private final List<WorldObject> _visibleObjects = new ArrayList<>();
|
||||||
/** Map containing nearby regions forming this world region's effective area. */
|
/** Array containing nearby regions forming this world region's effective area. */
|
||||||
private WorldRegion[] _surroundingRegions;
|
private WorldRegion[] _surroundingRegions;
|
||||||
private final int _regionX;
|
private final int _regionX;
|
||||||
private final int _regionY;
|
private final int _regionY;
|
||||||
@@ -52,8 +52,9 @@ public class WorldRegion
|
|||||||
|
|
||||||
if (!isOn)
|
if (!isOn)
|
||||||
{
|
{
|
||||||
for (WorldObject wo : _visibleObjects.values())
|
for (int i = 0; i < _visibleObjects.size(); i++)
|
||||||
{
|
{
|
||||||
|
final WorldObject wo = _visibleObjects.get(i);
|
||||||
if (wo.isAttackable())
|
if (wo.isAttackable())
|
||||||
{
|
{
|
||||||
final Attackable mob = (Attackable) wo;
|
final Attackable mob = (Attackable) wo;
|
||||||
@@ -87,15 +88,16 @@ public class WorldRegion
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for (WorldObject wo : _visibleObjects.values())
|
for (int i = 0; i < _visibleObjects.size(); i++)
|
||||||
{
|
{
|
||||||
|
final WorldObject wo = _visibleObjects.get(i);
|
||||||
if (wo.isAttackable())
|
if (wo.isAttackable())
|
||||||
{
|
{
|
||||||
// Start HP/MP/CP regeneration task.
|
// Start HP/MP/CP regeneration task.
|
||||||
((Attackable) wo).getStatus().startHpMpRegeneration();
|
((Attackable) wo).getStatus().startHpMpRegeneration();
|
||||||
RandomAnimationTaskManager.getInstance().add((Npc) wo);
|
RandomAnimationTaskManager.getInstance().add((Npc) wo);
|
||||||
}
|
}
|
||||||
else if (wo instanceof Npc)
|
else if (wo.isNpc())
|
||||||
{
|
{
|
||||||
RandomAnimationTaskManager.getInstance().add((Npc) wo);
|
RandomAnimationTaskManager.getInstance().add((Npc) wo);
|
||||||
}
|
}
|
||||||
@@ -110,13 +112,21 @@ public class WorldRegion
|
|||||||
|
|
||||||
public boolean areNeighborsEmpty()
|
public boolean areNeighborsEmpty()
|
||||||
{
|
{
|
||||||
for (WorldRegion worldRegion : _surroundingRegions)
|
for (int i = 0; i < _surroundingRegions.length; i++)
|
||||||
{
|
{
|
||||||
if (worldRegion.isActive() && worldRegion.getVisibleObjects().values().stream().anyMatch(WorldObject::isPlayable))
|
final WorldRegion worldRegion = _surroundingRegions[i];
|
||||||
|
if (worldRegion.isActive())
|
||||||
|
{
|
||||||
|
final List<WorldObject> regionObjects = worldRegion.getVisibleObjects();
|
||||||
|
for (int j = 0; j < regionObjects.size(); j++)
|
||||||
|
{
|
||||||
|
if (regionObjects.get(j).isPlayable())
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -157,9 +167,9 @@ public class WorldRegion
|
|||||||
// Then, set a timer to activate the neighbors.
|
// Then, set a timer to activate the neighbors.
|
||||||
_neighborsTask = ThreadPool.schedule(() ->
|
_neighborsTask = ThreadPool.schedule(() ->
|
||||||
{
|
{
|
||||||
for (WorldRegion worldRegion : _surroundingRegions)
|
for (int i = 0; i < _surroundingRegions.length; i++)
|
||||||
{
|
{
|
||||||
worldRegion.setActive(true);
|
_surroundingRegions[i].setActive(true);
|
||||||
}
|
}
|
||||||
}, 1000 * Config.GRID_NEIGHBOR_TURNON_TIME);
|
}, 1000 * Config.GRID_NEIGHBOR_TURNON_TIME);
|
||||||
}
|
}
|
||||||
@@ -183,8 +193,9 @@ public class WorldRegion
|
|||||||
// Suggest means: first check if a neighbor has PlayerInstances in it. If not, deactivate.
|
// Suggest means: first check if a neighbor has PlayerInstances in it. If not, deactivate.
|
||||||
_neighborsTask = ThreadPool.schedule(() ->
|
_neighborsTask = ThreadPool.schedule(() ->
|
||||||
{
|
{
|
||||||
for (WorldRegion worldRegion : _surroundingRegions)
|
for (int i = 0; i < _surroundingRegions.length; i++)
|
||||||
{
|
{
|
||||||
|
final WorldRegion worldRegion = _surroundingRegions[i];
|
||||||
if (worldRegion.areNeighborsEmpty())
|
if (worldRegion.areNeighborsEmpty())
|
||||||
{
|
{
|
||||||
worldRegion.setActive(false);
|
worldRegion.setActive(false);
|
||||||
@@ -206,7 +217,13 @@ public class WorldRegion
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
_visibleObjects.put(object.getObjectId(), object);
|
synchronized (_visibleObjects)
|
||||||
|
{
|
||||||
|
if (!_visibleObjects.contains(object))
|
||||||
|
{
|
||||||
|
_visibleObjects.add(object);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// If this is the first player to enter the region, activate self and neighbors.
|
// If this is the first player to enter the region, activate self and neighbors.
|
||||||
if (object.isPlayable() && !_active && !Config.GRIDS_ALWAYS_ON)
|
if (object.isPlayable() && !_active && !Config.GRIDS_ALWAYS_ON)
|
||||||
@@ -230,7 +247,11 @@ public class WorldRegion
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_visibleObjects.remove(object.getObjectId());
|
|
||||||
|
synchronized (_visibleObjects)
|
||||||
|
{
|
||||||
|
_visibleObjects.remove(object);
|
||||||
|
}
|
||||||
|
|
||||||
if (object.isPlayable() && areNeighborsEmpty() && !Config.GRIDS_ALWAYS_ON)
|
if (object.isPlayable() && areNeighborsEmpty() && !Config.GRIDS_ALWAYS_ON)
|
||||||
{
|
{
|
||||||
@@ -238,7 +259,7 @@ public class WorldRegion
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<Integer, WorldObject> getVisibleObjects()
|
public List<WorldObject> getVisibleObjects()
|
||||||
{
|
{
|
||||||
return _visibleObjects;
|
return _visibleObjects;
|
||||||
}
|
}
|
||||||
|
@@ -94,7 +94,7 @@ sp_cleanup.always_use_parentheses_in_expressions=true
|
|||||||
sp_cleanup.always_use_this_for_non_static_field_access=false
|
sp_cleanup.always_use_this_for_non_static_field_access=false
|
||||||
sp_cleanup.always_use_this_for_non_static_method_access=false
|
sp_cleanup.always_use_this_for_non_static_method_access=false
|
||||||
sp_cleanup.convert_functional_interfaces=true
|
sp_cleanup.convert_functional_interfaces=true
|
||||||
sp_cleanup.convert_to_enhanced_for_loop=true
|
sp_cleanup.convert_to_enhanced_for_loop=false
|
||||||
sp_cleanup.correct_indentation=false
|
sp_cleanup.correct_indentation=false
|
||||||
sp_cleanup.format_source_code=true
|
sp_cleanup.format_source_code=true
|
||||||
sp_cleanup.format_source_code_changes_only=false
|
sp_cleanup.format_source_code_changes_only=false
|
||||||
@@ -106,18 +106,23 @@ sp_cleanup.make_type_abstract_if_missing_method=false
|
|||||||
sp_cleanup.make_variable_declarations_final=true
|
sp_cleanup.make_variable_declarations_final=true
|
||||||
sp_cleanup.never_use_blocks=false
|
sp_cleanup.never_use_blocks=false
|
||||||
sp_cleanup.never_use_parentheses_in_expressions=false
|
sp_cleanup.never_use_parentheses_in_expressions=false
|
||||||
|
sp_cleanup.number_suffix=false
|
||||||
sp_cleanup.on_save_use_additional_actions=true
|
sp_cleanup.on_save_use_additional_actions=true
|
||||||
sp_cleanup.organize_imports=true
|
sp_cleanup.organize_imports=true
|
||||||
|
sp_cleanup.push_down_negation=false
|
||||||
sp_cleanup.qualify_static_field_accesses_with_declaring_class=false
|
sp_cleanup.qualify_static_field_accesses_with_declaring_class=false
|
||||||
sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true
|
sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true
|
||||||
sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true
|
sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true
|
||||||
sp_cleanup.qualify_static_member_accesses_with_declaring_class=true
|
sp_cleanup.qualify_static_member_accesses_with_declaring_class=true
|
||||||
sp_cleanup.qualify_static_method_accesses_with_declaring_class=false
|
sp_cleanup.qualify_static_method_accesses_with_declaring_class=false
|
||||||
sp_cleanup.remove_private_constructors=true
|
sp_cleanup.remove_private_constructors=true
|
||||||
|
sp_cleanup.remove_redundant_modifiers=false
|
||||||
|
sp_cleanup.remove_redundant_semicolons=false
|
||||||
sp_cleanup.remove_redundant_type_arguments=false
|
sp_cleanup.remove_redundant_type_arguments=false
|
||||||
sp_cleanup.remove_trailing_whitespaces=false
|
sp_cleanup.remove_trailing_whitespaces=false
|
||||||
sp_cleanup.remove_trailing_whitespaces_all=true
|
sp_cleanup.remove_trailing_whitespaces_all=true
|
||||||
sp_cleanup.remove_trailing_whitespaces_ignore_empty=true
|
sp_cleanup.remove_trailing_whitespaces_ignore_empty=true
|
||||||
|
sp_cleanup.remove_unnecessary_array_creation=false
|
||||||
sp_cleanup.remove_unnecessary_casts=true
|
sp_cleanup.remove_unnecessary_casts=true
|
||||||
sp_cleanup.remove_unnecessary_nls_tags=true
|
sp_cleanup.remove_unnecessary_nls_tags=true
|
||||||
sp_cleanup.remove_unused_imports=true
|
sp_cleanup.remove_unused_imports=true
|
||||||
@@ -126,11 +131,14 @@ sp_cleanup.remove_unused_private_fields=true
|
|||||||
sp_cleanup.remove_unused_private_members=false
|
sp_cleanup.remove_unused_private_members=false
|
||||||
sp_cleanup.remove_unused_private_methods=true
|
sp_cleanup.remove_unused_private_methods=true
|
||||||
sp_cleanup.remove_unused_private_types=true
|
sp_cleanup.remove_unused_private_types=true
|
||||||
|
sp_cleanup.simplify_lambda_expression_and_method_ref=false
|
||||||
sp_cleanup.sort_members=false
|
sp_cleanup.sort_members=false
|
||||||
sp_cleanup.sort_members_all=false
|
sp_cleanup.sort_members_all=false
|
||||||
sp_cleanup.use_anonymous_class_creation=false
|
sp_cleanup.use_anonymous_class_creation=false
|
||||||
|
sp_cleanup.use_autoboxing=false
|
||||||
sp_cleanup.use_blocks=true
|
sp_cleanup.use_blocks=true
|
||||||
sp_cleanup.use_blocks_only_for_return_and_throw=false
|
sp_cleanup.use_blocks_only_for_return_and_throw=false
|
||||||
|
sp_cleanup.use_directly_map_method=false
|
||||||
sp_cleanup.use_lambda=true
|
sp_cleanup.use_lambda=true
|
||||||
sp_cleanup.use_parentheses_in_expressions=true
|
sp_cleanup.use_parentheses_in_expressions=true
|
||||||
sp_cleanup.use_this_for_non_static_field_access=false
|
sp_cleanup.use_this_for_non_static_field_access=false
|
||||||
@@ -138,3 +146,4 @@ sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true
|
|||||||
sp_cleanup.use_this_for_non_static_method_access=false
|
sp_cleanup.use_this_for_non_static_method_access=false
|
||||||
sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true
|
sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true
|
||||||
sp_cleanup.use_type_arguments=false
|
sp_cleanup.use_type_arguments=false
|
||||||
|
sp_cleanup.use_unboxing=false
|
||||||
|
@@ -406,10 +406,13 @@ public class World
|
|||||||
oldRegion.removeVisibleObject(object);
|
oldRegion.removeVisibleObject(object);
|
||||||
|
|
||||||
// Go through all surrounding WorldRegion Creatures
|
// Go through all surrounding WorldRegion Creatures
|
||||||
for (WorldRegion worldRegion : oldRegion.getSurroundingRegions())
|
final WorldRegion[] surroundingRegions = oldRegion.getSurroundingRegions();
|
||||||
|
for (int i = 0; i < surroundingRegions.length; i++)
|
||||||
{
|
{
|
||||||
for (WorldObject wo : worldRegion.getVisibleObjects().values())
|
final List<WorldObject> visibleObjects = surroundingRegions[i].getVisibleObjects();
|
||||||
|
for (int j = 0; j < visibleObjects.size(); j++)
|
||||||
{
|
{
|
||||||
|
final WorldObject wo = visibleObjects.get(j);
|
||||||
if (wo == object)
|
if (wo == object)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
@@ -466,15 +469,19 @@ public class World
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (WorldRegion worldRegion : oldRegion.getSurroundingRegions())
|
final WorldRegion[] oldSurroundingRegions = oldRegion.getSurroundingRegions();
|
||||||
|
for (int i = 0; i < oldSurroundingRegions.length; i++)
|
||||||
{
|
{
|
||||||
|
final WorldRegion worldRegion = oldSurroundingRegions[i];
|
||||||
if (newRegion.isSurroundingRegion(worldRegion))
|
if (newRegion.isSurroundingRegion(worldRegion))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (WorldObject wo : worldRegion.getVisibleObjects().values())
|
final List<WorldObject> visibleObjects = worldRegion.getVisibleObjects();
|
||||||
|
for (int j = 0; j < visibleObjects.size(); j++)
|
||||||
{
|
{
|
||||||
|
final WorldObject wo = visibleObjects.get(j);
|
||||||
if (wo == object)
|
if (wo == object)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
@@ -522,15 +529,19 @@ public class World
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (WorldRegion worldRegion : newRegion.getSurroundingRegions())
|
final WorldRegion[] newSurroundingRegions = newRegion.getSurroundingRegions();
|
||||||
|
for (int i = 0; i < newSurroundingRegions.length; i++)
|
||||||
{
|
{
|
||||||
|
final WorldRegion worldRegion = newSurroundingRegions[i];
|
||||||
if (oldRegion.isSurroundingRegion(worldRegion))
|
if (oldRegion.isSurroundingRegion(worldRegion))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (WorldObject wo : worldRegion.getVisibleObjects().values())
|
final List<WorldObject> visibleObjects = worldRegion.getVisibleObjects();
|
||||||
|
for (int j = 0; j < visibleObjects.size(); j++)
|
||||||
{
|
{
|
||||||
|
final WorldObject wo = visibleObjects.get(j);
|
||||||
if ((wo == object) || (wo.getInstanceWorld() != object.getInstanceWorld()))
|
if ((wo == object) || (wo.getInstanceWorld() != object.getInstanceWorld()))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
@@ -610,27 +621,30 @@ public class World
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final WorldRegion centerWorldRegion = getRegion(object);
|
final WorldRegion worldRegion = getRegion(object);
|
||||||
if (centerWorldRegion == null)
|
if (worldRegion == null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (WorldRegion region : centerWorldRegion.getSurroundingRegions())
|
final WorldRegion[] surroundingRegions = worldRegion.getSurroundingRegions();
|
||||||
|
for (int i = 0; i < surroundingRegions.length; i++)
|
||||||
{
|
{
|
||||||
for (WorldObject visibleObject : region.getVisibleObjects().values())
|
final List<WorldObject> visibleObjects = surroundingRegions[i].getVisibleObjects();
|
||||||
|
for (int j = 0; j < visibleObjects.size(); j++)
|
||||||
{
|
{
|
||||||
if ((visibleObject == null) || (visibleObject == object) || !clazz.isInstance(visibleObject))
|
final WorldObject wo = visibleObjects.get(j);
|
||||||
|
if ((wo == null) || (wo == object) || !clazz.isInstance(wo))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (visibleObject.getInstanceWorld() != object.getInstanceWorld())
|
if (wo.getInstanceWorld() != object.getInstanceWorld())
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
c.accept(clazz.cast(visibleObject));
|
c.accept(clazz.cast(wo));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -662,29 +676,32 @@ public class World
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final WorldRegion centerWorldRegion = getRegion(object);
|
final WorldRegion worldRegion = getRegion(object);
|
||||||
if (centerWorldRegion == null)
|
if (worldRegion == null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (WorldRegion region : centerWorldRegion.getSurroundingRegions())
|
final WorldRegion[] surroundingRegions = worldRegion.getSurroundingRegions();
|
||||||
|
for (int i = 0; i < surroundingRegions.length; i++)
|
||||||
{
|
{
|
||||||
for (WorldObject visibleObject : region.getVisibleObjects().values())
|
final List<WorldObject> visibleObjects = surroundingRegions[i].getVisibleObjects();
|
||||||
|
for (int j = 0; j < visibleObjects.size(); j++)
|
||||||
{
|
{
|
||||||
if ((visibleObject == null) || (visibleObject == object) || !clazz.isInstance(visibleObject))
|
final WorldObject wo = visibleObjects.get(j);
|
||||||
|
if ((wo == null) || (wo == object) || !clazz.isInstance(wo))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (visibleObject.getInstanceWorld() != object.getInstanceWorld())
|
if (wo.getInstanceWorld() != object.getInstanceWorld())
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (visibleObject.calculateDistance3D(object) <= range)
|
if (wo.calculateDistance3D(object) <= range)
|
||||||
{
|
{
|
||||||
c.accept(clazz.cast(visibleObject));
|
c.accept(clazz.cast(wo));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -16,8 +16,8 @@
|
|||||||
*/
|
*/
|
||||||
package org.l2jmobius.gameserver.model;
|
package org.l2jmobius.gameserver.model;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.ArrayList;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.List;
|
||||||
import java.util.concurrent.ScheduledFuture;
|
import java.util.concurrent.ScheduledFuture;
|
||||||
|
|
||||||
import org.l2jmobius.Config;
|
import org.l2jmobius.Config;
|
||||||
@@ -28,9 +28,9 @@ import org.l2jmobius.gameserver.taskmanager.RandomAnimationTaskManager;
|
|||||||
|
|
||||||
public class WorldRegion
|
public class WorldRegion
|
||||||
{
|
{
|
||||||
/** Map containing visible objects in this world region. */
|
/** List containing visible objects in this world region. */
|
||||||
private final Map<Integer, WorldObject> _visibleObjects = new ConcurrentHashMap<>();
|
private final List<WorldObject> _visibleObjects = new ArrayList<>();
|
||||||
/** Map containing nearby regions forming this world region's effective area. */
|
/** Array containing nearby regions forming this world region's effective area. */
|
||||||
private WorldRegion[] _surroundingRegions;
|
private WorldRegion[] _surroundingRegions;
|
||||||
private final int _regionX;
|
private final int _regionX;
|
||||||
private final int _regionY;
|
private final int _regionY;
|
||||||
@@ -52,8 +52,9 @@ public class WorldRegion
|
|||||||
|
|
||||||
if (!isOn)
|
if (!isOn)
|
||||||
{
|
{
|
||||||
for (WorldObject wo : _visibleObjects.values())
|
for (int i = 0; i < _visibleObjects.size(); i++)
|
||||||
{
|
{
|
||||||
|
final WorldObject wo = _visibleObjects.get(i);
|
||||||
if (wo.isAttackable())
|
if (wo.isAttackable())
|
||||||
{
|
{
|
||||||
final Attackable mob = (Attackable) wo;
|
final Attackable mob = (Attackable) wo;
|
||||||
@@ -87,15 +88,16 @@ public class WorldRegion
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for (WorldObject wo : _visibleObjects.values())
|
for (int i = 0; i < _visibleObjects.size(); i++)
|
||||||
{
|
{
|
||||||
|
final WorldObject wo = _visibleObjects.get(i);
|
||||||
if (wo.isAttackable())
|
if (wo.isAttackable())
|
||||||
{
|
{
|
||||||
// Start HP/MP/CP regeneration task.
|
// Start HP/MP/CP regeneration task.
|
||||||
((Attackable) wo).getStatus().startHpMpRegeneration();
|
((Attackable) wo).getStatus().startHpMpRegeneration();
|
||||||
RandomAnimationTaskManager.getInstance().add((Npc) wo);
|
RandomAnimationTaskManager.getInstance().add((Npc) wo);
|
||||||
}
|
}
|
||||||
else if (wo instanceof Npc)
|
else if (wo.isNpc())
|
||||||
{
|
{
|
||||||
RandomAnimationTaskManager.getInstance().add((Npc) wo);
|
RandomAnimationTaskManager.getInstance().add((Npc) wo);
|
||||||
}
|
}
|
||||||
@@ -110,13 +112,21 @@ public class WorldRegion
|
|||||||
|
|
||||||
public boolean areNeighborsEmpty()
|
public boolean areNeighborsEmpty()
|
||||||
{
|
{
|
||||||
for (WorldRegion worldRegion : _surroundingRegions)
|
for (int i = 0; i < _surroundingRegions.length; i++)
|
||||||
{
|
{
|
||||||
if (worldRegion.isActive() && worldRegion.getVisibleObjects().values().stream().anyMatch(WorldObject::isPlayable))
|
final WorldRegion worldRegion = _surroundingRegions[i];
|
||||||
|
if (worldRegion.isActive())
|
||||||
|
{
|
||||||
|
final List<WorldObject> regionObjects = worldRegion.getVisibleObjects();
|
||||||
|
for (int j = 0; j < regionObjects.size(); j++)
|
||||||
|
{
|
||||||
|
if (regionObjects.get(j).isPlayable())
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -157,9 +167,9 @@ public class WorldRegion
|
|||||||
// Then, set a timer to activate the neighbors.
|
// Then, set a timer to activate the neighbors.
|
||||||
_neighborsTask = ThreadPool.schedule(() ->
|
_neighborsTask = ThreadPool.schedule(() ->
|
||||||
{
|
{
|
||||||
for (WorldRegion worldRegion : _surroundingRegions)
|
for (int i = 0; i < _surroundingRegions.length; i++)
|
||||||
{
|
{
|
||||||
worldRegion.setActive(true);
|
_surroundingRegions[i].setActive(true);
|
||||||
}
|
}
|
||||||
}, 1000 * Config.GRID_NEIGHBOR_TURNON_TIME);
|
}, 1000 * Config.GRID_NEIGHBOR_TURNON_TIME);
|
||||||
}
|
}
|
||||||
@@ -183,8 +193,9 @@ public class WorldRegion
|
|||||||
// Suggest means: first check if a neighbor has PlayerInstances in it. If not, deactivate.
|
// Suggest means: first check if a neighbor has PlayerInstances in it. If not, deactivate.
|
||||||
_neighborsTask = ThreadPool.schedule(() ->
|
_neighborsTask = ThreadPool.schedule(() ->
|
||||||
{
|
{
|
||||||
for (WorldRegion worldRegion : _surroundingRegions)
|
for (int i = 0; i < _surroundingRegions.length; i++)
|
||||||
{
|
{
|
||||||
|
final WorldRegion worldRegion = _surroundingRegions[i];
|
||||||
if (worldRegion.areNeighborsEmpty())
|
if (worldRegion.areNeighborsEmpty())
|
||||||
{
|
{
|
||||||
worldRegion.setActive(false);
|
worldRegion.setActive(false);
|
||||||
@@ -206,7 +217,13 @@ public class WorldRegion
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
_visibleObjects.put(object.getObjectId(), object);
|
synchronized (_visibleObjects)
|
||||||
|
{
|
||||||
|
if (!_visibleObjects.contains(object))
|
||||||
|
{
|
||||||
|
_visibleObjects.add(object);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// If this is the first player to enter the region, activate self and neighbors.
|
// If this is the first player to enter the region, activate self and neighbors.
|
||||||
if (object.isPlayable() && !_active && !Config.GRIDS_ALWAYS_ON)
|
if (object.isPlayable() && !_active && !Config.GRIDS_ALWAYS_ON)
|
||||||
@@ -230,7 +247,11 @@ public class WorldRegion
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_visibleObjects.remove(object.getObjectId());
|
|
||||||
|
synchronized (_visibleObjects)
|
||||||
|
{
|
||||||
|
_visibleObjects.remove(object);
|
||||||
|
}
|
||||||
|
|
||||||
if (object.isPlayable() && areNeighborsEmpty() && !Config.GRIDS_ALWAYS_ON)
|
if (object.isPlayable() && areNeighborsEmpty() && !Config.GRIDS_ALWAYS_ON)
|
||||||
{
|
{
|
||||||
@@ -238,7 +259,7 @@ public class WorldRegion
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<Integer, WorldObject> getVisibleObjects()
|
public List<WorldObject> getVisibleObjects()
|
||||||
{
|
{
|
||||||
return _visibleObjects;
|
return _visibleObjects;
|
||||||
}
|
}
|
||||||
|
@@ -94,7 +94,7 @@ sp_cleanup.always_use_parentheses_in_expressions=true
|
|||||||
sp_cleanup.always_use_this_for_non_static_field_access=false
|
sp_cleanup.always_use_this_for_non_static_field_access=false
|
||||||
sp_cleanup.always_use_this_for_non_static_method_access=false
|
sp_cleanup.always_use_this_for_non_static_method_access=false
|
||||||
sp_cleanup.convert_functional_interfaces=true
|
sp_cleanup.convert_functional_interfaces=true
|
||||||
sp_cleanup.convert_to_enhanced_for_loop=true
|
sp_cleanup.convert_to_enhanced_for_loop=false
|
||||||
sp_cleanup.correct_indentation=false
|
sp_cleanup.correct_indentation=false
|
||||||
sp_cleanup.format_source_code=true
|
sp_cleanup.format_source_code=true
|
||||||
sp_cleanup.format_source_code_changes_only=false
|
sp_cleanup.format_source_code_changes_only=false
|
||||||
@@ -106,18 +106,23 @@ sp_cleanup.make_type_abstract_if_missing_method=false
|
|||||||
sp_cleanup.make_variable_declarations_final=true
|
sp_cleanup.make_variable_declarations_final=true
|
||||||
sp_cleanup.never_use_blocks=false
|
sp_cleanup.never_use_blocks=false
|
||||||
sp_cleanup.never_use_parentheses_in_expressions=false
|
sp_cleanup.never_use_parentheses_in_expressions=false
|
||||||
|
sp_cleanup.number_suffix=false
|
||||||
sp_cleanup.on_save_use_additional_actions=true
|
sp_cleanup.on_save_use_additional_actions=true
|
||||||
sp_cleanup.organize_imports=true
|
sp_cleanup.organize_imports=true
|
||||||
|
sp_cleanup.push_down_negation=false
|
||||||
sp_cleanup.qualify_static_field_accesses_with_declaring_class=false
|
sp_cleanup.qualify_static_field_accesses_with_declaring_class=false
|
||||||
sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true
|
sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true
|
||||||
sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true
|
sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true
|
||||||
sp_cleanup.qualify_static_member_accesses_with_declaring_class=true
|
sp_cleanup.qualify_static_member_accesses_with_declaring_class=true
|
||||||
sp_cleanup.qualify_static_method_accesses_with_declaring_class=false
|
sp_cleanup.qualify_static_method_accesses_with_declaring_class=false
|
||||||
sp_cleanup.remove_private_constructors=true
|
sp_cleanup.remove_private_constructors=true
|
||||||
|
sp_cleanup.remove_redundant_modifiers=false
|
||||||
|
sp_cleanup.remove_redundant_semicolons=false
|
||||||
sp_cleanup.remove_redundant_type_arguments=false
|
sp_cleanup.remove_redundant_type_arguments=false
|
||||||
sp_cleanup.remove_trailing_whitespaces=false
|
sp_cleanup.remove_trailing_whitespaces=false
|
||||||
sp_cleanup.remove_trailing_whitespaces_all=true
|
sp_cleanup.remove_trailing_whitespaces_all=true
|
||||||
sp_cleanup.remove_trailing_whitespaces_ignore_empty=true
|
sp_cleanup.remove_trailing_whitespaces_ignore_empty=true
|
||||||
|
sp_cleanup.remove_unnecessary_array_creation=false
|
||||||
sp_cleanup.remove_unnecessary_casts=true
|
sp_cleanup.remove_unnecessary_casts=true
|
||||||
sp_cleanup.remove_unnecessary_nls_tags=true
|
sp_cleanup.remove_unnecessary_nls_tags=true
|
||||||
sp_cleanup.remove_unused_imports=true
|
sp_cleanup.remove_unused_imports=true
|
||||||
@@ -126,11 +131,14 @@ sp_cleanup.remove_unused_private_fields=true
|
|||||||
sp_cleanup.remove_unused_private_members=false
|
sp_cleanup.remove_unused_private_members=false
|
||||||
sp_cleanup.remove_unused_private_methods=true
|
sp_cleanup.remove_unused_private_methods=true
|
||||||
sp_cleanup.remove_unused_private_types=true
|
sp_cleanup.remove_unused_private_types=true
|
||||||
|
sp_cleanup.simplify_lambda_expression_and_method_ref=false
|
||||||
sp_cleanup.sort_members=false
|
sp_cleanup.sort_members=false
|
||||||
sp_cleanup.sort_members_all=false
|
sp_cleanup.sort_members_all=false
|
||||||
sp_cleanup.use_anonymous_class_creation=false
|
sp_cleanup.use_anonymous_class_creation=false
|
||||||
|
sp_cleanup.use_autoboxing=false
|
||||||
sp_cleanup.use_blocks=true
|
sp_cleanup.use_blocks=true
|
||||||
sp_cleanup.use_blocks_only_for_return_and_throw=false
|
sp_cleanup.use_blocks_only_for_return_and_throw=false
|
||||||
|
sp_cleanup.use_directly_map_method=false
|
||||||
sp_cleanup.use_lambda=true
|
sp_cleanup.use_lambda=true
|
||||||
sp_cleanup.use_parentheses_in_expressions=true
|
sp_cleanup.use_parentheses_in_expressions=true
|
||||||
sp_cleanup.use_this_for_non_static_field_access=false
|
sp_cleanup.use_this_for_non_static_field_access=false
|
||||||
@@ -138,3 +146,4 @@ sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true
|
|||||||
sp_cleanup.use_this_for_non_static_method_access=false
|
sp_cleanup.use_this_for_non_static_method_access=false
|
||||||
sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true
|
sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true
|
||||||
sp_cleanup.use_type_arguments=false
|
sp_cleanup.use_type_arguments=false
|
||||||
|
sp_cleanup.use_unboxing=false
|
||||||
|
@@ -406,10 +406,13 @@ public class World
|
|||||||
oldRegion.removeVisibleObject(object);
|
oldRegion.removeVisibleObject(object);
|
||||||
|
|
||||||
// Go through all surrounding WorldRegion Creatures
|
// Go through all surrounding WorldRegion Creatures
|
||||||
for (WorldRegion worldRegion : oldRegion.getSurroundingRegions())
|
final WorldRegion[] surroundingRegions = oldRegion.getSurroundingRegions();
|
||||||
|
for (int i = 0; i < surroundingRegions.length; i++)
|
||||||
{
|
{
|
||||||
for (WorldObject wo : worldRegion.getVisibleObjects().values())
|
final List<WorldObject> visibleObjects = surroundingRegions[i].getVisibleObjects();
|
||||||
|
for (int j = 0; j < visibleObjects.size(); j++)
|
||||||
{
|
{
|
||||||
|
final WorldObject wo = visibleObjects.get(j);
|
||||||
if (wo == object)
|
if (wo == object)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
@@ -466,15 +469,19 @@ public class World
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (WorldRegion worldRegion : oldRegion.getSurroundingRegions())
|
final WorldRegion[] oldSurroundingRegions = oldRegion.getSurroundingRegions();
|
||||||
|
for (int i = 0; i < oldSurroundingRegions.length; i++)
|
||||||
{
|
{
|
||||||
|
final WorldRegion worldRegion = oldSurroundingRegions[i];
|
||||||
if (newRegion.isSurroundingRegion(worldRegion))
|
if (newRegion.isSurroundingRegion(worldRegion))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (WorldObject wo : worldRegion.getVisibleObjects().values())
|
final List<WorldObject> visibleObjects = worldRegion.getVisibleObjects();
|
||||||
|
for (int j = 0; j < visibleObjects.size(); j++)
|
||||||
{
|
{
|
||||||
|
final WorldObject wo = visibleObjects.get(j);
|
||||||
if (wo == object)
|
if (wo == object)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
@@ -522,15 +529,19 @@ public class World
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (WorldRegion worldRegion : newRegion.getSurroundingRegions())
|
final WorldRegion[] newSurroundingRegions = newRegion.getSurroundingRegions();
|
||||||
|
for (int i = 0; i < newSurroundingRegions.length; i++)
|
||||||
{
|
{
|
||||||
|
final WorldRegion worldRegion = newSurroundingRegions[i];
|
||||||
if (oldRegion.isSurroundingRegion(worldRegion))
|
if (oldRegion.isSurroundingRegion(worldRegion))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (WorldObject wo : worldRegion.getVisibleObjects().values())
|
final List<WorldObject> visibleObjects = worldRegion.getVisibleObjects();
|
||||||
|
for (int j = 0; j < visibleObjects.size(); j++)
|
||||||
{
|
{
|
||||||
|
final WorldObject wo = visibleObjects.get(j);
|
||||||
if ((wo == object) || (wo.getInstanceWorld() != object.getInstanceWorld()))
|
if ((wo == object) || (wo.getInstanceWorld() != object.getInstanceWorld()))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
@@ -610,27 +621,30 @@ public class World
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final WorldRegion centerWorldRegion = getRegion(object);
|
final WorldRegion worldRegion = getRegion(object);
|
||||||
if (centerWorldRegion == null)
|
if (worldRegion == null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (WorldRegion region : centerWorldRegion.getSurroundingRegions())
|
final WorldRegion[] surroundingRegions = worldRegion.getSurroundingRegions();
|
||||||
|
for (int i = 0; i < surroundingRegions.length; i++)
|
||||||
{
|
{
|
||||||
for (WorldObject visibleObject : region.getVisibleObjects().values())
|
final List<WorldObject> visibleObjects = surroundingRegions[i].getVisibleObjects();
|
||||||
|
for (int j = 0; j < visibleObjects.size(); j++)
|
||||||
{
|
{
|
||||||
if ((visibleObject == null) || (visibleObject == object) || !clazz.isInstance(visibleObject))
|
final WorldObject wo = visibleObjects.get(j);
|
||||||
|
if ((wo == null) || (wo == object) || !clazz.isInstance(wo))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (visibleObject.getInstanceWorld() != object.getInstanceWorld())
|
if (wo.getInstanceWorld() != object.getInstanceWorld())
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
c.accept(clazz.cast(visibleObject));
|
c.accept(clazz.cast(wo));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -662,29 +676,32 @@ public class World
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final WorldRegion centerWorldRegion = getRegion(object);
|
final WorldRegion worldRegion = getRegion(object);
|
||||||
if (centerWorldRegion == null)
|
if (worldRegion == null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (WorldRegion region : centerWorldRegion.getSurroundingRegions())
|
final WorldRegion[] surroundingRegions = worldRegion.getSurroundingRegions();
|
||||||
|
for (int i = 0; i < surroundingRegions.length; i++)
|
||||||
{
|
{
|
||||||
for (WorldObject visibleObject : region.getVisibleObjects().values())
|
final List<WorldObject> visibleObjects = surroundingRegions[i].getVisibleObjects();
|
||||||
|
for (int j = 0; j < visibleObjects.size(); j++)
|
||||||
{
|
{
|
||||||
if ((visibleObject == null) || (visibleObject == object) || !clazz.isInstance(visibleObject))
|
final WorldObject wo = visibleObjects.get(j);
|
||||||
|
if ((wo == null) || (wo == object) || !clazz.isInstance(wo))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (visibleObject.getInstanceWorld() != object.getInstanceWorld())
|
if (wo.getInstanceWorld() != object.getInstanceWorld())
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (visibleObject.calculateDistance3D(object) <= range)
|
if (wo.calculateDistance3D(object) <= range)
|
||||||
{
|
{
|
||||||
c.accept(clazz.cast(visibleObject));
|
c.accept(clazz.cast(wo));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -16,8 +16,8 @@
|
|||||||
*/
|
*/
|
||||||
package org.l2jmobius.gameserver.model;
|
package org.l2jmobius.gameserver.model;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.ArrayList;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.List;
|
||||||
import java.util.concurrent.ScheduledFuture;
|
import java.util.concurrent.ScheduledFuture;
|
||||||
|
|
||||||
import org.l2jmobius.Config;
|
import org.l2jmobius.Config;
|
||||||
@@ -28,9 +28,9 @@ import org.l2jmobius.gameserver.taskmanager.RandomAnimationTaskManager;
|
|||||||
|
|
||||||
public class WorldRegion
|
public class WorldRegion
|
||||||
{
|
{
|
||||||
/** Map containing visible objects in this world region. */
|
/** List containing visible objects in this world region. */
|
||||||
private final Map<Integer, WorldObject> _visibleObjects = new ConcurrentHashMap<>();
|
private final List<WorldObject> _visibleObjects = new ArrayList<>();
|
||||||
/** Map containing nearby regions forming this world region's effective area. */
|
/** Array containing nearby regions forming this world region's effective area. */
|
||||||
private WorldRegion[] _surroundingRegions;
|
private WorldRegion[] _surroundingRegions;
|
||||||
private final int _regionX;
|
private final int _regionX;
|
||||||
private final int _regionY;
|
private final int _regionY;
|
||||||
@@ -52,8 +52,9 @@ public class WorldRegion
|
|||||||
|
|
||||||
if (!isOn)
|
if (!isOn)
|
||||||
{
|
{
|
||||||
for (WorldObject wo : _visibleObjects.values())
|
for (int i = 0; i < _visibleObjects.size(); i++)
|
||||||
{
|
{
|
||||||
|
final WorldObject wo = _visibleObjects.get(i);
|
||||||
if (wo.isAttackable())
|
if (wo.isAttackable())
|
||||||
{
|
{
|
||||||
final Attackable mob = (Attackable) wo;
|
final Attackable mob = (Attackable) wo;
|
||||||
@@ -87,15 +88,16 @@ public class WorldRegion
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for (WorldObject wo : _visibleObjects.values())
|
for (int i = 0; i < _visibleObjects.size(); i++)
|
||||||
{
|
{
|
||||||
|
final WorldObject wo = _visibleObjects.get(i);
|
||||||
if (wo.isAttackable())
|
if (wo.isAttackable())
|
||||||
{
|
{
|
||||||
// Start HP/MP/CP regeneration task.
|
// Start HP/MP/CP regeneration task.
|
||||||
((Attackable) wo).getStatus().startHpMpRegeneration();
|
((Attackable) wo).getStatus().startHpMpRegeneration();
|
||||||
RandomAnimationTaskManager.getInstance().add((Npc) wo);
|
RandomAnimationTaskManager.getInstance().add((Npc) wo);
|
||||||
}
|
}
|
||||||
else if (wo instanceof Npc)
|
else if (wo.isNpc())
|
||||||
{
|
{
|
||||||
RandomAnimationTaskManager.getInstance().add((Npc) wo);
|
RandomAnimationTaskManager.getInstance().add((Npc) wo);
|
||||||
}
|
}
|
||||||
@@ -110,13 +112,21 @@ public class WorldRegion
|
|||||||
|
|
||||||
public boolean areNeighborsEmpty()
|
public boolean areNeighborsEmpty()
|
||||||
{
|
{
|
||||||
for (WorldRegion worldRegion : _surroundingRegions)
|
for (int i = 0; i < _surroundingRegions.length; i++)
|
||||||
{
|
{
|
||||||
if (worldRegion.isActive() && worldRegion.getVisibleObjects().values().stream().anyMatch(WorldObject::isPlayable))
|
final WorldRegion worldRegion = _surroundingRegions[i];
|
||||||
|
if (worldRegion.isActive())
|
||||||
|
{
|
||||||
|
final List<WorldObject> regionObjects = worldRegion.getVisibleObjects();
|
||||||
|
for (int j = 0; j < regionObjects.size(); j++)
|
||||||
|
{
|
||||||
|
if (regionObjects.get(j).isPlayable())
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -157,9 +167,9 @@ public class WorldRegion
|
|||||||
// Then, set a timer to activate the neighbors.
|
// Then, set a timer to activate the neighbors.
|
||||||
_neighborsTask = ThreadPool.schedule(() ->
|
_neighborsTask = ThreadPool.schedule(() ->
|
||||||
{
|
{
|
||||||
for (WorldRegion worldRegion : _surroundingRegions)
|
for (int i = 0; i < _surroundingRegions.length; i++)
|
||||||
{
|
{
|
||||||
worldRegion.setActive(true);
|
_surroundingRegions[i].setActive(true);
|
||||||
}
|
}
|
||||||
}, 1000 * Config.GRID_NEIGHBOR_TURNON_TIME);
|
}, 1000 * Config.GRID_NEIGHBOR_TURNON_TIME);
|
||||||
}
|
}
|
||||||
@@ -183,8 +193,9 @@ public class WorldRegion
|
|||||||
// Suggest means: first check if a neighbor has PlayerInstances in it. If not, deactivate.
|
// Suggest means: first check if a neighbor has PlayerInstances in it. If not, deactivate.
|
||||||
_neighborsTask = ThreadPool.schedule(() ->
|
_neighborsTask = ThreadPool.schedule(() ->
|
||||||
{
|
{
|
||||||
for (WorldRegion worldRegion : _surroundingRegions)
|
for (int i = 0; i < _surroundingRegions.length; i++)
|
||||||
{
|
{
|
||||||
|
final WorldRegion worldRegion = _surroundingRegions[i];
|
||||||
if (worldRegion.areNeighborsEmpty())
|
if (worldRegion.areNeighborsEmpty())
|
||||||
{
|
{
|
||||||
worldRegion.setActive(false);
|
worldRegion.setActive(false);
|
||||||
@@ -206,7 +217,13 @@ public class WorldRegion
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
_visibleObjects.put(object.getObjectId(), object);
|
synchronized (_visibleObjects)
|
||||||
|
{
|
||||||
|
if (!_visibleObjects.contains(object))
|
||||||
|
{
|
||||||
|
_visibleObjects.add(object);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// If this is the first player to enter the region, activate self and neighbors.
|
// If this is the first player to enter the region, activate self and neighbors.
|
||||||
if (object.isPlayable() && !_active && !Config.GRIDS_ALWAYS_ON)
|
if (object.isPlayable() && !_active && !Config.GRIDS_ALWAYS_ON)
|
||||||
@@ -230,7 +247,11 @@ public class WorldRegion
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_visibleObjects.remove(object.getObjectId());
|
|
||||||
|
synchronized (_visibleObjects)
|
||||||
|
{
|
||||||
|
_visibleObjects.remove(object);
|
||||||
|
}
|
||||||
|
|
||||||
if (object.isPlayable() && areNeighborsEmpty() && !Config.GRIDS_ALWAYS_ON)
|
if (object.isPlayable() && areNeighborsEmpty() && !Config.GRIDS_ALWAYS_ON)
|
||||||
{
|
{
|
||||||
@@ -238,7 +259,7 @@ public class WorldRegion
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<Integer, WorldObject> getVisibleObjects()
|
public List<WorldObject> getVisibleObjects()
|
||||||
{
|
{
|
||||||
return _visibleObjects;
|
return _visibleObjects;
|
||||||
}
|
}
|
||||||
|
@@ -94,7 +94,7 @@ sp_cleanup.always_use_parentheses_in_expressions=true
|
|||||||
sp_cleanup.always_use_this_for_non_static_field_access=false
|
sp_cleanup.always_use_this_for_non_static_field_access=false
|
||||||
sp_cleanup.always_use_this_for_non_static_method_access=false
|
sp_cleanup.always_use_this_for_non_static_method_access=false
|
||||||
sp_cleanup.convert_functional_interfaces=true
|
sp_cleanup.convert_functional_interfaces=true
|
||||||
sp_cleanup.convert_to_enhanced_for_loop=true
|
sp_cleanup.convert_to_enhanced_for_loop=false
|
||||||
sp_cleanup.correct_indentation=false
|
sp_cleanup.correct_indentation=false
|
||||||
sp_cleanup.format_source_code=true
|
sp_cleanup.format_source_code=true
|
||||||
sp_cleanup.format_source_code_changes_only=false
|
sp_cleanup.format_source_code_changes_only=false
|
||||||
@@ -106,18 +106,23 @@ sp_cleanup.make_type_abstract_if_missing_method=false
|
|||||||
sp_cleanup.make_variable_declarations_final=true
|
sp_cleanup.make_variable_declarations_final=true
|
||||||
sp_cleanup.never_use_blocks=false
|
sp_cleanup.never_use_blocks=false
|
||||||
sp_cleanup.never_use_parentheses_in_expressions=false
|
sp_cleanup.never_use_parentheses_in_expressions=false
|
||||||
|
sp_cleanup.number_suffix=false
|
||||||
sp_cleanup.on_save_use_additional_actions=true
|
sp_cleanup.on_save_use_additional_actions=true
|
||||||
sp_cleanup.organize_imports=true
|
sp_cleanup.organize_imports=true
|
||||||
|
sp_cleanup.push_down_negation=false
|
||||||
sp_cleanup.qualify_static_field_accesses_with_declaring_class=false
|
sp_cleanup.qualify_static_field_accesses_with_declaring_class=false
|
||||||
sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true
|
sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true
|
||||||
sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true
|
sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true
|
||||||
sp_cleanup.qualify_static_member_accesses_with_declaring_class=true
|
sp_cleanup.qualify_static_member_accesses_with_declaring_class=true
|
||||||
sp_cleanup.qualify_static_method_accesses_with_declaring_class=false
|
sp_cleanup.qualify_static_method_accesses_with_declaring_class=false
|
||||||
sp_cleanup.remove_private_constructors=true
|
sp_cleanup.remove_private_constructors=true
|
||||||
|
sp_cleanup.remove_redundant_modifiers=false
|
||||||
|
sp_cleanup.remove_redundant_semicolons=false
|
||||||
sp_cleanup.remove_redundant_type_arguments=false
|
sp_cleanup.remove_redundant_type_arguments=false
|
||||||
sp_cleanup.remove_trailing_whitespaces=false
|
sp_cleanup.remove_trailing_whitespaces=false
|
||||||
sp_cleanup.remove_trailing_whitespaces_all=true
|
sp_cleanup.remove_trailing_whitespaces_all=true
|
||||||
sp_cleanup.remove_trailing_whitespaces_ignore_empty=true
|
sp_cleanup.remove_trailing_whitespaces_ignore_empty=true
|
||||||
|
sp_cleanup.remove_unnecessary_array_creation=false
|
||||||
sp_cleanup.remove_unnecessary_casts=true
|
sp_cleanup.remove_unnecessary_casts=true
|
||||||
sp_cleanup.remove_unnecessary_nls_tags=true
|
sp_cleanup.remove_unnecessary_nls_tags=true
|
||||||
sp_cleanup.remove_unused_imports=true
|
sp_cleanup.remove_unused_imports=true
|
||||||
@@ -126,11 +131,14 @@ sp_cleanup.remove_unused_private_fields=true
|
|||||||
sp_cleanup.remove_unused_private_members=false
|
sp_cleanup.remove_unused_private_members=false
|
||||||
sp_cleanup.remove_unused_private_methods=true
|
sp_cleanup.remove_unused_private_methods=true
|
||||||
sp_cleanup.remove_unused_private_types=true
|
sp_cleanup.remove_unused_private_types=true
|
||||||
|
sp_cleanup.simplify_lambda_expression_and_method_ref=false
|
||||||
sp_cleanup.sort_members=false
|
sp_cleanup.sort_members=false
|
||||||
sp_cleanup.sort_members_all=false
|
sp_cleanup.sort_members_all=false
|
||||||
sp_cleanup.use_anonymous_class_creation=false
|
sp_cleanup.use_anonymous_class_creation=false
|
||||||
|
sp_cleanup.use_autoboxing=false
|
||||||
sp_cleanup.use_blocks=true
|
sp_cleanup.use_blocks=true
|
||||||
sp_cleanup.use_blocks_only_for_return_and_throw=false
|
sp_cleanup.use_blocks_only_for_return_and_throw=false
|
||||||
|
sp_cleanup.use_directly_map_method=false
|
||||||
sp_cleanup.use_lambda=true
|
sp_cleanup.use_lambda=true
|
||||||
sp_cleanup.use_parentheses_in_expressions=true
|
sp_cleanup.use_parentheses_in_expressions=true
|
||||||
sp_cleanup.use_this_for_non_static_field_access=false
|
sp_cleanup.use_this_for_non_static_field_access=false
|
||||||
@@ -138,3 +146,4 @@ sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true
|
|||||||
sp_cleanup.use_this_for_non_static_method_access=false
|
sp_cleanup.use_this_for_non_static_method_access=false
|
||||||
sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true
|
sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true
|
||||||
sp_cleanup.use_type_arguments=false
|
sp_cleanup.use_type_arguments=false
|
||||||
|
sp_cleanup.use_unboxing=false
|
||||||
|
@@ -406,10 +406,13 @@ public class World
|
|||||||
oldRegion.removeVisibleObject(object);
|
oldRegion.removeVisibleObject(object);
|
||||||
|
|
||||||
// Go through all surrounding WorldRegion Creatures
|
// Go through all surrounding WorldRegion Creatures
|
||||||
for (WorldRegion worldRegion : oldRegion.getSurroundingRegions())
|
final WorldRegion[] surroundingRegions = oldRegion.getSurroundingRegions();
|
||||||
|
for (int i = 0; i < surroundingRegions.length; i++)
|
||||||
{
|
{
|
||||||
for (WorldObject wo : worldRegion.getVisibleObjects().values())
|
final List<WorldObject> visibleObjects = surroundingRegions[i].getVisibleObjects();
|
||||||
|
for (int j = 0; j < visibleObjects.size(); j++)
|
||||||
{
|
{
|
||||||
|
final WorldObject wo = visibleObjects.get(j);
|
||||||
if (wo == object)
|
if (wo == object)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
@@ -466,15 +469,19 @@ public class World
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (WorldRegion worldRegion : oldRegion.getSurroundingRegions())
|
final WorldRegion[] oldSurroundingRegions = oldRegion.getSurroundingRegions();
|
||||||
|
for (int i = 0; i < oldSurroundingRegions.length; i++)
|
||||||
{
|
{
|
||||||
|
final WorldRegion worldRegion = oldSurroundingRegions[i];
|
||||||
if (newRegion.isSurroundingRegion(worldRegion))
|
if (newRegion.isSurroundingRegion(worldRegion))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (WorldObject wo : worldRegion.getVisibleObjects().values())
|
final List<WorldObject> visibleObjects = worldRegion.getVisibleObjects();
|
||||||
|
for (int j = 0; j < visibleObjects.size(); j++)
|
||||||
{
|
{
|
||||||
|
final WorldObject wo = visibleObjects.get(j);
|
||||||
if (wo == object)
|
if (wo == object)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
@@ -522,15 +529,19 @@ public class World
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (WorldRegion worldRegion : newRegion.getSurroundingRegions())
|
final WorldRegion[] newSurroundingRegions = newRegion.getSurroundingRegions();
|
||||||
|
for (int i = 0; i < newSurroundingRegions.length; i++)
|
||||||
{
|
{
|
||||||
|
final WorldRegion worldRegion = newSurroundingRegions[i];
|
||||||
if (oldRegion.isSurroundingRegion(worldRegion))
|
if (oldRegion.isSurroundingRegion(worldRegion))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (WorldObject wo : worldRegion.getVisibleObjects().values())
|
final List<WorldObject> visibleObjects = worldRegion.getVisibleObjects();
|
||||||
|
for (int j = 0; j < visibleObjects.size(); j++)
|
||||||
{
|
{
|
||||||
|
final WorldObject wo = visibleObjects.get(j);
|
||||||
if ((wo == object) || (wo.getInstanceWorld() != object.getInstanceWorld()))
|
if ((wo == object) || (wo.getInstanceWorld() != object.getInstanceWorld()))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
@@ -610,27 +621,30 @@ public class World
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final WorldRegion centerWorldRegion = getRegion(object);
|
final WorldRegion worldRegion = getRegion(object);
|
||||||
if (centerWorldRegion == null)
|
if (worldRegion == null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (WorldRegion region : centerWorldRegion.getSurroundingRegions())
|
final WorldRegion[] surroundingRegions = worldRegion.getSurroundingRegions();
|
||||||
|
for (int i = 0; i < surroundingRegions.length; i++)
|
||||||
{
|
{
|
||||||
for (WorldObject visibleObject : region.getVisibleObjects().values())
|
final List<WorldObject> visibleObjects = surroundingRegions[i].getVisibleObjects();
|
||||||
|
for (int j = 0; j < visibleObjects.size(); j++)
|
||||||
{
|
{
|
||||||
if ((visibleObject == null) || (visibleObject == object) || !clazz.isInstance(visibleObject))
|
final WorldObject wo = visibleObjects.get(j);
|
||||||
|
if ((wo == null) || (wo == object) || !clazz.isInstance(wo))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (visibleObject.getInstanceWorld() != object.getInstanceWorld())
|
if (wo.getInstanceWorld() != object.getInstanceWorld())
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
c.accept(clazz.cast(visibleObject));
|
c.accept(clazz.cast(wo));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -662,29 +676,32 @@ public class World
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final WorldRegion centerWorldRegion = getRegion(object);
|
final WorldRegion worldRegion = getRegion(object);
|
||||||
if (centerWorldRegion == null)
|
if (worldRegion == null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (WorldRegion region : centerWorldRegion.getSurroundingRegions())
|
final WorldRegion[] surroundingRegions = worldRegion.getSurroundingRegions();
|
||||||
|
for (int i = 0; i < surroundingRegions.length; i++)
|
||||||
{
|
{
|
||||||
for (WorldObject visibleObject : region.getVisibleObjects().values())
|
final List<WorldObject> visibleObjects = surroundingRegions[i].getVisibleObjects();
|
||||||
|
for (int j = 0; j < visibleObjects.size(); j++)
|
||||||
{
|
{
|
||||||
if ((visibleObject == null) || (visibleObject == object) || !clazz.isInstance(visibleObject))
|
final WorldObject wo = visibleObjects.get(j);
|
||||||
|
if ((wo == null) || (wo == object) || !clazz.isInstance(wo))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (visibleObject.getInstanceWorld() != object.getInstanceWorld())
|
if (wo.getInstanceWorld() != object.getInstanceWorld())
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (visibleObject.calculateDistance3D(object) <= range)
|
if (wo.calculateDistance3D(object) <= range)
|
||||||
{
|
{
|
||||||
c.accept(clazz.cast(visibleObject));
|
c.accept(clazz.cast(wo));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -16,8 +16,8 @@
|
|||||||
*/
|
*/
|
||||||
package org.l2jmobius.gameserver.model;
|
package org.l2jmobius.gameserver.model;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.ArrayList;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.List;
|
||||||
import java.util.concurrent.ScheduledFuture;
|
import java.util.concurrent.ScheduledFuture;
|
||||||
|
|
||||||
import org.l2jmobius.Config;
|
import org.l2jmobius.Config;
|
||||||
@@ -28,9 +28,9 @@ import org.l2jmobius.gameserver.taskmanager.RandomAnimationTaskManager;
|
|||||||
|
|
||||||
public class WorldRegion
|
public class WorldRegion
|
||||||
{
|
{
|
||||||
/** Map containing visible objects in this world region. */
|
/** List containing visible objects in this world region. */
|
||||||
private final Map<Integer, WorldObject> _visibleObjects = new ConcurrentHashMap<>();
|
private final List<WorldObject> _visibleObjects = new ArrayList<>();
|
||||||
/** Map containing nearby regions forming this world region's effective area. */
|
/** Array containing nearby regions forming this world region's effective area. */
|
||||||
private WorldRegion[] _surroundingRegions;
|
private WorldRegion[] _surroundingRegions;
|
||||||
private final int _regionX;
|
private final int _regionX;
|
||||||
private final int _regionY;
|
private final int _regionY;
|
||||||
@@ -52,8 +52,9 @@ public class WorldRegion
|
|||||||
|
|
||||||
if (!isOn)
|
if (!isOn)
|
||||||
{
|
{
|
||||||
for (WorldObject wo : _visibleObjects.values())
|
for (int i = 0; i < _visibleObjects.size(); i++)
|
||||||
{
|
{
|
||||||
|
final WorldObject wo = _visibleObjects.get(i);
|
||||||
if (wo.isAttackable())
|
if (wo.isAttackable())
|
||||||
{
|
{
|
||||||
final Attackable mob = (Attackable) wo;
|
final Attackable mob = (Attackable) wo;
|
||||||
@@ -87,15 +88,16 @@ public class WorldRegion
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for (WorldObject wo : _visibleObjects.values())
|
for (int i = 0; i < _visibleObjects.size(); i++)
|
||||||
{
|
{
|
||||||
|
final WorldObject wo = _visibleObjects.get(i);
|
||||||
if (wo.isAttackable())
|
if (wo.isAttackable())
|
||||||
{
|
{
|
||||||
// Start HP/MP/CP regeneration task.
|
// Start HP/MP/CP regeneration task.
|
||||||
((Attackable) wo).getStatus().startHpMpRegeneration();
|
((Attackable) wo).getStatus().startHpMpRegeneration();
|
||||||
RandomAnimationTaskManager.getInstance().add((Npc) wo);
|
RandomAnimationTaskManager.getInstance().add((Npc) wo);
|
||||||
}
|
}
|
||||||
else if (wo instanceof Npc)
|
else if (wo.isNpc())
|
||||||
{
|
{
|
||||||
RandomAnimationTaskManager.getInstance().add((Npc) wo);
|
RandomAnimationTaskManager.getInstance().add((Npc) wo);
|
||||||
}
|
}
|
||||||
@@ -110,13 +112,21 @@ public class WorldRegion
|
|||||||
|
|
||||||
public boolean areNeighborsEmpty()
|
public boolean areNeighborsEmpty()
|
||||||
{
|
{
|
||||||
for (WorldRegion worldRegion : _surroundingRegions)
|
for (int i = 0; i < _surroundingRegions.length; i++)
|
||||||
{
|
{
|
||||||
if (worldRegion.isActive() && worldRegion.getVisibleObjects().values().stream().anyMatch(WorldObject::isPlayable))
|
final WorldRegion worldRegion = _surroundingRegions[i];
|
||||||
|
if (worldRegion.isActive())
|
||||||
|
{
|
||||||
|
final List<WorldObject> regionObjects = worldRegion.getVisibleObjects();
|
||||||
|
for (int j = 0; j < regionObjects.size(); j++)
|
||||||
|
{
|
||||||
|
if (regionObjects.get(j).isPlayable())
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -157,9 +167,9 @@ public class WorldRegion
|
|||||||
// Then, set a timer to activate the neighbors.
|
// Then, set a timer to activate the neighbors.
|
||||||
_neighborsTask = ThreadPool.schedule(() ->
|
_neighborsTask = ThreadPool.schedule(() ->
|
||||||
{
|
{
|
||||||
for (WorldRegion worldRegion : _surroundingRegions)
|
for (int i = 0; i < _surroundingRegions.length; i++)
|
||||||
{
|
{
|
||||||
worldRegion.setActive(true);
|
_surroundingRegions[i].setActive(true);
|
||||||
}
|
}
|
||||||
}, 1000 * Config.GRID_NEIGHBOR_TURNON_TIME);
|
}, 1000 * Config.GRID_NEIGHBOR_TURNON_TIME);
|
||||||
}
|
}
|
||||||
@@ -183,8 +193,9 @@ public class WorldRegion
|
|||||||
// Suggest means: first check if a neighbor has PlayerInstances in it. If not, deactivate.
|
// Suggest means: first check if a neighbor has PlayerInstances in it. If not, deactivate.
|
||||||
_neighborsTask = ThreadPool.schedule(() ->
|
_neighborsTask = ThreadPool.schedule(() ->
|
||||||
{
|
{
|
||||||
for (WorldRegion worldRegion : _surroundingRegions)
|
for (int i = 0; i < _surroundingRegions.length; i++)
|
||||||
{
|
{
|
||||||
|
final WorldRegion worldRegion = _surroundingRegions[i];
|
||||||
if (worldRegion.areNeighborsEmpty())
|
if (worldRegion.areNeighborsEmpty())
|
||||||
{
|
{
|
||||||
worldRegion.setActive(false);
|
worldRegion.setActive(false);
|
||||||
@@ -206,7 +217,13 @@ public class WorldRegion
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
_visibleObjects.put(object.getObjectId(), object);
|
synchronized (_visibleObjects)
|
||||||
|
{
|
||||||
|
if (!_visibleObjects.contains(object))
|
||||||
|
{
|
||||||
|
_visibleObjects.add(object);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// If this is the first player to enter the region, activate self and neighbors.
|
// If this is the first player to enter the region, activate self and neighbors.
|
||||||
if (object.isPlayable() && !_active && !Config.GRIDS_ALWAYS_ON)
|
if (object.isPlayable() && !_active && !Config.GRIDS_ALWAYS_ON)
|
||||||
@@ -230,7 +247,11 @@ public class WorldRegion
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_visibleObjects.remove(object.getObjectId());
|
|
||||||
|
synchronized (_visibleObjects)
|
||||||
|
{
|
||||||
|
_visibleObjects.remove(object);
|
||||||
|
}
|
||||||
|
|
||||||
if (object.isPlayable() && areNeighborsEmpty() && !Config.GRIDS_ALWAYS_ON)
|
if (object.isPlayable() && areNeighborsEmpty() && !Config.GRIDS_ALWAYS_ON)
|
||||||
{
|
{
|
||||||
@@ -238,7 +259,7 @@ public class WorldRegion
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<Integer, WorldObject> getVisibleObjects()
|
public List<WorldObject> getVisibleObjects()
|
||||||
{
|
{
|
||||||
return _visibleObjects;
|
return _visibleObjects;
|
||||||
}
|
}
|
||||||
|
@@ -94,7 +94,7 @@ sp_cleanup.always_use_parentheses_in_expressions=true
|
|||||||
sp_cleanup.always_use_this_for_non_static_field_access=false
|
sp_cleanup.always_use_this_for_non_static_field_access=false
|
||||||
sp_cleanup.always_use_this_for_non_static_method_access=false
|
sp_cleanup.always_use_this_for_non_static_method_access=false
|
||||||
sp_cleanup.convert_functional_interfaces=true
|
sp_cleanup.convert_functional_interfaces=true
|
||||||
sp_cleanup.convert_to_enhanced_for_loop=true
|
sp_cleanup.convert_to_enhanced_for_loop=false
|
||||||
sp_cleanup.correct_indentation=false
|
sp_cleanup.correct_indentation=false
|
||||||
sp_cleanup.format_source_code=true
|
sp_cleanup.format_source_code=true
|
||||||
sp_cleanup.format_source_code_changes_only=false
|
sp_cleanup.format_source_code_changes_only=false
|
||||||
@@ -106,18 +106,23 @@ sp_cleanup.make_type_abstract_if_missing_method=false
|
|||||||
sp_cleanup.make_variable_declarations_final=true
|
sp_cleanup.make_variable_declarations_final=true
|
||||||
sp_cleanup.never_use_blocks=false
|
sp_cleanup.never_use_blocks=false
|
||||||
sp_cleanup.never_use_parentheses_in_expressions=false
|
sp_cleanup.never_use_parentheses_in_expressions=false
|
||||||
|
sp_cleanup.number_suffix=false
|
||||||
sp_cleanup.on_save_use_additional_actions=true
|
sp_cleanup.on_save_use_additional_actions=true
|
||||||
sp_cleanup.organize_imports=true
|
sp_cleanup.organize_imports=true
|
||||||
|
sp_cleanup.push_down_negation=false
|
||||||
sp_cleanup.qualify_static_field_accesses_with_declaring_class=false
|
sp_cleanup.qualify_static_field_accesses_with_declaring_class=false
|
||||||
sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true
|
sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true
|
||||||
sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true
|
sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true
|
||||||
sp_cleanup.qualify_static_member_accesses_with_declaring_class=true
|
sp_cleanup.qualify_static_member_accesses_with_declaring_class=true
|
||||||
sp_cleanup.qualify_static_method_accesses_with_declaring_class=false
|
sp_cleanup.qualify_static_method_accesses_with_declaring_class=false
|
||||||
sp_cleanup.remove_private_constructors=true
|
sp_cleanup.remove_private_constructors=true
|
||||||
|
sp_cleanup.remove_redundant_modifiers=false
|
||||||
|
sp_cleanup.remove_redundant_semicolons=false
|
||||||
sp_cleanup.remove_redundant_type_arguments=false
|
sp_cleanup.remove_redundant_type_arguments=false
|
||||||
sp_cleanup.remove_trailing_whitespaces=false
|
sp_cleanup.remove_trailing_whitespaces=false
|
||||||
sp_cleanup.remove_trailing_whitespaces_all=true
|
sp_cleanup.remove_trailing_whitespaces_all=true
|
||||||
sp_cleanup.remove_trailing_whitespaces_ignore_empty=true
|
sp_cleanup.remove_trailing_whitespaces_ignore_empty=true
|
||||||
|
sp_cleanup.remove_unnecessary_array_creation=false
|
||||||
sp_cleanup.remove_unnecessary_casts=true
|
sp_cleanup.remove_unnecessary_casts=true
|
||||||
sp_cleanup.remove_unnecessary_nls_tags=true
|
sp_cleanup.remove_unnecessary_nls_tags=true
|
||||||
sp_cleanup.remove_unused_imports=true
|
sp_cleanup.remove_unused_imports=true
|
||||||
@@ -126,11 +131,14 @@ sp_cleanup.remove_unused_private_fields=true
|
|||||||
sp_cleanup.remove_unused_private_members=false
|
sp_cleanup.remove_unused_private_members=false
|
||||||
sp_cleanup.remove_unused_private_methods=true
|
sp_cleanup.remove_unused_private_methods=true
|
||||||
sp_cleanup.remove_unused_private_types=true
|
sp_cleanup.remove_unused_private_types=true
|
||||||
|
sp_cleanup.simplify_lambda_expression_and_method_ref=false
|
||||||
sp_cleanup.sort_members=false
|
sp_cleanup.sort_members=false
|
||||||
sp_cleanup.sort_members_all=false
|
sp_cleanup.sort_members_all=false
|
||||||
sp_cleanup.use_anonymous_class_creation=false
|
sp_cleanup.use_anonymous_class_creation=false
|
||||||
|
sp_cleanup.use_autoboxing=false
|
||||||
sp_cleanup.use_blocks=true
|
sp_cleanup.use_blocks=true
|
||||||
sp_cleanup.use_blocks_only_for_return_and_throw=false
|
sp_cleanup.use_blocks_only_for_return_and_throw=false
|
||||||
|
sp_cleanup.use_directly_map_method=false
|
||||||
sp_cleanup.use_lambda=true
|
sp_cleanup.use_lambda=true
|
||||||
sp_cleanup.use_parentheses_in_expressions=true
|
sp_cleanup.use_parentheses_in_expressions=true
|
||||||
sp_cleanup.use_this_for_non_static_field_access=false
|
sp_cleanup.use_this_for_non_static_field_access=false
|
||||||
@@ -138,3 +146,4 @@ sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true
|
|||||||
sp_cleanup.use_this_for_non_static_method_access=false
|
sp_cleanup.use_this_for_non_static_method_access=false
|
||||||
sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true
|
sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true
|
||||||
sp_cleanup.use_type_arguments=false
|
sp_cleanup.use_type_arguments=false
|
||||||
|
sp_cleanup.use_unboxing=false
|
||||||
|
@@ -406,10 +406,13 @@ public class World
|
|||||||
oldRegion.removeVisibleObject(object);
|
oldRegion.removeVisibleObject(object);
|
||||||
|
|
||||||
// Go through all surrounding WorldRegion Creatures
|
// Go through all surrounding WorldRegion Creatures
|
||||||
for (WorldRegion worldRegion : oldRegion.getSurroundingRegions())
|
final WorldRegion[] surroundingRegions = oldRegion.getSurroundingRegions();
|
||||||
|
for (int i = 0; i < surroundingRegions.length; i++)
|
||||||
{
|
{
|
||||||
for (WorldObject wo : worldRegion.getVisibleObjects().values())
|
final List<WorldObject> visibleObjects = surroundingRegions[i].getVisibleObjects();
|
||||||
|
for (int j = 0; j < visibleObjects.size(); j++)
|
||||||
{
|
{
|
||||||
|
final WorldObject wo = visibleObjects.get(j);
|
||||||
if (wo == object)
|
if (wo == object)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
@@ -466,15 +469,19 @@ public class World
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (WorldRegion worldRegion : oldRegion.getSurroundingRegions())
|
final WorldRegion[] oldSurroundingRegions = oldRegion.getSurroundingRegions();
|
||||||
|
for (int i = 0; i < oldSurroundingRegions.length; i++)
|
||||||
{
|
{
|
||||||
|
final WorldRegion worldRegion = oldSurroundingRegions[i];
|
||||||
if (newRegion.isSurroundingRegion(worldRegion))
|
if (newRegion.isSurroundingRegion(worldRegion))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (WorldObject wo : worldRegion.getVisibleObjects().values())
|
final List<WorldObject> visibleObjects = worldRegion.getVisibleObjects();
|
||||||
|
for (int j = 0; j < visibleObjects.size(); j++)
|
||||||
{
|
{
|
||||||
|
final WorldObject wo = visibleObjects.get(j);
|
||||||
if (wo == object)
|
if (wo == object)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
@@ -522,15 +529,19 @@ public class World
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (WorldRegion worldRegion : newRegion.getSurroundingRegions())
|
final WorldRegion[] newSurroundingRegions = newRegion.getSurroundingRegions();
|
||||||
|
for (int i = 0; i < newSurroundingRegions.length; i++)
|
||||||
{
|
{
|
||||||
|
final WorldRegion worldRegion = newSurroundingRegions[i];
|
||||||
if (oldRegion.isSurroundingRegion(worldRegion))
|
if (oldRegion.isSurroundingRegion(worldRegion))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (WorldObject wo : worldRegion.getVisibleObjects().values())
|
final List<WorldObject> visibleObjects = worldRegion.getVisibleObjects();
|
||||||
|
for (int j = 0; j < visibleObjects.size(); j++)
|
||||||
{
|
{
|
||||||
|
final WorldObject wo = visibleObjects.get(j);
|
||||||
if ((wo == object) || (wo.getInstanceWorld() != object.getInstanceWorld()))
|
if ((wo == object) || (wo.getInstanceWorld() != object.getInstanceWorld()))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
@@ -610,27 +621,30 @@ public class World
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final WorldRegion centerWorldRegion = getRegion(object);
|
final WorldRegion worldRegion = getRegion(object);
|
||||||
if (centerWorldRegion == null)
|
if (worldRegion == null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (WorldRegion region : centerWorldRegion.getSurroundingRegions())
|
final WorldRegion[] surroundingRegions = worldRegion.getSurroundingRegions();
|
||||||
|
for (int i = 0; i < surroundingRegions.length; i++)
|
||||||
{
|
{
|
||||||
for (WorldObject visibleObject : region.getVisibleObjects().values())
|
final List<WorldObject> visibleObjects = surroundingRegions[i].getVisibleObjects();
|
||||||
|
for (int j = 0; j < visibleObjects.size(); j++)
|
||||||
{
|
{
|
||||||
if ((visibleObject == null) || (visibleObject == object) || !clazz.isInstance(visibleObject))
|
final WorldObject wo = visibleObjects.get(j);
|
||||||
|
if ((wo == null) || (wo == object) || !clazz.isInstance(wo))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (visibleObject.getInstanceWorld() != object.getInstanceWorld())
|
if (wo.getInstanceWorld() != object.getInstanceWorld())
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
c.accept(clazz.cast(visibleObject));
|
c.accept(clazz.cast(wo));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -662,29 +676,32 @@ public class World
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final WorldRegion centerWorldRegion = getRegion(object);
|
final WorldRegion worldRegion = getRegion(object);
|
||||||
if (centerWorldRegion == null)
|
if (worldRegion == null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (WorldRegion region : centerWorldRegion.getSurroundingRegions())
|
final WorldRegion[] surroundingRegions = worldRegion.getSurroundingRegions();
|
||||||
|
for (int i = 0; i < surroundingRegions.length; i++)
|
||||||
{
|
{
|
||||||
for (WorldObject visibleObject : region.getVisibleObjects().values())
|
final List<WorldObject> visibleObjects = surroundingRegions[i].getVisibleObjects();
|
||||||
|
for (int j = 0; j < visibleObjects.size(); j++)
|
||||||
{
|
{
|
||||||
if ((visibleObject == null) || (visibleObject == object) || !clazz.isInstance(visibleObject))
|
final WorldObject wo = visibleObjects.get(j);
|
||||||
|
if ((wo == null) || (wo == object) || !clazz.isInstance(wo))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (visibleObject.getInstanceWorld() != object.getInstanceWorld())
|
if (wo.getInstanceWorld() != object.getInstanceWorld())
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (visibleObject.calculateDistance3D(object) <= range)
|
if (wo.calculateDistance3D(object) <= range)
|
||||||
{
|
{
|
||||||
c.accept(clazz.cast(visibleObject));
|
c.accept(clazz.cast(wo));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -16,8 +16,8 @@
|
|||||||
*/
|
*/
|
||||||
package org.l2jmobius.gameserver.model;
|
package org.l2jmobius.gameserver.model;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.ArrayList;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.List;
|
||||||
import java.util.concurrent.ScheduledFuture;
|
import java.util.concurrent.ScheduledFuture;
|
||||||
|
|
||||||
import org.l2jmobius.Config;
|
import org.l2jmobius.Config;
|
||||||
@@ -28,9 +28,9 @@ import org.l2jmobius.gameserver.taskmanager.RandomAnimationTaskManager;
|
|||||||
|
|
||||||
public class WorldRegion
|
public class WorldRegion
|
||||||
{
|
{
|
||||||
/** Map containing visible objects in this world region. */
|
/** List containing visible objects in this world region. */
|
||||||
private final Map<Integer, WorldObject> _visibleObjects = new ConcurrentHashMap<>();
|
private final List<WorldObject> _visibleObjects = new ArrayList<>();
|
||||||
/** Map containing nearby regions forming this world region's effective area. */
|
/** Array containing nearby regions forming this world region's effective area. */
|
||||||
private WorldRegion[] _surroundingRegions;
|
private WorldRegion[] _surroundingRegions;
|
||||||
private final int _regionX;
|
private final int _regionX;
|
||||||
private final int _regionY;
|
private final int _regionY;
|
||||||
@@ -52,8 +52,9 @@ public class WorldRegion
|
|||||||
|
|
||||||
if (!isOn)
|
if (!isOn)
|
||||||
{
|
{
|
||||||
for (WorldObject wo : _visibleObjects.values())
|
for (int i = 0; i < _visibleObjects.size(); i++)
|
||||||
{
|
{
|
||||||
|
final WorldObject wo = _visibleObjects.get(i);
|
||||||
if (wo.isAttackable())
|
if (wo.isAttackable())
|
||||||
{
|
{
|
||||||
final Attackable mob = (Attackable) wo;
|
final Attackable mob = (Attackable) wo;
|
||||||
@@ -87,15 +88,16 @@ public class WorldRegion
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for (WorldObject wo : _visibleObjects.values())
|
for (int i = 0; i < _visibleObjects.size(); i++)
|
||||||
{
|
{
|
||||||
|
final WorldObject wo = _visibleObjects.get(i);
|
||||||
if (wo.isAttackable())
|
if (wo.isAttackable())
|
||||||
{
|
{
|
||||||
// Start HP/MP/CP regeneration task.
|
// Start HP/MP/CP regeneration task.
|
||||||
((Attackable) wo).getStatus().startHpMpRegeneration();
|
((Attackable) wo).getStatus().startHpMpRegeneration();
|
||||||
RandomAnimationTaskManager.getInstance().add((Npc) wo);
|
RandomAnimationTaskManager.getInstance().add((Npc) wo);
|
||||||
}
|
}
|
||||||
else if (wo instanceof Npc)
|
else if (wo.isNpc())
|
||||||
{
|
{
|
||||||
RandomAnimationTaskManager.getInstance().add((Npc) wo);
|
RandomAnimationTaskManager.getInstance().add((Npc) wo);
|
||||||
}
|
}
|
||||||
@@ -110,13 +112,21 @@ public class WorldRegion
|
|||||||
|
|
||||||
public boolean areNeighborsEmpty()
|
public boolean areNeighborsEmpty()
|
||||||
{
|
{
|
||||||
for (WorldRegion worldRegion : _surroundingRegions)
|
for (int i = 0; i < _surroundingRegions.length; i++)
|
||||||
{
|
{
|
||||||
if (worldRegion.isActive() && worldRegion.getVisibleObjects().values().stream().anyMatch(WorldObject::isPlayable))
|
final WorldRegion worldRegion = _surroundingRegions[i];
|
||||||
|
if (worldRegion.isActive())
|
||||||
|
{
|
||||||
|
final List<WorldObject> regionObjects = worldRegion.getVisibleObjects();
|
||||||
|
for (int j = 0; j < regionObjects.size(); j++)
|
||||||
|
{
|
||||||
|
if (regionObjects.get(j).isPlayable())
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -157,9 +167,9 @@ public class WorldRegion
|
|||||||
// Then, set a timer to activate the neighbors.
|
// Then, set a timer to activate the neighbors.
|
||||||
_neighborsTask = ThreadPool.schedule(() ->
|
_neighborsTask = ThreadPool.schedule(() ->
|
||||||
{
|
{
|
||||||
for (WorldRegion worldRegion : _surroundingRegions)
|
for (int i = 0; i < _surroundingRegions.length; i++)
|
||||||
{
|
{
|
||||||
worldRegion.setActive(true);
|
_surroundingRegions[i].setActive(true);
|
||||||
}
|
}
|
||||||
}, 1000 * Config.GRID_NEIGHBOR_TURNON_TIME);
|
}, 1000 * Config.GRID_NEIGHBOR_TURNON_TIME);
|
||||||
}
|
}
|
||||||
@@ -183,8 +193,9 @@ public class WorldRegion
|
|||||||
// Suggest means: first check if a neighbor has PlayerInstances in it. If not, deactivate.
|
// Suggest means: first check if a neighbor has PlayerInstances in it. If not, deactivate.
|
||||||
_neighborsTask = ThreadPool.schedule(() ->
|
_neighborsTask = ThreadPool.schedule(() ->
|
||||||
{
|
{
|
||||||
for (WorldRegion worldRegion : _surroundingRegions)
|
for (int i = 0; i < _surroundingRegions.length; i++)
|
||||||
{
|
{
|
||||||
|
final WorldRegion worldRegion = _surroundingRegions[i];
|
||||||
if (worldRegion.areNeighborsEmpty())
|
if (worldRegion.areNeighborsEmpty())
|
||||||
{
|
{
|
||||||
worldRegion.setActive(false);
|
worldRegion.setActive(false);
|
||||||
@@ -206,7 +217,13 @@ public class WorldRegion
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
_visibleObjects.put(object.getObjectId(), object);
|
synchronized (_visibleObjects)
|
||||||
|
{
|
||||||
|
if (!_visibleObjects.contains(object))
|
||||||
|
{
|
||||||
|
_visibleObjects.add(object);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// If this is the first player to enter the region, activate self and neighbors.
|
// If this is the first player to enter the region, activate self and neighbors.
|
||||||
if (object.isPlayable() && !_active && !Config.GRIDS_ALWAYS_ON)
|
if (object.isPlayable() && !_active && !Config.GRIDS_ALWAYS_ON)
|
||||||
@@ -230,7 +247,11 @@ public class WorldRegion
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_visibleObjects.remove(object.getObjectId());
|
|
||||||
|
synchronized (_visibleObjects)
|
||||||
|
{
|
||||||
|
_visibleObjects.remove(object);
|
||||||
|
}
|
||||||
|
|
||||||
if (object.isPlayable() && areNeighborsEmpty() && !Config.GRIDS_ALWAYS_ON)
|
if (object.isPlayable() && areNeighborsEmpty() && !Config.GRIDS_ALWAYS_ON)
|
||||||
{
|
{
|
||||||
@@ -238,7 +259,7 @@ public class WorldRegion
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<Integer, WorldObject> getVisibleObjects()
|
public List<WorldObject> getVisibleObjects()
|
||||||
{
|
{
|
||||||
return _visibleObjects;
|
return _visibleObjects;
|
||||||
}
|
}
|
||||||
|
@@ -94,7 +94,7 @@ sp_cleanup.always_use_parentheses_in_expressions=true
|
|||||||
sp_cleanup.always_use_this_for_non_static_field_access=false
|
sp_cleanup.always_use_this_for_non_static_field_access=false
|
||||||
sp_cleanup.always_use_this_for_non_static_method_access=false
|
sp_cleanup.always_use_this_for_non_static_method_access=false
|
||||||
sp_cleanup.convert_functional_interfaces=true
|
sp_cleanup.convert_functional_interfaces=true
|
||||||
sp_cleanup.convert_to_enhanced_for_loop=true
|
sp_cleanup.convert_to_enhanced_for_loop=false
|
||||||
sp_cleanup.correct_indentation=false
|
sp_cleanup.correct_indentation=false
|
||||||
sp_cleanup.format_source_code=true
|
sp_cleanup.format_source_code=true
|
||||||
sp_cleanup.format_source_code_changes_only=false
|
sp_cleanup.format_source_code_changes_only=false
|
||||||
@@ -106,18 +106,23 @@ sp_cleanup.make_type_abstract_if_missing_method=false
|
|||||||
sp_cleanup.make_variable_declarations_final=true
|
sp_cleanup.make_variable_declarations_final=true
|
||||||
sp_cleanup.never_use_blocks=false
|
sp_cleanup.never_use_blocks=false
|
||||||
sp_cleanup.never_use_parentheses_in_expressions=false
|
sp_cleanup.never_use_parentheses_in_expressions=false
|
||||||
|
sp_cleanup.number_suffix=false
|
||||||
sp_cleanup.on_save_use_additional_actions=true
|
sp_cleanup.on_save_use_additional_actions=true
|
||||||
sp_cleanup.organize_imports=true
|
sp_cleanup.organize_imports=true
|
||||||
|
sp_cleanup.push_down_negation=false
|
||||||
sp_cleanup.qualify_static_field_accesses_with_declaring_class=false
|
sp_cleanup.qualify_static_field_accesses_with_declaring_class=false
|
||||||
sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true
|
sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true
|
||||||
sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true
|
sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true
|
||||||
sp_cleanup.qualify_static_member_accesses_with_declaring_class=true
|
sp_cleanup.qualify_static_member_accesses_with_declaring_class=true
|
||||||
sp_cleanup.qualify_static_method_accesses_with_declaring_class=false
|
sp_cleanup.qualify_static_method_accesses_with_declaring_class=false
|
||||||
sp_cleanup.remove_private_constructors=true
|
sp_cleanup.remove_private_constructors=true
|
||||||
|
sp_cleanup.remove_redundant_modifiers=false
|
||||||
|
sp_cleanup.remove_redundant_semicolons=false
|
||||||
sp_cleanup.remove_redundant_type_arguments=false
|
sp_cleanup.remove_redundant_type_arguments=false
|
||||||
sp_cleanup.remove_trailing_whitespaces=false
|
sp_cleanup.remove_trailing_whitespaces=false
|
||||||
sp_cleanup.remove_trailing_whitespaces_all=true
|
sp_cleanup.remove_trailing_whitespaces_all=true
|
||||||
sp_cleanup.remove_trailing_whitespaces_ignore_empty=true
|
sp_cleanup.remove_trailing_whitespaces_ignore_empty=true
|
||||||
|
sp_cleanup.remove_unnecessary_array_creation=false
|
||||||
sp_cleanup.remove_unnecessary_casts=true
|
sp_cleanup.remove_unnecessary_casts=true
|
||||||
sp_cleanup.remove_unnecessary_nls_tags=true
|
sp_cleanup.remove_unnecessary_nls_tags=true
|
||||||
sp_cleanup.remove_unused_imports=true
|
sp_cleanup.remove_unused_imports=true
|
||||||
@@ -126,11 +131,14 @@ sp_cleanup.remove_unused_private_fields=true
|
|||||||
sp_cleanup.remove_unused_private_members=false
|
sp_cleanup.remove_unused_private_members=false
|
||||||
sp_cleanup.remove_unused_private_methods=true
|
sp_cleanup.remove_unused_private_methods=true
|
||||||
sp_cleanup.remove_unused_private_types=true
|
sp_cleanup.remove_unused_private_types=true
|
||||||
|
sp_cleanup.simplify_lambda_expression_and_method_ref=false
|
||||||
sp_cleanup.sort_members=false
|
sp_cleanup.sort_members=false
|
||||||
sp_cleanup.sort_members_all=false
|
sp_cleanup.sort_members_all=false
|
||||||
sp_cleanup.use_anonymous_class_creation=false
|
sp_cleanup.use_anonymous_class_creation=false
|
||||||
|
sp_cleanup.use_autoboxing=false
|
||||||
sp_cleanup.use_blocks=true
|
sp_cleanup.use_blocks=true
|
||||||
sp_cleanup.use_blocks_only_for_return_and_throw=false
|
sp_cleanup.use_blocks_only_for_return_and_throw=false
|
||||||
|
sp_cleanup.use_directly_map_method=false
|
||||||
sp_cleanup.use_lambda=true
|
sp_cleanup.use_lambda=true
|
||||||
sp_cleanup.use_parentheses_in_expressions=true
|
sp_cleanup.use_parentheses_in_expressions=true
|
||||||
sp_cleanup.use_this_for_non_static_field_access=false
|
sp_cleanup.use_this_for_non_static_field_access=false
|
||||||
@@ -138,3 +146,4 @@ sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true
|
|||||||
sp_cleanup.use_this_for_non_static_method_access=false
|
sp_cleanup.use_this_for_non_static_method_access=false
|
||||||
sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true
|
sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true
|
||||||
sp_cleanup.use_type_arguments=false
|
sp_cleanup.use_type_arguments=false
|
||||||
|
sp_cleanup.use_unboxing=false
|
||||||
|
@@ -406,10 +406,13 @@ public class World
|
|||||||
oldRegion.removeVisibleObject(object);
|
oldRegion.removeVisibleObject(object);
|
||||||
|
|
||||||
// Go through all surrounding WorldRegion Creatures
|
// Go through all surrounding WorldRegion Creatures
|
||||||
for (WorldRegion worldRegion : oldRegion.getSurroundingRegions())
|
final WorldRegion[] surroundingRegions = oldRegion.getSurroundingRegions();
|
||||||
|
for (int i = 0; i < surroundingRegions.length; i++)
|
||||||
{
|
{
|
||||||
for (WorldObject wo : worldRegion.getVisibleObjects().values())
|
final List<WorldObject> visibleObjects = surroundingRegions[i].getVisibleObjects();
|
||||||
|
for (int j = 0; j < visibleObjects.size(); j++)
|
||||||
{
|
{
|
||||||
|
final WorldObject wo = visibleObjects.get(j);
|
||||||
if (wo == object)
|
if (wo == object)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
@@ -466,15 +469,19 @@ public class World
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (WorldRegion worldRegion : oldRegion.getSurroundingRegions())
|
final WorldRegion[] oldSurroundingRegions = oldRegion.getSurroundingRegions();
|
||||||
|
for (int i = 0; i < oldSurroundingRegions.length; i++)
|
||||||
{
|
{
|
||||||
|
final WorldRegion worldRegion = oldSurroundingRegions[i];
|
||||||
if (newRegion.isSurroundingRegion(worldRegion))
|
if (newRegion.isSurroundingRegion(worldRegion))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (WorldObject wo : worldRegion.getVisibleObjects().values())
|
final List<WorldObject> visibleObjects = worldRegion.getVisibleObjects();
|
||||||
|
for (int j = 0; j < visibleObjects.size(); j++)
|
||||||
{
|
{
|
||||||
|
final WorldObject wo = visibleObjects.get(j);
|
||||||
if (wo == object)
|
if (wo == object)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
@@ -522,15 +529,19 @@ public class World
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (WorldRegion worldRegion : newRegion.getSurroundingRegions())
|
final WorldRegion[] newSurroundingRegions = newRegion.getSurroundingRegions();
|
||||||
|
for (int i = 0; i < newSurroundingRegions.length; i++)
|
||||||
{
|
{
|
||||||
|
final WorldRegion worldRegion = newSurroundingRegions[i];
|
||||||
if (oldRegion.isSurroundingRegion(worldRegion))
|
if (oldRegion.isSurroundingRegion(worldRegion))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (WorldObject wo : worldRegion.getVisibleObjects().values())
|
final List<WorldObject> visibleObjects = worldRegion.getVisibleObjects();
|
||||||
|
for (int j = 0; j < visibleObjects.size(); j++)
|
||||||
{
|
{
|
||||||
|
final WorldObject wo = visibleObjects.get(j);
|
||||||
if ((wo == object) || (wo.getInstanceWorld() != object.getInstanceWorld()))
|
if ((wo == object) || (wo.getInstanceWorld() != object.getInstanceWorld()))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
@@ -610,27 +621,30 @@ public class World
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final WorldRegion centerWorldRegion = getRegion(object);
|
final WorldRegion worldRegion = getRegion(object);
|
||||||
if (centerWorldRegion == null)
|
if (worldRegion == null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (WorldRegion region : centerWorldRegion.getSurroundingRegions())
|
final WorldRegion[] surroundingRegions = worldRegion.getSurroundingRegions();
|
||||||
|
for (int i = 0; i < surroundingRegions.length; i++)
|
||||||
{
|
{
|
||||||
for (WorldObject visibleObject : region.getVisibleObjects().values())
|
final List<WorldObject> visibleObjects = surroundingRegions[i].getVisibleObjects();
|
||||||
|
for (int j = 0; j < visibleObjects.size(); j++)
|
||||||
{
|
{
|
||||||
if ((visibleObject == null) || (visibleObject == object) || !clazz.isInstance(visibleObject))
|
final WorldObject wo = visibleObjects.get(j);
|
||||||
|
if ((wo == null) || (wo == object) || !clazz.isInstance(wo))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (visibleObject.getInstanceWorld() != object.getInstanceWorld())
|
if (wo.getInstanceWorld() != object.getInstanceWorld())
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
c.accept(clazz.cast(visibleObject));
|
c.accept(clazz.cast(wo));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -662,29 +676,32 @@ public class World
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final WorldRegion centerWorldRegion = getRegion(object);
|
final WorldRegion worldRegion = getRegion(object);
|
||||||
if (centerWorldRegion == null)
|
if (worldRegion == null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (WorldRegion region : centerWorldRegion.getSurroundingRegions())
|
final WorldRegion[] surroundingRegions = worldRegion.getSurroundingRegions();
|
||||||
|
for (int i = 0; i < surroundingRegions.length; i++)
|
||||||
{
|
{
|
||||||
for (WorldObject visibleObject : region.getVisibleObjects().values())
|
final List<WorldObject> visibleObjects = surroundingRegions[i].getVisibleObjects();
|
||||||
|
for (int j = 0; j < visibleObjects.size(); j++)
|
||||||
{
|
{
|
||||||
if ((visibleObject == null) || (visibleObject == object) || !clazz.isInstance(visibleObject))
|
final WorldObject wo = visibleObjects.get(j);
|
||||||
|
if ((wo == null) || (wo == object) || !clazz.isInstance(wo))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (visibleObject.getInstanceWorld() != object.getInstanceWorld())
|
if (wo.getInstanceWorld() != object.getInstanceWorld())
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (visibleObject.calculateDistance3D(object) <= range)
|
if (wo.calculateDistance3D(object) <= range)
|
||||||
{
|
{
|
||||||
c.accept(clazz.cast(visibleObject));
|
c.accept(clazz.cast(wo));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -16,8 +16,8 @@
|
|||||||
*/
|
*/
|
||||||
package org.l2jmobius.gameserver.model;
|
package org.l2jmobius.gameserver.model;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.ArrayList;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.List;
|
||||||
import java.util.concurrent.ScheduledFuture;
|
import java.util.concurrent.ScheduledFuture;
|
||||||
|
|
||||||
import org.l2jmobius.Config;
|
import org.l2jmobius.Config;
|
||||||
@@ -28,9 +28,9 @@ import org.l2jmobius.gameserver.taskmanager.RandomAnimationTaskManager;
|
|||||||
|
|
||||||
public class WorldRegion
|
public class WorldRegion
|
||||||
{
|
{
|
||||||
/** Map containing visible objects in this world region. */
|
/** List containing visible objects in this world region. */
|
||||||
private final Map<Integer, WorldObject> _visibleObjects = new ConcurrentHashMap<>();
|
private final List<WorldObject> _visibleObjects = new ArrayList<>();
|
||||||
/** Map containing nearby regions forming this world region's effective area. */
|
/** Array containing nearby regions forming this world region's effective area. */
|
||||||
private WorldRegion[] _surroundingRegions;
|
private WorldRegion[] _surroundingRegions;
|
||||||
private final int _regionX;
|
private final int _regionX;
|
||||||
private final int _regionY;
|
private final int _regionY;
|
||||||
@@ -52,8 +52,9 @@ public class WorldRegion
|
|||||||
|
|
||||||
if (!isOn)
|
if (!isOn)
|
||||||
{
|
{
|
||||||
for (WorldObject wo : _visibleObjects.values())
|
for (int i = 0; i < _visibleObjects.size(); i++)
|
||||||
{
|
{
|
||||||
|
final WorldObject wo = _visibleObjects.get(i);
|
||||||
if (wo.isAttackable())
|
if (wo.isAttackable())
|
||||||
{
|
{
|
||||||
final Attackable mob = (Attackable) wo;
|
final Attackable mob = (Attackable) wo;
|
||||||
@@ -87,15 +88,16 @@ public class WorldRegion
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for (WorldObject wo : _visibleObjects.values())
|
for (int i = 0; i < _visibleObjects.size(); i++)
|
||||||
{
|
{
|
||||||
|
final WorldObject wo = _visibleObjects.get(i);
|
||||||
if (wo.isAttackable())
|
if (wo.isAttackable())
|
||||||
{
|
{
|
||||||
// Start HP/MP/CP regeneration task.
|
// Start HP/MP/CP regeneration task.
|
||||||
((Attackable) wo).getStatus().startHpMpRegeneration();
|
((Attackable) wo).getStatus().startHpMpRegeneration();
|
||||||
RandomAnimationTaskManager.getInstance().add((Npc) wo);
|
RandomAnimationTaskManager.getInstance().add((Npc) wo);
|
||||||
}
|
}
|
||||||
else if (wo instanceof Npc)
|
else if (wo.isNpc())
|
||||||
{
|
{
|
||||||
RandomAnimationTaskManager.getInstance().add((Npc) wo);
|
RandomAnimationTaskManager.getInstance().add((Npc) wo);
|
||||||
}
|
}
|
||||||
@@ -110,13 +112,21 @@ public class WorldRegion
|
|||||||
|
|
||||||
public boolean areNeighborsEmpty()
|
public boolean areNeighborsEmpty()
|
||||||
{
|
{
|
||||||
for (WorldRegion worldRegion : _surroundingRegions)
|
for (int i = 0; i < _surroundingRegions.length; i++)
|
||||||
{
|
{
|
||||||
if (worldRegion.isActive() && worldRegion.getVisibleObjects().values().stream().anyMatch(WorldObject::isPlayable))
|
final WorldRegion worldRegion = _surroundingRegions[i];
|
||||||
|
if (worldRegion.isActive())
|
||||||
|
{
|
||||||
|
final List<WorldObject> regionObjects = worldRegion.getVisibleObjects();
|
||||||
|
for (int j = 0; j < regionObjects.size(); j++)
|
||||||
|
{
|
||||||
|
if (regionObjects.get(j).isPlayable())
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -157,9 +167,9 @@ public class WorldRegion
|
|||||||
// Then, set a timer to activate the neighbors.
|
// Then, set a timer to activate the neighbors.
|
||||||
_neighborsTask = ThreadPool.schedule(() ->
|
_neighborsTask = ThreadPool.schedule(() ->
|
||||||
{
|
{
|
||||||
for (WorldRegion worldRegion : _surroundingRegions)
|
for (int i = 0; i < _surroundingRegions.length; i++)
|
||||||
{
|
{
|
||||||
worldRegion.setActive(true);
|
_surroundingRegions[i].setActive(true);
|
||||||
}
|
}
|
||||||
}, 1000 * Config.GRID_NEIGHBOR_TURNON_TIME);
|
}, 1000 * Config.GRID_NEIGHBOR_TURNON_TIME);
|
||||||
}
|
}
|
||||||
@@ -183,8 +193,9 @@ public class WorldRegion
|
|||||||
// Suggest means: first check if a neighbor has PlayerInstances in it. If not, deactivate.
|
// Suggest means: first check if a neighbor has PlayerInstances in it. If not, deactivate.
|
||||||
_neighborsTask = ThreadPool.schedule(() ->
|
_neighborsTask = ThreadPool.schedule(() ->
|
||||||
{
|
{
|
||||||
for (WorldRegion worldRegion : _surroundingRegions)
|
for (int i = 0; i < _surroundingRegions.length; i++)
|
||||||
{
|
{
|
||||||
|
final WorldRegion worldRegion = _surroundingRegions[i];
|
||||||
if (worldRegion.areNeighborsEmpty())
|
if (worldRegion.areNeighborsEmpty())
|
||||||
{
|
{
|
||||||
worldRegion.setActive(false);
|
worldRegion.setActive(false);
|
||||||
@@ -206,7 +217,13 @@ public class WorldRegion
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
_visibleObjects.put(object.getObjectId(), object);
|
synchronized (_visibleObjects)
|
||||||
|
{
|
||||||
|
if (!_visibleObjects.contains(object))
|
||||||
|
{
|
||||||
|
_visibleObjects.add(object);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// If this is the first player to enter the region, activate self and neighbors.
|
// If this is the first player to enter the region, activate self and neighbors.
|
||||||
if (object.isPlayable() && !_active && !Config.GRIDS_ALWAYS_ON)
|
if (object.isPlayable() && !_active && !Config.GRIDS_ALWAYS_ON)
|
||||||
@@ -230,7 +247,11 @@ public class WorldRegion
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_visibleObjects.remove(object.getObjectId());
|
|
||||||
|
synchronized (_visibleObjects)
|
||||||
|
{
|
||||||
|
_visibleObjects.remove(object);
|
||||||
|
}
|
||||||
|
|
||||||
if (object.isPlayable() && areNeighborsEmpty() && !Config.GRIDS_ALWAYS_ON)
|
if (object.isPlayable() && areNeighborsEmpty() && !Config.GRIDS_ALWAYS_ON)
|
||||||
{
|
{
|
||||||
@@ -238,7 +259,7 @@ public class WorldRegion
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<Integer, WorldObject> getVisibleObjects()
|
public List<WorldObject> getVisibleObjects()
|
||||||
{
|
{
|
||||||
return _visibleObjects;
|
return _visibleObjects;
|
||||||
}
|
}
|
||||||
|
@@ -94,7 +94,7 @@ sp_cleanup.always_use_parentheses_in_expressions=true
|
|||||||
sp_cleanup.always_use_this_for_non_static_field_access=false
|
sp_cleanup.always_use_this_for_non_static_field_access=false
|
||||||
sp_cleanup.always_use_this_for_non_static_method_access=false
|
sp_cleanup.always_use_this_for_non_static_method_access=false
|
||||||
sp_cleanup.convert_functional_interfaces=true
|
sp_cleanup.convert_functional_interfaces=true
|
||||||
sp_cleanup.convert_to_enhanced_for_loop=true
|
sp_cleanup.convert_to_enhanced_for_loop=false
|
||||||
sp_cleanup.correct_indentation=false
|
sp_cleanup.correct_indentation=false
|
||||||
sp_cleanup.format_source_code=true
|
sp_cleanup.format_source_code=true
|
||||||
sp_cleanup.format_source_code_changes_only=false
|
sp_cleanup.format_source_code_changes_only=false
|
||||||
@@ -106,18 +106,23 @@ sp_cleanup.make_type_abstract_if_missing_method=false
|
|||||||
sp_cleanup.make_variable_declarations_final=true
|
sp_cleanup.make_variable_declarations_final=true
|
||||||
sp_cleanup.never_use_blocks=false
|
sp_cleanup.never_use_blocks=false
|
||||||
sp_cleanup.never_use_parentheses_in_expressions=false
|
sp_cleanup.never_use_parentheses_in_expressions=false
|
||||||
|
sp_cleanup.number_suffix=false
|
||||||
sp_cleanup.on_save_use_additional_actions=true
|
sp_cleanup.on_save_use_additional_actions=true
|
||||||
sp_cleanup.organize_imports=true
|
sp_cleanup.organize_imports=true
|
||||||
|
sp_cleanup.push_down_negation=false
|
||||||
sp_cleanup.qualify_static_field_accesses_with_declaring_class=false
|
sp_cleanup.qualify_static_field_accesses_with_declaring_class=false
|
||||||
sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true
|
sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true
|
||||||
sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true
|
sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true
|
||||||
sp_cleanup.qualify_static_member_accesses_with_declaring_class=true
|
sp_cleanup.qualify_static_member_accesses_with_declaring_class=true
|
||||||
sp_cleanup.qualify_static_method_accesses_with_declaring_class=false
|
sp_cleanup.qualify_static_method_accesses_with_declaring_class=false
|
||||||
sp_cleanup.remove_private_constructors=true
|
sp_cleanup.remove_private_constructors=true
|
||||||
|
sp_cleanup.remove_redundant_modifiers=false
|
||||||
|
sp_cleanup.remove_redundant_semicolons=false
|
||||||
sp_cleanup.remove_redundant_type_arguments=false
|
sp_cleanup.remove_redundant_type_arguments=false
|
||||||
sp_cleanup.remove_trailing_whitespaces=false
|
sp_cleanup.remove_trailing_whitespaces=false
|
||||||
sp_cleanup.remove_trailing_whitespaces_all=true
|
sp_cleanup.remove_trailing_whitespaces_all=true
|
||||||
sp_cleanup.remove_trailing_whitespaces_ignore_empty=true
|
sp_cleanup.remove_trailing_whitespaces_ignore_empty=true
|
||||||
|
sp_cleanup.remove_unnecessary_array_creation=false
|
||||||
sp_cleanup.remove_unnecessary_casts=true
|
sp_cleanup.remove_unnecessary_casts=true
|
||||||
sp_cleanup.remove_unnecessary_nls_tags=true
|
sp_cleanup.remove_unnecessary_nls_tags=true
|
||||||
sp_cleanup.remove_unused_imports=true
|
sp_cleanup.remove_unused_imports=true
|
||||||
@@ -126,11 +131,14 @@ sp_cleanup.remove_unused_private_fields=true
|
|||||||
sp_cleanup.remove_unused_private_members=false
|
sp_cleanup.remove_unused_private_members=false
|
||||||
sp_cleanup.remove_unused_private_methods=true
|
sp_cleanup.remove_unused_private_methods=true
|
||||||
sp_cleanup.remove_unused_private_types=true
|
sp_cleanup.remove_unused_private_types=true
|
||||||
|
sp_cleanup.simplify_lambda_expression_and_method_ref=false
|
||||||
sp_cleanup.sort_members=false
|
sp_cleanup.sort_members=false
|
||||||
sp_cleanup.sort_members_all=false
|
sp_cleanup.sort_members_all=false
|
||||||
sp_cleanup.use_anonymous_class_creation=false
|
sp_cleanup.use_anonymous_class_creation=false
|
||||||
|
sp_cleanup.use_autoboxing=false
|
||||||
sp_cleanup.use_blocks=true
|
sp_cleanup.use_blocks=true
|
||||||
sp_cleanup.use_blocks_only_for_return_and_throw=false
|
sp_cleanup.use_blocks_only_for_return_and_throw=false
|
||||||
|
sp_cleanup.use_directly_map_method=false
|
||||||
sp_cleanup.use_lambda=true
|
sp_cleanup.use_lambda=true
|
||||||
sp_cleanup.use_parentheses_in_expressions=true
|
sp_cleanup.use_parentheses_in_expressions=true
|
||||||
sp_cleanup.use_this_for_non_static_field_access=false
|
sp_cleanup.use_this_for_non_static_field_access=false
|
||||||
@@ -138,3 +146,4 @@ sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true
|
|||||||
sp_cleanup.use_this_for_non_static_method_access=false
|
sp_cleanup.use_this_for_non_static_method_access=false
|
||||||
sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true
|
sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true
|
||||||
sp_cleanup.use_type_arguments=false
|
sp_cleanup.use_type_arguments=false
|
||||||
|
sp_cleanup.use_unboxing=false
|
||||||
|
@@ -406,10 +406,13 @@ public class World
|
|||||||
oldRegion.removeVisibleObject(object);
|
oldRegion.removeVisibleObject(object);
|
||||||
|
|
||||||
// Go through all surrounding WorldRegion Creatures
|
// Go through all surrounding WorldRegion Creatures
|
||||||
for (WorldRegion worldRegion : oldRegion.getSurroundingRegions())
|
final WorldRegion[] surroundingRegions = oldRegion.getSurroundingRegions();
|
||||||
|
for (int i = 0; i < surroundingRegions.length; i++)
|
||||||
{
|
{
|
||||||
for (WorldObject wo : worldRegion.getVisibleObjects().values())
|
final List<WorldObject> visibleObjects = surroundingRegions[i].getVisibleObjects();
|
||||||
|
for (int j = 0; j < visibleObjects.size(); j++)
|
||||||
{
|
{
|
||||||
|
final WorldObject wo = visibleObjects.get(j);
|
||||||
if (wo == object)
|
if (wo == object)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
@@ -466,15 +469,19 @@ public class World
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (WorldRegion worldRegion : oldRegion.getSurroundingRegions())
|
final WorldRegion[] oldSurroundingRegions = oldRegion.getSurroundingRegions();
|
||||||
|
for (int i = 0; i < oldSurroundingRegions.length; i++)
|
||||||
{
|
{
|
||||||
|
final WorldRegion worldRegion = oldSurroundingRegions[i];
|
||||||
if (newRegion.isSurroundingRegion(worldRegion))
|
if (newRegion.isSurroundingRegion(worldRegion))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (WorldObject wo : worldRegion.getVisibleObjects().values())
|
final List<WorldObject> visibleObjects = worldRegion.getVisibleObjects();
|
||||||
|
for (int j = 0; j < visibleObjects.size(); j++)
|
||||||
{
|
{
|
||||||
|
final WorldObject wo = visibleObjects.get(j);
|
||||||
if (wo == object)
|
if (wo == object)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
@@ -522,15 +529,19 @@ public class World
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (WorldRegion worldRegion : newRegion.getSurroundingRegions())
|
final WorldRegion[] newSurroundingRegions = newRegion.getSurroundingRegions();
|
||||||
|
for (int i = 0; i < newSurroundingRegions.length; i++)
|
||||||
{
|
{
|
||||||
|
final WorldRegion worldRegion = newSurroundingRegions[i];
|
||||||
if (oldRegion.isSurroundingRegion(worldRegion))
|
if (oldRegion.isSurroundingRegion(worldRegion))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (WorldObject wo : worldRegion.getVisibleObjects().values())
|
final List<WorldObject> visibleObjects = worldRegion.getVisibleObjects();
|
||||||
|
for (int j = 0; j < visibleObjects.size(); j++)
|
||||||
{
|
{
|
||||||
|
final WorldObject wo = visibleObjects.get(j);
|
||||||
if ((wo == object) || (wo.getInstanceWorld() != object.getInstanceWorld()))
|
if ((wo == object) || (wo.getInstanceWorld() != object.getInstanceWorld()))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
@@ -610,27 +621,30 @@ public class World
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final WorldRegion centerWorldRegion = getRegion(object);
|
final WorldRegion worldRegion = getRegion(object);
|
||||||
if (centerWorldRegion == null)
|
if (worldRegion == null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (WorldRegion region : centerWorldRegion.getSurroundingRegions())
|
final WorldRegion[] surroundingRegions = worldRegion.getSurroundingRegions();
|
||||||
|
for (int i = 0; i < surroundingRegions.length; i++)
|
||||||
{
|
{
|
||||||
for (WorldObject visibleObject : region.getVisibleObjects().values())
|
final List<WorldObject> visibleObjects = surroundingRegions[i].getVisibleObjects();
|
||||||
|
for (int j = 0; j < visibleObjects.size(); j++)
|
||||||
{
|
{
|
||||||
if ((visibleObject == null) || (visibleObject == object) || !clazz.isInstance(visibleObject))
|
final WorldObject wo = visibleObjects.get(j);
|
||||||
|
if ((wo == null) || (wo == object) || !clazz.isInstance(wo))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (visibleObject.getInstanceWorld() != object.getInstanceWorld())
|
if (wo.getInstanceWorld() != object.getInstanceWorld())
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
c.accept(clazz.cast(visibleObject));
|
c.accept(clazz.cast(wo));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -662,29 +676,32 @@ public class World
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final WorldRegion centerWorldRegion = getRegion(object);
|
final WorldRegion worldRegion = getRegion(object);
|
||||||
if (centerWorldRegion == null)
|
if (worldRegion == null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (WorldRegion region : centerWorldRegion.getSurroundingRegions())
|
final WorldRegion[] surroundingRegions = worldRegion.getSurroundingRegions();
|
||||||
|
for (int i = 0; i < surroundingRegions.length; i++)
|
||||||
{
|
{
|
||||||
for (WorldObject visibleObject : region.getVisibleObjects().values())
|
final List<WorldObject> visibleObjects = surroundingRegions[i].getVisibleObjects();
|
||||||
|
for (int j = 0; j < visibleObjects.size(); j++)
|
||||||
{
|
{
|
||||||
if ((visibleObject == null) || (visibleObject == object) || !clazz.isInstance(visibleObject))
|
final WorldObject wo = visibleObjects.get(j);
|
||||||
|
if ((wo == null) || (wo == object) || !clazz.isInstance(wo))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (visibleObject.getInstanceWorld() != object.getInstanceWorld())
|
if (wo.getInstanceWorld() != object.getInstanceWorld())
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (visibleObject.calculateDistance3D(object) <= range)
|
if (wo.calculateDistance3D(object) <= range)
|
||||||
{
|
{
|
||||||
c.accept(clazz.cast(visibleObject));
|
c.accept(clazz.cast(wo));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -16,8 +16,8 @@
|
|||||||
*/
|
*/
|
||||||
package org.l2jmobius.gameserver.model;
|
package org.l2jmobius.gameserver.model;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.ArrayList;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.List;
|
||||||
import java.util.concurrent.ScheduledFuture;
|
import java.util.concurrent.ScheduledFuture;
|
||||||
|
|
||||||
import org.l2jmobius.Config;
|
import org.l2jmobius.Config;
|
||||||
@@ -28,9 +28,9 @@ import org.l2jmobius.gameserver.taskmanager.RandomAnimationTaskManager;
|
|||||||
|
|
||||||
public class WorldRegion
|
public class WorldRegion
|
||||||
{
|
{
|
||||||
/** Map containing visible objects in this world region. */
|
/** List containing visible objects in this world region. */
|
||||||
private final Map<Integer, WorldObject> _visibleObjects = new ConcurrentHashMap<>();
|
private final List<WorldObject> _visibleObjects = new ArrayList<>();
|
||||||
/** Map containing nearby regions forming this world region's effective area. */
|
/** Array containing nearby regions forming this world region's effective area. */
|
||||||
private WorldRegion[] _surroundingRegions;
|
private WorldRegion[] _surroundingRegions;
|
||||||
private final int _regionX;
|
private final int _regionX;
|
||||||
private final int _regionY;
|
private final int _regionY;
|
||||||
@@ -52,8 +52,9 @@ public class WorldRegion
|
|||||||
|
|
||||||
if (!isOn)
|
if (!isOn)
|
||||||
{
|
{
|
||||||
for (WorldObject wo : _visibleObjects.values())
|
for (int i = 0; i < _visibleObjects.size(); i++)
|
||||||
{
|
{
|
||||||
|
final WorldObject wo = _visibleObjects.get(i);
|
||||||
if (wo.isAttackable())
|
if (wo.isAttackable())
|
||||||
{
|
{
|
||||||
final Attackable mob = (Attackable) wo;
|
final Attackable mob = (Attackable) wo;
|
||||||
@@ -87,15 +88,16 @@ public class WorldRegion
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for (WorldObject wo : _visibleObjects.values())
|
for (int i = 0; i < _visibleObjects.size(); i++)
|
||||||
{
|
{
|
||||||
|
final WorldObject wo = _visibleObjects.get(i);
|
||||||
if (wo.isAttackable())
|
if (wo.isAttackable())
|
||||||
{
|
{
|
||||||
// Start HP/MP/CP regeneration task.
|
// Start HP/MP/CP regeneration task.
|
||||||
((Attackable) wo).getStatus().startHpMpRegeneration();
|
((Attackable) wo).getStatus().startHpMpRegeneration();
|
||||||
RandomAnimationTaskManager.getInstance().add((Npc) wo);
|
RandomAnimationTaskManager.getInstance().add((Npc) wo);
|
||||||
}
|
}
|
||||||
else if (wo instanceof Npc)
|
else if (wo.isNpc())
|
||||||
{
|
{
|
||||||
RandomAnimationTaskManager.getInstance().add((Npc) wo);
|
RandomAnimationTaskManager.getInstance().add((Npc) wo);
|
||||||
}
|
}
|
||||||
@@ -110,13 +112,21 @@ public class WorldRegion
|
|||||||
|
|
||||||
public boolean areNeighborsEmpty()
|
public boolean areNeighborsEmpty()
|
||||||
{
|
{
|
||||||
for (WorldRegion worldRegion : _surroundingRegions)
|
for (int i = 0; i < _surroundingRegions.length; i++)
|
||||||
{
|
{
|
||||||
if (worldRegion.isActive() && worldRegion.getVisibleObjects().values().stream().anyMatch(WorldObject::isPlayable))
|
final WorldRegion worldRegion = _surroundingRegions[i];
|
||||||
|
if (worldRegion.isActive())
|
||||||
|
{
|
||||||
|
final List<WorldObject> regionObjects = worldRegion.getVisibleObjects();
|
||||||
|
for (int j = 0; j < regionObjects.size(); j++)
|
||||||
|
{
|
||||||
|
if (regionObjects.get(j).isPlayable())
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -157,9 +167,9 @@ public class WorldRegion
|
|||||||
// Then, set a timer to activate the neighbors.
|
// Then, set a timer to activate the neighbors.
|
||||||
_neighborsTask = ThreadPool.schedule(() ->
|
_neighborsTask = ThreadPool.schedule(() ->
|
||||||
{
|
{
|
||||||
for (WorldRegion worldRegion : _surroundingRegions)
|
for (int i = 0; i < _surroundingRegions.length; i++)
|
||||||
{
|
{
|
||||||
worldRegion.setActive(true);
|
_surroundingRegions[i].setActive(true);
|
||||||
}
|
}
|
||||||
}, 1000 * Config.GRID_NEIGHBOR_TURNON_TIME);
|
}, 1000 * Config.GRID_NEIGHBOR_TURNON_TIME);
|
||||||
}
|
}
|
||||||
@@ -183,8 +193,9 @@ public class WorldRegion
|
|||||||
// Suggest means: first check if a neighbor has PlayerInstances in it. If not, deactivate.
|
// Suggest means: first check if a neighbor has PlayerInstances in it. If not, deactivate.
|
||||||
_neighborsTask = ThreadPool.schedule(() ->
|
_neighborsTask = ThreadPool.schedule(() ->
|
||||||
{
|
{
|
||||||
for (WorldRegion worldRegion : _surroundingRegions)
|
for (int i = 0; i < _surroundingRegions.length; i++)
|
||||||
{
|
{
|
||||||
|
final WorldRegion worldRegion = _surroundingRegions[i];
|
||||||
if (worldRegion.areNeighborsEmpty())
|
if (worldRegion.areNeighborsEmpty())
|
||||||
{
|
{
|
||||||
worldRegion.setActive(false);
|
worldRegion.setActive(false);
|
||||||
@@ -206,7 +217,13 @@ public class WorldRegion
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
_visibleObjects.put(object.getObjectId(), object);
|
synchronized (_visibleObjects)
|
||||||
|
{
|
||||||
|
if (!_visibleObjects.contains(object))
|
||||||
|
{
|
||||||
|
_visibleObjects.add(object);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// If this is the first player to enter the region, activate self and neighbors.
|
// If this is the first player to enter the region, activate self and neighbors.
|
||||||
if (object.isPlayable() && !_active && !Config.GRIDS_ALWAYS_ON)
|
if (object.isPlayable() && !_active && !Config.GRIDS_ALWAYS_ON)
|
||||||
@@ -230,7 +247,11 @@ public class WorldRegion
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_visibleObjects.remove(object.getObjectId());
|
|
||||||
|
synchronized (_visibleObjects)
|
||||||
|
{
|
||||||
|
_visibleObjects.remove(object);
|
||||||
|
}
|
||||||
|
|
||||||
if (object.isPlayable() && areNeighborsEmpty() && !Config.GRIDS_ALWAYS_ON)
|
if (object.isPlayable() && areNeighborsEmpty() && !Config.GRIDS_ALWAYS_ON)
|
||||||
{
|
{
|
||||||
@@ -238,7 +259,7 @@ public class WorldRegion
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<Integer, WorldObject> getVisibleObjects()
|
public List<WorldObject> getVisibleObjects()
|
||||||
{
|
{
|
||||||
return _visibleObjects;
|
return _visibleObjects;
|
||||||
}
|
}
|
||||||
|
@@ -94,7 +94,7 @@ sp_cleanup.always_use_parentheses_in_expressions=true
|
|||||||
sp_cleanup.always_use_this_for_non_static_field_access=false
|
sp_cleanup.always_use_this_for_non_static_field_access=false
|
||||||
sp_cleanup.always_use_this_for_non_static_method_access=false
|
sp_cleanup.always_use_this_for_non_static_method_access=false
|
||||||
sp_cleanup.convert_functional_interfaces=true
|
sp_cleanup.convert_functional_interfaces=true
|
||||||
sp_cleanup.convert_to_enhanced_for_loop=true
|
sp_cleanup.convert_to_enhanced_for_loop=false
|
||||||
sp_cleanup.correct_indentation=false
|
sp_cleanup.correct_indentation=false
|
||||||
sp_cleanup.format_source_code=true
|
sp_cleanup.format_source_code=true
|
||||||
sp_cleanup.format_source_code_changes_only=false
|
sp_cleanup.format_source_code_changes_only=false
|
||||||
@@ -106,18 +106,23 @@ sp_cleanup.make_type_abstract_if_missing_method=false
|
|||||||
sp_cleanup.make_variable_declarations_final=true
|
sp_cleanup.make_variable_declarations_final=true
|
||||||
sp_cleanup.never_use_blocks=false
|
sp_cleanup.never_use_blocks=false
|
||||||
sp_cleanup.never_use_parentheses_in_expressions=false
|
sp_cleanup.never_use_parentheses_in_expressions=false
|
||||||
|
sp_cleanup.number_suffix=false
|
||||||
sp_cleanup.on_save_use_additional_actions=true
|
sp_cleanup.on_save_use_additional_actions=true
|
||||||
sp_cleanup.organize_imports=true
|
sp_cleanup.organize_imports=true
|
||||||
|
sp_cleanup.push_down_negation=false
|
||||||
sp_cleanup.qualify_static_field_accesses_with_declaring_class=false
|
sp_cleanup.qualify_static_field_accesses_with_declaring_class=false
|
||||||
sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true
|
sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true
|
||||||
sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true
|
sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true
|
||||||
sp_cleanup.qualify_static_member_accesses_with_declaring_class=true
|
sp_cleanup.qualify_static_member_accesses_with_declaring_class=true
|
||||||
sp_cleanup.qualify_static_method_accesses_with_declaring_class=false
|
sp_cleanup.qualify_static_method_accesses_with_declaring_class=false
|
||||||
sp_cleanup.remove_private_constructors=true
|
sp_cleanup.remove_private_constructors=true
|
||||||
|
sp_cleanup.remove_redundant_modifiers=false
|
||||||
|
sp_cleanup.remove_redundant_semicolons=false
|
||||||
sp_cleanup.remove_redundant_type_arguments=false
|
sp_cleanup.remove_redundant_type_arguments=false
|
||||||
sp_cleanup.remove_trailing_whitespaces=false
|
sp_cleanup.remove_trailing_whitespaces=false
|
||||||
sp_cleanup.remove_trailing_whitespaces_all=true
|
sp_cleanup.remove_trailing_whitespaces_all=true
|
||||||
sp_cleanup.remove_trailing_whitespaces_ignore_empty=true
|
sp_cleanup.remove_trailing_whitespaces_ignore_empty=true
|
||||||
|
sp_cleanup.remove_unnecessary_array_creation=false
|
||||||
sp_cleanup.remove_unnecessary_casts=true
|
sp_cleanup.remove_unnecessary_casts=true
|
||||||
sp_cleanup.remove_unnecessary_nls_tags=true
|
sp_cleanup.remove_unnecessary_nls_tags=true
|
||||||
sp_cleanup.remove_unused_imports=true
|
sp_cleanup.remove_unused_imports=true
|
||||||
@@ -126,11 +131,14 @@ sp_cleanup.remove_unused_private_fields=true
|
|||||||
sp_cleanup.remove_unused_private_members=false
|
sp_cleanup.remove_unused_private_members=false
|
||||||
sp_cleanup.remove_unused_private_methods=true
|
sp_cleanup.remove_unused_private_methods=true
|
||||||
sp_cleanup.remove_unused_private_types=true
|
sp_cleanup.remove_unused_private_types=true
|
||||||
|
sp_cleanup.simplify_lambda_expression_and_method_ref=false
|
||||||
sp_cleanup.sort_members=false
|
sp_cleanup.sort_members=false
|
||||||
sp_cleanup.sort_members_all=false
|
sp_cleanup.sort_members_all=false
|
||||||
sp_cleanup.use_anonymous_class_creation=false
|
sp_cleanup.use_anonymous_class_creation=false
|
||||||
|
sp_cleanup.use_autoboxing=false
|
||||||
sp_cleanup.use_blocks=true
|
sp_cleanup.use_blocks=true
|
||||||
sp_cleanup.use_blocks_only_for_return_and_throw=false
|
sp_cleanup.use_blocks_only_for_return_and_throw=false
|
||||||
|
sp_cleanup.use_directly_map_method=false
|
||||||
sp_cleanup.use_lambda=true
|
sp_cleanup.use_lambda=true
|
||||||
sp_cleanup.use_parentheses_in_expressions=true
|
sp_cleanup.use_parentheses_in_expressions=true
|
||||||
sp_cleanup.use_this_for_non_static_field_access=false
|
sp_cleanup.use_this_for_non_static_field_access=false
|
||||||
@@ -138,3 +146,4 @@ sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true
|
|||||||
sp_cleanup.use_this_for_non_static_method_access=false
|
sp_cleanup.use_this_for_non_static_method_access=false
|
||||||
sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true
|
sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true
|
||||||
sp_cleanup.use_type_arguments=false
|
sp_cleanup.use_type_arguments=false
|
||||||
|
sp_cleanup.use_unboxing=false
|
||||||
|
@@ -406,10 +406,13 @@ public class World
|
|||||||
oldRegion.removeVisibleObject(object);
|
oldRegion.removeVisibleObject(object);
|
||||||
|
|
||||||
// Go through all surrounding WorldRegion Creatures
|
// Go through all surrounding WorldRegion Creatures
|
||||||
for (WorldRegion worldRegion : oldRegion.getSurroundingRegions())
|
final WorldRegion[] surroundingRegions = oldRegion.getSurroundingRegions();
|
||||||
|
for (int i = 0; i < surroundingRegions.length; i++)
|
||||||
{
|
{
|
||||||
for (WorldObject wo : worldRegion.getVisibleObjects().values())
|
final List<WorldObject> visibleObjects = surroundingRegions[i].getVisibleObjects();
|
||||||
|
for (int j = 0; j < visibleObjects.size(); j++)
|
||||||
{
|
{
|
||||||
|
final WorldObject wo = visibleObjects.get(j);
|
||||||
if (wo == object)
|
if (wo == object)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
@@ -466,15 +469,19 @@ public class World
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (WorldRegion worldRegion : oldRegion.getSurroundingRegions())
|
final WorldRegion[] oldSurroundingRegions = oldRegion.getSurroundingRegions();
|
||||||
|
for (int i = 0; i < oldSurroundingRegions.length; i++)
|
||||||
{
|
{
|
||||||
|
final WorldRegion worldRegion = oldSurroundingRegions[i];
|
||||||
if (newRegion.isSurroundingRegion(worldRegion))
|
if (newRegion.isSurroundingRegion(worldRegion))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (WorldObject wo : worldRegion.getVisibleObjects().values())
|
final List<WorldObject> visibleObjects = worldRegion.getVisibleObjects();
|
||||||
|
for (int j = 0; j < visibleObjects.size(); j++)
|
||||||
{
|
{
|
||||||
|
final WorldObject wo = visibleObjects.get(j);
|
||||||
if (wo == object)
|
if (wo == object)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
@@ -522,15 +529,19 @@ public class World
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (WorldRegion worldRegion : newRegion.getSurroundingRegions())
|
final WorldRegion[] newSurroundingRegions = newRegion.getSurroundingRegions();
|
||||||
|
for (int i = 0; i < newSurroundingRegions.length; i++)
|
||||||
{
|
{
|
||||||
|
final WorldRegion worldRegion = newSurroundingRegions[i];
|
||||||
if (oldRegion.isSurroundingRegion(worldRegion))
|
if (oldRegion.isSurroundingRegion(worldRegion))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (WorldObject wo : worldRegion.getVisibleObjects().values())
|
final List<WorldObject> visibleObjects = worldRegion.getVisibleObjects();
|
||||||
|
for (int j = 0; j < visibleObjects.size(); j++)
|
||||||
{
|
{
|
||||||
|
final WorldObject wo = visibleObjects.get(j);
|
||||||
if ((wo == object) || (wo.getInstanceWorld() != object.getInstanceWorld()))
|
if ((wo == object) || (wo.getInstanceWorld() != object.getInstanceWorld()))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
@@ -610,27 +621,30 @@ public class World
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final WorldRegion centerWorldRegion = getRegion(object);
|
final WorldRegion worldRegion = getRegion(object);
|
||||||
if (centerWorldRegion == null)
|
if (worldRegion == null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (WorldRegion region : centerWorldRegion.getSurroundingRegions())
|
final WorldRegion[] surroundingRegions = worldRegion.getSurroundingRegions();
|
||||||
|
for (int i = 0; i < surroundingRegions.length; i++)
|
||||||
{
|
{
|
||||||
for (WorldObject visibleObject : region.getVisibleObjects().values())
|
final List<WorldObject> visibleObjects = surroundingRegions[i].getVisibleObjects();
|
||||||
|
for (int j = 0; j < visibleObjects.size(); j++)
|
||||||
{
|
{
|
||||||
if ((visibleObject == null) || (visibleObject == object) || !clazz.isInstance(visibleObject))
|
final WorldObject wo = visibleObjects.get(j);
|
||||||
|
if ((wo == null) || (wo == object) || !clazz.isInstance(wo))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (visibleObject.getInstanceWorld() != object.getInstanceWorld())
|
if (wo.getInstanceWorld() != object.getInstanceWorld())
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
c.accept(clazz.cast(visibleObject));
|
c.accept(clazz.cast(wo));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -662,29 +676,32 @@ public class World
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final WorldRegion centerWorldRegion = getRegion(object);
|
final WorldRegion worldRegion = getRegion(object);
|
||||||
if (centerWorldRegion == null)
|
if (worldRegion == null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (WorldRegion region : centerWorldRegion.getSurroundingRegions())
|
final WorldRegion[] surroundingRegions = worldRegion.getSurroundingRegions();
|
||||||
|
for (int i = 0; i < surroundingRegions.length; i++)
|
||||||
{
|
{
|
||||||
for (WorldObject visibleObject : region.getVisibleObjects().values())
|
final List<WorldObject> visibleObjects = surroundingRegions[i].getVisibleObjects();
|
||||||
|
for (int j = 0; j < visibleObjects.size(); j++)
|
||||||
{
|
{
|
||||||
if ((visibleObject == null) || (visibleObject == object) || !clazz.isInstance(visibleObject))
|
final WorldObject wo = visibleObjects.get(j);
|
||||||
|
if ((wo == null) || (wo == object) || !clazz.isInstance(wo))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (visibleObject.getInstanceWorld() != object.getInstanceWorld())
|
if (wo.getInstanceWorld() != object.getInstanceWorld())
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (visibleObject.calculateDistance3D(object) <= range)
|
if (wo.calculateDistance3D(object) <= range)
|
||||||
{
|
{
|
||||||
c.accept(clazz.cast(visibleObject));
|
c.accept(clazz.cast(wo));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -16,8 +16,8 @@
|
|||||||
*/
|
*/
|
||||||
package org.l2jmobius.gameserver.model;
|
package org.l2jmobius.gameserver.model;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.ArrayList;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.List;
|
||||||
import java.util.concurrent.ScheduledFuture;
|
import java.util.concurrent.ScheduledFuture;
|
||||||
|
|
||||||
import org.l2jmobius.Config;
|
import org.l2jmobius.Config;
|
||||||
@@ -28,9 +28,9 @@ import org.l2jmobius.gameserver.taskmanager.RandomAnimationTaskManager;
|
|||||||
|
|
||||||
public class WorldRegion
|
public class WorldRegion
|
||||||
{
|
{
|
||||||
/** Map containing visible objects in this world region. */
|
/** List containing visible objects in this world region. */
|
||||||
private final Map<Integer, WorldObject> _visibleObjects = new ConcurrentHashMap<>();
|
private final List<WorldObject> _visibleObjects = new ArrayList<>();
|
||||||
/** Map containing nearby regions forming this world region's effective area. */
|
/** Array containing nearby regions forming this world region's effective area. */
|
||||||
private WorldRegion[] _surroundingRegions;
|
private WorldRegion[] _surroundingRegions;
|
||||||
private final int _regionX;
|
private final int _regionX;
|
||||||
private final int _regionY;
|
private final int _regionY;
|
||||||
@@ -52,8 +52,9 @@ public class WorldRegion
|
|||||||
|
|
||||||
if (!isOn)
|
if (!isOn)
|
||||||
{
|
{
|
||||||
for (WorldObject wo : _visibleObjects.values())
|
for (int i = 0; i < _visibleObjects.size(); i++)
|
||||||
{
|
{
|
||||||
|
final WorldObject wo = _visibleObjects.get(i);
|
||||||
if (wo.isAttackable())
|
if (wo.isAttackable())
|
||||||
{
|
{
|
||||||
final Attackable mob = (Attackable) wo;
|
final Attackable mob = (Attackable) wo;
|
||||||
@@ -87,15 +88,16 @@ public class WorldRegion
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for (WorldObject wo : _visibleObjects.values())
|
for (int i = 0; i < _visibleObjects.size(); i++)
|
||||||
{
|
{
|
||||||
|
final WorldObject wo = _visibleObjects.get(i);
|
||||||
if (wo.isAttackable())
|
if (wo.isAttackable())
|
||||||
{
|
{
|
||||||
// Start HP/MP/CP regeneration task.
|
// Start HP/MP/CP regeneration task.
|
||||||
((Attackable) wo).getStatus().startHpMpRegeneration();
|
((Attackable) wo).getStatus().startHpMpRegeneration();
|
||||||
RandomAnimationTaskManager.getInstance().add((Npc) wo);
|
RandomAnimationTaskManager.getInstance().add((Npc) wo);
|
||||||
}
|
}
|
||||||
else if (wo instanceof Npc)
|
else if (wo.isNpc())
|
||||||
{
|
{
|
||||||
RandomAnimationTaskManager.getInstance().add((Npc) wo);
|
RandomAnimationTaskManager.getInstance().add((Npc) wo);
|
||||||
}
|
}
|
||||||
@@ -110,13 +112,21 @@ public class WorldRegion
|
|||||||
|
|
||||||
public boolean areNeighborsEmpty()
|
public boolean areNeighborsEmpty()
|
||||||
{
|
{
|
||||||
for (WorldRegion worldRegion : _surroundingRegions)
|
for (int i = 0; i < _surroundingRegions.length; i++)
|
||||||
{
|
{
|
||||||
if (worldRegion.isActive() && worldRegion.getVisibleObjects().values().stream().anyMatch(WorldObject::isPlayable))
|
final WorldRegion worldRegion = _surroundingRegions[i];
|
||||||
|
if (worldRegion.isActive())
|
||||||
|
{
|
||||||
|
final List<WorldObject> regionObjects = worldRegion.getVisibleObjects();
|
||||||
|
for (int j = 0; j < regionObjects.size(); j++)
|
||||||
|
{
|
||||||
|
if (regionObjects.get(j).isPlayable())
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -157,9 +167,9 @@ public class WorldRegion
|
|||||||
// Then, set a timer to activate the neighbors.
|
// Then, set a timer to activate the neighbors.
|
||||||
_neighborsTask = ThreadPool.schedule(() ->
|
_neighborsTask = ThreadPool.schedule(() ->
|
||||||
{
|
{
|
||||||
for (WorldRegion worldRegion : _surroundingRegions)
|
for (int i = 0; i < _surroundingRegions.length; i++)
|
||||||
{
|
{
|
||||||
worldRegion.setActive(true);
|
_surroundingRegions[i].setActive(true);
|
||||||
}
|
}
|
||||||
}, 1000 * Config.GRID_NEIGHBOR_TURNON_TIME);
|
}, 1000 * Config.GRID_NEIGHBOR_TURNON_TIME);
|
||||||
}
|
}
|
||||||
@@ -183,8 +193,9 @@ public class WorldRegion
|
|||||||
// Suggest means: first check if a neighbor has PlayerInstances in it. If not, deactivate.
|
// Suggest means: first check if a neighbor has PlayerInstances in it. If not, deactivate.
|
||||||
_neighborsTask = ThreadPool.schedule(() ->
|
_neighborsTask = ThreadPool.schedule(() ->
|
||||||
{
|
{
|
||||||
for (WorldRegion worldRegion : _surroundingRegions)
|
for (int i = 0; i < _surroundingRegions.length; i++)
|
||||||
{
|
{
|
||||||
|
final WorldRegion worldRegion = _surroundingRegions[i];
|
||||||
if (worldRegion.areNeighborsEmpty())
|
if (worldRegion.areNeighborsEmpty())
|
||||||
{
|
{
|
||||||
worldRegion.setActive(false);
|
worldRegion.setActive(false);
|
||||||
@@ -206,7 +217,13 @@ public class WorldRegion
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
_visibleObjects.put(object.getObjectId(), object);
|
synchronized (_visibleObjects)
|
||||||
|
{
|
||||||
|
if (!_visibleObjects.contains(object))
|
||||||
|
{
|
||||||
|
_visibleObjects.add(object);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// If this is the first player to enter the region, activate self and neighbors.
|
// If this is the first player to enter the region, activate self and neighbors.
|
||||||
if (object.isPlayable() && !_active && !Config.GRIDS_ALWAYS_ON)
|
if (object.isPlayable() && !_active && !Config.GRIDS_ALWAYS_ON)
|
||||||
@@ -230,7 +247,11 @@ public class WorldRegion
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_visibleObjects.remove(object.getObjectId());
|
|
||||||
|
synchronized (_visibleObjects)
|
||||||
|
{
|
||||||
|
_visibleObjects.remove(object);
|
||||||
|
}
|
||||||
|
|
||||||
if (object.isPlayable() && areNeighborsEmpty() && !Config.GRIDS_ALWAYS_ON)
|
if (object.isPlayable() && areNeighborsEmpty() && !Config.GRIDS_ALWAYS_ON)
|
||||||
{
|
{
|
||||||
@@ -238,7 +259,7 @@ public class WorldRegion
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<Integer, WorldObject> getVisibleObjects()
|
public List<WorldObject> getVisibleObjects()
|
||||||
{
|
{
|
||||||
return _visibleObjects;
|
return _visibleObjects;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user