瀏覽代碼

MMOCore
This is still pending cleanup and opts for this very reason please do not send contribs to this now(they wont be accepted unless its a bugfix).
Notice that this project may go on a unstable state, so its encoraged to use the compiled jar that come with l2j itself witch is suposed to be the lastest stable version.

KenM 18 年之前
父節點
當前提交
65ffcddc21

+ 7 - 0
MMOCore/.classpath

@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+	<classpathentry kind="src" path="src"/>
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+	<classpathentry kind="lib" path="lib/javolution.jar"/>
+	<classpathentry kind="output" path="bin"/>
+</classpath>

+ 17 - 0
MMOCore/.project

@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>MMOCore</name>
+	<comment></comment>
+	<projects>
+	</projects>
+	<buildSpec>
+		<buildCommand>
+			<name>org.eclipse.jdt.core.javabuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+	</buildSpec>
+	<natures>
+		<nature>org.eclipse.jdt.core.javanature</nature>
+	</natures>
+</projectDescription>

+ 256 - 0
MMOCore/.settings/org.eclipse.jdt.core.prefs

@@ -0,0 +1,256 @@
+#Sun Dec 10 22:47:16 BRST 2006
+eclipse.preferences.version=1
+org.eclipse.jdt.core.codeComplete.argumentPrefixes=
+org.eclipse.jdt.core.codeComplete.argumentSuffixes=
+org.eclipse.jdt.core.codeComplete.fieldPrefixes=
+org.eclipse.jdt.core.codeComplete.fieldSuffixes=
+org.eclipse.jdt.core.codeComplete.localPrefixes=
+org.eclipse.jdt.core.codeComplete.localSuffixes=
+org.eclipse.jdt.core.codeComplete.staticFieldPrefixes=
+org.eclipse.jdt.core.codeComplete.staticFieldSuffixes=
+org.eclipse.jdt.core.formatter.align_type_members_on_columns=false
+org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16
+org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=16
+org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call=16
+org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation=16
+org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression=16
+org.eclipse.jdt.core.formatter.alignment_for_assignment=0
+org.eclipse.jdt.core.formatter.alignment_for_binary_expression=16
+org.eclipse.jdt.core.formatter.alignment_for_compact_if=16
+org.eclipse.jdt.core.formatter.alignment_for_conditional_expression=80
+org.eclipse.jdt.core.formatter.alignment_for_enum_constants=0
+org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer=16
+org.eclipse.jdt.core.formatter.alignment_for_multiple_fields=16
+org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration=16
+org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration=16
+org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation=16
+org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration=16
+org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration=16
+org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration=16
+org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration=16
+org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration=16
+org.eclipse.jdt.core.formatter.blank_lines_after_imports=1
+org.eclipse.jdt.core.formatter.blank_lines_after_package=1
+org.eclipse.jdt.core.formatter.blank_lines_before_field=1
+org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration=0
+org.eclipse.jdt.core.formatter.blank_lines_before_imports=1
+org.eclipse.jdt.core.formatter.blank_lines_before_member_type=1
+org.eclipse.jdt.core.formatter.blank_lines_before_method=1
+org.eclipse.jdt.core.formatter.blank_lines_before_new_chunk=1
+org.eclipse.jdt.core.formatter.blank_lines_before_package=0
+org.eclipse.jdt.core.formatter.blank_lines_between_type_declarations=1
+org.eclipse.jdt.core.formatter.brace_position_for_annotation_type_declaration=next_line
+org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_array_initializer=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_block=next_line
+org.eclipse.jdt.core.formatter.brace_position_for_block_in_case=next_line
+org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration=next_line
+org.eclipse.jdt.core.formatter.brace_position_for_enum_constant=next_line
+org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration=next_line
+org.eclipse.jdt.core.formatter.brace_position_for_method_declaration=next_line
+org.eclipse.jdt.core.formatter.brace_position_for_switch=next_line
+org.eclipse.jdt.core.formatter.brace_position_for_type_declaration=next_line
+org.eclipse.jdt.core.formatter.comment.clear_blank_lines=false
+org.eclipse.jdt.core.formatter.comment.format_comments=true
+org.eclipse.jdt.core.formatter.comment.format_header=false
+org.eclipse.jdt.core.formatter.comment.format_html=true
+org.eclipse.jdt.core.formatter.comment.format_source_code=true
+org.eclipse.jdt.core.formatter.comment.indent_parameter_description=true
+org.eclipse.jdt.core.formatter.comment.indent_root_tags=true
+org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags=insert
+org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter=insert
+org.eclipse.jdt.core.formatter.comment.line_length=80
+org.eclipse.jdt.core.formatter.compact_else_if=true
+org.eclipse.jdt.core.formatter.continuation_indentation=2
+org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer=2
+org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line=false
+org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_annotation_declaration_header=true
+org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_constant_header=true
+org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header=true
+org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_type_header=true
+org.eclipse.jdt.core.formatter.indent_breaks_compare_to_cases=true
+org.eclipse.jdt.core.formatter.indent_empty_lines=false
+org.eclipse.jdt.core.formatter.indent_statements_compare_to_block=true
+org.eclipse.jdt.core.formatter.indent_statements_compare_to_body=true
+org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases=true
+org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch=true
+org.eclipse.jdt.core.formatter.indentation.size=4
+org.eclipse.jdt.core.formatter.insert_new_line_after_annotation=insert
+org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement=insert
+org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement=insert
+org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement=insert
+org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement=insert
+org.eclipse.jdt.core.formatter.insert_new_line_in_empty_annotation_declaration=insert
+org.eclipse.jdt.core.formatter.insert_new_line_in_empty_anonymous_type_declaration=insert
+org.eclipse.jdt.core.formatter.insert_new_line_in_empty_block=insert
+org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant=insert
+org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration=insert
+org.eclipse.jdt.core.formatter.insert_new_line_in_empty_method_body=insert
+org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration=insert
+org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter=insert
+org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator=insert
+org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_binary_operator=insert
+org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments=insert
+org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters=insert
+org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block=insert
+org.eclipse.jdt.core.formatter.insert_space_after_closing_paren_in_cast=insert
+org.eclipse.jdt.core.formatter.insert_space_after_colon_in_assert=insert
+org.eclipse.jdt.core.formatter.insert_space_after_colon_in_case=insert
+org.eclipse.jdt.core.formatter.insert_space_after_colon_in_conditional=insert
+org.eclipse.jdt.core.formatter.insert_space_after_colon_in_for=insert
+org.eclipse.jdt.core.formatter.insert_space_after_colon_in_labeled_statement=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_allocation_expression=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_array_initializer=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_parameters=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_throws=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_constant_arguments=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_declarations=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_explicitconstructorcall_arguments=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_increments=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_inits=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_throws=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_field_declarations=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_local_declarations=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_parameterized_type_reference=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_superinterfaces=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters=insert
+org.eclipse.jdt.core.formatter.insert_space_after_ellipsis=insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_brace_in_array_initializer=insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_allocation_expression=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_annotation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_cast=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_catch=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_constructor_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_enum_constant=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_for=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_if=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_invocation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_switch=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_synchronized=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_while=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_postfix_operator=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional=insert
+org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for=insert
+org.eclipse.jdt.core.formatter.insert_space_after_unary_operator=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter=insert
+org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator=insert
+org.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration=insert
+org.eclipse.jdt.core.formatter.insert_space_before_binary_operator=insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_brace_in_array_initializer=insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_allocation_expression=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_annotation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_cast=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_catch=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_constructor_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_enum_constant=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_for=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_if=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_invocation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_switch=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_synchronized=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_while=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_colon_in_assert=insert
+org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional=insert
+org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_colon_in_for=insert
+org.eclipse.jdt.core.formatter.insert_space_before_colon_in_labeled_statement=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_allocation_expression=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_annotation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_array_initializer=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_parameters=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_throws=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_constant_arguments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_declarations=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_explicitconstructorcall_arguments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_increments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_inits=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_throws=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_field_declarations=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_local_declarations=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_parameterized_type_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_superinterfaces=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_ellipsis=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_annotation_type_declaration=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_anonymous_type_declaration=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_array_initializer=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_block=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_constructor_declaration=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_constant=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_declaration=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_method_declaration=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_switch=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declaration=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_allocation_expression=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_type_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation_type_member_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_catch=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_constructor_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_enum_constant=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_for=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invocation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_synchronized=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while=insert
+org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_return=insert
+org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional=insert
+org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_semicolon=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_unary_operator=do not insert
+org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer=do not insert
+org.eclipse.jdt.core.formatter.insert_space_between_empty_brackets_in_array_allocation_expression=do not insert
+org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_annotation_type_member_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_enum_constant=do not insert
+org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation=do not insert
+org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line=false
+org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line=false
+org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line=false
+org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line=false
+org.eclipse.jdt.core.formatter.lineSplit=80
+org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body=0
+org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve=1
+org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line=true
+org.eclipse.jdt.core.formatter.tabulation.char=space
+org.eclipse.jdt.core.formatter.tabulation.size=4
+org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations=false

File diff suppressed because it is too large
+ 9 - 0
MMOCore/.settings/org.eclipse.jdt.ui.prefs


+ 6 - 0
MMOCore/.settings/org.eclipse.wst.validation.prefs

@@ -0,0 +1,6 @@
+#Tue Mar 13 21:21:27 BRT 2007
+DELEGATES_PREFERENCE=delegateValidatorListorg.eclipse.wst.wsdl.validation.internal.eclipse.WSDLDelegatingValidator\=org.eclipse.wst.wsdl.validation.internal.eclipse.Validator;org.eclipse.wst.xsd.core.internal.validation.eclipse.XSDDelegatingValidator\=org.eclipse.wst.xsd.core.internal.validation.eclipse.Validator;
+USER_BUILD_PREFERENCE=enabledBuildValidatorListorg.eclipse.wst.wsi.ui.internal.WSIMessageValidator;org.eclipse.wst.wsdl.validation.internal.eclipse.WSDLDelegatingValidator;org.eclipse.wst.xsd.core.internal.validation.eclipse.XSDDelegatingValidator;org.eclipse.wst.html.internal.validation.HTMLValidator;org.eclipse.wst.dtd.core.internal.validation.eclipse.Validator;org.eclipse.wst.xml.core.internal.validation.eclipse.Validator;
+USER_MANUAL_PREFERENCE=enabledManualValidatorListorg.eclipse.wst.wsi.ui.internal.WSIMessageValidator;org.eclipse.wst.wsdl.validation.internal.eclipse.WSDLDelegatingValidator;org.eclipse.wst.xsd.core.internal.validation.eclipse.XSDDelegatingValidator;org.eclipse.wst.html.internal.validation.HTMLValidator;org.eclipse.wst.dtd.core.internal.validation.eclipse.Validator;org.eclipse.wst.xml.core.internal.validation.eclipse.Validator;
+USER_PREFERENCE=overrideGlobalPreferencesfalse
+eclipse.preferences.version=1

+ 73 - 0
MMOCore/build.xml

@@ -0,0 +1,73 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project name="MMOCore" default="dist" basedir=".">
+	<description>
+        MMOCore
+    </description>
+    
+    <property name="src" location="src"/>
+    <property name="lib" location="lib"/>
+    <property name="build" location="build"/>
+    <property name="build.classes" location="${build}/classes"/>
+    <property name="build.dist" location="${build}/dist"/>
+    
+    <path id="classpath">
+        <fileset dir="${lib}">
+            <include name="javolution.jar"/>
+        </fileset>
+    </path>
+    
+    <target name="init"
+    	depends="clean"
+    	description="Create the output directories.">
+        <mkdir dir="${build}"/>
+        <mkdir dir="${build.classes}"/>
+        <mkdir dir="${build.dist}" />
+    </target>
+    
+    <target name="compile"
+            depends="init"
+            description="Compile the source.">
+
+        <javac destdir="${build.classes}"
+               optimize="off"
+               debug="on"
+               source="1.5"
+               target="1.5"
+               nowarn="off">
+            <src path="${src}"/>
+            <classpath refid="classpath"/>   
+        </javac>
+    </target>
+    
+    <target name="jar"
+            depends="compile"
+            description="Create the jar file">
+
+        <jar destfile="${build}/mmocore.jar">
+            <fileset dir="${build.classes}"/>
+            <manifest>
+                <attribute name="Main-Class" value="com.l2jserver.mmocore.MMOCore"/>
+                <attribute name="Class-Path" value="javolution.jar"/>
+            </manifest>
+        </jar>
+        
+   		<copy todir="${build.dist}">
+			<fileset dir="${src}/../lib">
+				<include name="*.jar"/>
+			</fileset>
+		</copy>
+	</target>
+	
+	<target name="dist"
+		depends="jar"
+		description="Generates a happy zip with the MMOCore">
+        <zip destfile="${build}/mmocore.zip"
+             basedir="${build.dist}" />
+    </target>
+    
+    
+    <target name="clean"
+            description="Remove the output directories">
+        <delete dir="${build}"/>
+    </target>
+</project>

二進制
MMOCore/lib/javolution.jar


+ 52 - 0
MMOCore/src/com/l2jserver/mmocore/network/AbstractPacket.java

@@ -0,0 +1,52 @@
+/* This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA.
+ *
+ * http://www.gnu.org/copyleft/gpl.html
+ */
+package com.l2jserver.mmocore.network;
+
+import java.nio.ByteBuffer;
+
+
+/**
+ * @author KenM
+ *
+ */
+public abstract class AbstractPacket<T extends MMOClient>
+{
+    protected ByteBuffer _buf;
+    
+    protected T _client;
+    
+    protected void setClient(T client)
+    {
+        _client = client;
+    }
+    
+    public T getClient()
+    {
+        return _client;
+    }
+    
+    protected void setByteBuffer(ByteBuffer buf)
+    {
+        _buf = buf;
+    }
+    
+    protected ByteBuffer getByteBuffer()
+    {
+        return _buf;
+    }
+}

+ 29 - 0
MMOCore/src/com/l2jserver/mmocore/network/IAcceptFilter.java

@@ -0,0 +1,29 @@
+/* This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA.
+ *
+ * http://www.gnu.org/copyleft/gpl.html
+ */
+package com.l2jserver.mmocore.network;
+
+import java.nio.channels.SocketChannel;
+
+/**
+ * @author KenM
+ *
+ */
+public interface IAcceptFilter
+{
+    public boolean accept(SocketChannel sc);
+}

+ 27 - 0
MMOCore/src/com/l2jserver/mmocore/network/IClientFactory.java

@@ -0,0 +1,27 @@
+/* This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA.
+ *
+ * http://www.gnu.org/copyleft/gpl.html
+ */
+package com.l2jserver.mmocore.network;
+
+/**
+ * @author KenM
+ *
+ */
+public interface IClientFactory<T extends MMOClient>
+{
+    public T create(MMOConnection<T> con);
+}

+ 28 - 0
MMOCore/src/com/l2jserver/mmocore/network/IMMOExecutor.java

@@ -0,0 +1,28 @@
+/* This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA.
+ *
+ * http://www.gnu.org/copyleft/gpl.html
+ */
+package com.l2jserver.mmocore.network;
+
+
+/**
+ * @author KenM
+ *
+ */
+public interface IMMOExecutor<T extends MMOClient>
+{
+    public void execute(ReceivablePacket<T> packet);
+}

+ 30 - 0
MMOCore/src/com/l2jserver/mmocore/network/IPacketHandler.java

@@ -0,0 +1,30 @@
+/* This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA.
+ *
+ * http://www.gnu.org/copyleft/gpl.html
+ */
+package com.l2jserver.mmocore.network;
+
+import java.nio.ByteBuffer;
+
+
+/**
+ * @author KenM
+ *
+ */
+public interface IPacketHandler<T extends MMOClient>
+{
+    public ReceivablePacket<T> handlePacket(ByteBuffer buf, T client);
+}

+ 68 - 0
MMOCore/src/com/l2jserver/mmocore/network/MMOClient.java

@@ -0,0 +1,68 @@
+/* This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA.
+ *
+ * http://www.gnu.org/copyleft/gpl.html
+ */
+package com.l2jserver.mmocore.network;
+
+import java.nio.ByteBuffer;
+
+/**
+ * @author KenM
+ *
+ */
+public abstract class MMOClient<T extends MMOConnection>
+{
+    private T _connection;
+    
+    @SuppressWarnings("unchecked")
+    public MMOClient(T con)
+    {
+        this.setConnection(con);
+        con.setClient(this);
+    }
+    
+    protected void setConnection(T con)
+    {
+        _connection = con;
+    }
+    
+    public T getConnection()
+    {
+        return _connection;
+    }
+    
+    public void closeNow()
+    {
+        this.getConnection().closeNow();
+    }
+    
+    public void closeLater()
+    {
+        this.getConnection().closeLater();
+    }
+    
+    public abstract boolean decrypt(ByteBuffer buf, int size);
+    
+    public abstract boolean encrypt(ByteBuffer buf, int size);
+    
+    protected void onDisconection()
+    {
+    }
+    
+    protected void onForcedDisconnection()
+    {
+    }
+}

+ 226 - 0
MMOCore/src/com/l2jserver/mmocore/network/MMOConnection.java

@@ -0,0 +1,226 @@
+/* This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA.
+ *
+ * http://www.gnu.org/copyleft/gpl.html
+ */
+package com.l2jserver.mmocore.network;
+
+import java.nio.ByteBuffer;
+import java.nio.channels.CancelledKeyException;
+import java.nio.channels.SelectionKey;
+import java.nio.channels.SocketChannel;
+
+
+import javolution.util.FastList;
+
+/**
+ * @author KenM
+ *
+ */
+public class MMOConnection<T extends MMOClient>
+{
+    private final SelectorThread<T> _selectorThread;
+    private T _client;
+    
+    private SocketChannel _socketChannel;
+    private FastList<SendablePacket<T>> _sendQueue = new FastList<SendablePacket<T>>();
+    private SelectionKey _selectionKey;
+    
+    private ByteBuffer _readBuffer;
+    private ByteBuffer _writeBuffer;
+    
+    private boolean _pendingClose;
+    
+    public MMOConnection(SelectorThread<T> selectorThread, SocketChannel sc, SelectionKey key)
+    {
+        _selectorThread = selectorThread;
+        this.setSocketChannel(sc);
+        this.setSelectionKey(key);
+    }
+    
+    protected void setClient(T client)
+    {
+        _client = client;
+    }
+    
+    protected T getClient()
+    {
+        return _client;
+    }
+    
+    public void sendPacket(SendablePacket<T> sp)
+    {
+        sp.setClient(this.getClient());
+        synchronized (this.getSendQueue())
+        {
+            if (!_pendingClose)
+            {
+                try
+                {
+                    this.getSelectionKey().interestOps(this.getSelectionKey().interestOps() | SelectionKey.OP_WRITE);
+                    this.getSendQueue().addLast(sp);
+                }
+                catch (CancelledKeyException e)
+                {
+                    // ignore
+                }
+            }
+        }
+    }
+    
+    protected SelectorThread<T> getSelectorThread()
+    {
+        return _selectorThread;
+    }
+    
+    protected void setSelectionKey(SelectionKey key)
+    {
+        _selectionKey = key;
+    }
+    
+    protected SelectionKey getSelectionKey()
+    {
+        return _selectionKey;
+    }
+    
+    protected void enableReadInterest()
+    {
+        try
+        {
+            this.getSelectionKey().interestOps(this.getSelectionKey().interestOps() | SelectionKey.OP_READ);
+        }
+        catch (CancelledKeyException e)
+        {
+            // ignore
+        }
+    }
+    
+    protected void disableReadInterest()
+    {
+        try
+        {
+            this.getSelectionKey().interestOps(this.getSelectionKey().interestOps() & ~SelectionKey.OP_READ);
+        }
+        catch (CancelledKeyException e)
+        {
+            // ignore
+        }
+    }
+    
+    protected void enableWriteInterest()
+    {
+        try
+        {
+            this.getSelectionKey().interestOps(this.getSelectionKey().interestOps() | SelectionKey.OP_WRITE);
+        }
+        catch (CancelledKeyException e)
+        {
+            // ignore
+        }
+    }
+    
+    protected void disableWriteInterest()
+    {
+        try
+        {
+            this.getSelectionKey().interestOps(this.getSelectionKey().interestOps() & ~SelectionKey.OP_WRITE);
+        }
+        catch (CancelledKeyException e)
+        {
+            // ignore
+        }
+    }
+    
+    protected void setSocketChannel(SocketChannel sc)
+    {
+        _socketChannel = sc;
+    }
+    
+    public SocketChannel getSocketChannel()
+    {
+        return _socketChannel;
+    }
+    
+    protected FastList<SendablePacket<T>> getSendQueue()
+    {
+        return _sendQueue;
+    }
+    
+    protected void setWriteBuffer(ByteBuffer buf)
+    {
+        _writeBuffer = buf;
+    }
+    
+    protected ByteBuffer getWriteBuffer()
+    {
+        return _writeBuffer;
+    }
+    
+    protected void setReadBuffer(ByteBuffer buf)
+    {
+        _readBuffer = buf;
+    }
+    
+    protected ByteBuffer getReadBuffer()
+    {
+        return _readBuffer;
+    }
+    
+    public boolean isClosed()
+    {
+        return _pendingClose;
+    }
+    
+    protected void closeNow()
+    {
+        synchronized (this.getSendQueue())
+        {
+            _pendingClose = true;
+            this.getSendQueue().clear();
+            this.disableWriteInterest();
+        }
+        this.getSelectorThread().closeConnection(this);
+    }
+    
+    public void close(SendablePacket<T> sp)
+    {
+        synchronized (this.getSendQueue())
+        {
+            this.getSendQueue().clear();
+            this.sendPacket(sp);
+            _pendingClose = true;
+        }
+        this.getSelectorThread().closeConnection(this);
+    }
+    
+    protected void closeLater()
+    {
+        synchronized (this.getSendQueue())
+        {
+            _pendingClose = true;
+        }
+        this.getSelectorThread().closeConnection(this);
+    }
+    
+    protected void onDisconection()
+    {
+        this.getClient().onDisconection();
+    }
+    
+    protected void onForcedDisconnection()
+    {
+        this.getClient().onForcedDisconnection();
+    }
+}

+ 91 - 0
MMOCore/src/com/l2jserver/mmocore/network/ReceivablePacket.java

@@ -0,0 +1,91 @@
+/* This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA.
+ *
+ * http://www.gnu.org/copyleft/gpl.html
+ */
+package com.l2jserver.mmocore.network;
+
+
+import javolution.text.TextBuilder;
+
+/**
+ * @author KenM
+ *
+ */
+public abstract class ReceivablePacket<T extends MMOClient> extends AbstractPacket<T> implements Runnable
+{
+    protected ReceivablePacket()
+    {
+        
+    }
+    
+    protected int getAvaliableBytes()
+    {
+        return this.getByteBuffer().remaining();
+    }
+    
+    protected abstract boolean read();
+    
+    public abstract void run();
+    
+    protected void readB(byte[] dst)
+    {
+        this.getByteBuffer().get(dst);
+    }
+    
+    protected void readB(byte[] dst, int offset, int len)
+    {
+        this.getByteBuffer().get(dst, offset, len);
+    }
+    
+    protected int readC()
+    {
+        return this.getByteBuffer().get() & 0xFF;
+    }
+    
+    protected int readH()
+    {
+        return this.getByteBuffer().getShort() & 0xFFFF;
+    }
+    
+    protected int readD()
+    {
+        return this.getByteBuffer().getInt();
+    }
+    
+    protected long readQ()
+    {
+        return this.getByteBuffer().getLong();
+    }
+    
+    protected double readF()
+    {
+        return this.getByteBuffer().getDouble();
+    }
+    
+    protected String readS()
+    {
+        TextBuilder tb = TextBuilder.newInstance();
+        char ch;
+        
+        while ((ch = this.getByteBuffer().getChar()) != 0)
+        {
+            tb.append(ch);
+        }
+        String str = tb.stringValue();
+        TextBuilder.recycle(tb);
+        return str;
+    }
+}

+ 82 - 0
MMOCore/src/com/l2jserver/mmocore/network/SelectorConfig.java

@@ -0,0 +1,82 @@
+/* This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA.
+ *
+ * http://www.gnu.org/copyleft/gpl.html
+ */
+package com.l2jserver.mmocore.network;
+
+import java.nio.ByteOrder;
+
+/**
+ * @author KenM
+ *
+ */
+public class SelectorConfig
+{
+    
+    private int READ_BUFFER_SIZE = 64*1024;
+    private int WRITE_BUFFER_SIZE = 64*1024;
+    private HeaderSize HEADER_TYPE = HeaderSize.SHORT_HEADER;
+    private int HELPER_BUFFER_SIZE = 64*1024;
+    private int HELPER_BUFFER_COUNT = 20;
+    private ByteOrder BYTE_ORDER = ByteOrder.LITTLE_ENDIAN;
+    
+    /**
+     * BYTE_HEADER: unsigned byte, max size: 255 <BR>
+     * SHORT_HEADER: unsigned short, max size: 65535<BR>
+     * INT_HEADER: signed integer, max size: Integer.MAX_SIZE<BR>
+     * @author KenM
+     */
+    public static enum HeaderSize
+    { 
+        BYTE_HEADER,
+        SHORT_HEADER,
+        INT_HEADER,
+    }
+    
+    public SelectorConfig()
+    {
+    }
+    
+    public int getReadBufferSize()
+    {
+        return READ_BUFFER_SIZE;
+    }
+    
+    public int getWriteBufferSize()
+    {
+        return READ_BUFFER_SIZE;
+    }
+    
+    public int getHelperBufferSize()
+    {
+        return HELPER_BUFFER_SIZE;
+    }
+    
+    public int getHelperBufferCount()
+    {
+        return HELPER_BUFFER_COUNT;
+    }
+    
+    public ByteOrder getByteOrder()
+    {
+        return BYTE_ORDER;
+    }
+    
+    public HeaderSize getHeaderType()
+    {
+        return HEADER_TYPE;
+    }
+}

+ 51 - 0
MMOCore/src/com/l2jserver/mmocore/network/SelectorServerConfig.java

@@ -0,0 +1,51 @@
+/* This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA.
+ *
+ * http://www.gnu.org/copyleft/gpl.html
+ */
+package com.l2jserver.mmocore.network;
+
+import java.net.InetAddress;
+
+/**
+ * @author KenM
+ *
+ */
+public class SelectorServerConfig extends SelectorConfig
+{
+    private final int SERVER_PORT;
+    private final InetAddress SERVER_ADDRESS;
+    
+    public SelectorServerConfig(int port)
+    {
+        this(null, port);
+    }
+    
+    public SelectorServerConfig(InetAddress address, int port)
+    {
+        SERVER_PORT = port;
+        SERVER_ADDRESS = address;
+    }
+    
+    public int getPort()
+    {
+        return SERVER_PORT;
+    }
+    
+    public InetAddress getAddress()
+    {
+        return SERVER_ADDRESS;
+    }
+}

+ 755 - 0
MMOCore/src/com/l2jserver/mmocore/network/SelectorThread.java

@@ -0,0 +1,755 @@
+/* This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA.
+ *
+ * http://www.gnu.org/copyleft/gpl.html
+ */
+package com.l2jserver.mmocore.network;
+
+import java.io.IOException;
+import java.net.InetAddress;
+import java.net.InetSocketAddress;
+import java.net.ServerSocket;
+import java.nio.ByteBuffer;
+import java.nio.ByteOrder;
+import java.nio.channels.ClosedChannelException;
+import java.nio.channels.SelectionKey;
+import java.nio.channels.Selector;
+import java.nio.channels.ServerSocketChannel;
+import java.nio.channels.SocketChannel;
+import java.util.Iterator;
+import java.util.Set;
+
+import com.l2jserver.mmocore.network.SelectorConfig.HeaderSize;
+
+
+import javolution.util.FastList;
+
+/**
+ * @author KenM<BR>
+ * Parts of design based on networkcore from WoodenGil
+ */
+public class SelectorThread<T extends MMOClient> extends Thread
+{
+    private Selector _selector;
+    
+    // Implementations
+    private IPacketHandler<T> _packetHandler;
+    private IMMOExecutor<T> _executor;
+    private IClientFactory<T> _clientFactory;
+    private IAcceptFilter _acceptFilter;
+    
+    private boolean _shutdown;
+
+    // Pending Close
+    private FastList<MMOConnection<T>> _pendingClose = new FastList<MMOConnection<T>>();
+    
+    // Configs
+    private InetAddress ADDRESS;
+    private int PORT;
+    private int HELPER_BUFFER_SIZE;
+    private int HELPER_BUFFER_COUNT;
+    private int HEADER_SIZE = 2;
+    private ByteOrder BYTE_ORDER;
+    private HeaderSize HEADER_TYPE;
+
+    // MAIN BUFFERS
+    private ByteBuffer WRITE_BUFFER;
+    private ByteBuffer READ_BUFFER;
+
+    // ByteBuffers General Purpose Pool
+    private final FastList<ByteBuffer> _bufferPool = new FastList<ByteBuffer>();
+
+    public SelectorThread(SelectorConfig sc, IPacketHandler<T> packetHandler, IMMOExecutor<T> executor) throws IOException
+    {
+        this.readConfig(sc);
+
+        this.initBufferPool();
+        this.setPacketHandler(packetHandler);
+        this.setExecutor(executor);
+        this.initializeSelector();
+    }
+
+    public SelectorThread(SelectorServerConfig ssc, IPacketHandler<T> packetHandler, IClientFactory<T> clientFactory, IMMOExecutor<T> executor) throws IOException
+    {
+        this.readConfig(ssc);
+        
+        PORT = ssc.getPort();
+        ADDRESS = ssc.getAddress();
+        
+        this.initBufferPool();
+        this.setPacketHandler(packetHandler);
+        this.setClientFactory(clientFactory);
+        this.setExecutor(executor);
+        this.initializeSelector();
+    }
+
+    protected void readConfig(SelectorConfig sc)
+    {
+        HELPER_BUFFER_SIZE = sc.getHelperBufferSize();
+        HELPER_BUFFER_COUNT = sc.getHelperBufferCount();
+        BYTE_ORDER = sc.getByteOrder();
+
+        WRITE_BUFFER = ByteBuffer.wrap(new byte[sc.getWriteBufferSize()]).order(BYTE_ORDER);
+        READ_BUFFER = ByteBuffer.wrap(new byte[sc.getReadBufferSize()]).order(BYTE_ORDER);
+
+        HEADER_TYPE = sc.getHeaderType();
+    }
+
+    protected void initBufferPool()
+    {
+        for (int i = 0; i < HELPER_BUFFER_COUNT; i++)
+        {
+            this.getFreeBuffers().addLast(ByteBuffer.wrap(new byte[HELPER_BUFFER_SIZE]).order(BYTE_ORDER));
+        }
+    }
+
+    public void openServerSocket() throws IOException
+    {
+
+        ServerSocketChannel ssc = ServerSocketChannel.open();
+        ssc.configureBlocking(false);
+
+        ServerSocket ss = ssc.socket();
+        if (ADDRESS == null)
+        {
+            ss.bind(new InetSocketAddress(PORT));
+        }
+        else
+        {
+            ss.bind(new InetSocketAddress(ADDRESS, PORT));
+        }
+
+        ssc.register(this.getSelector(), SelectionKey.OP_ACCEPT);
+    }
+
+    protected void initializeSelector() throws IOException
+    {
+        this.setName("SelectorThread-"+this.getId());
+        this.setSelector(Selector.open());
+    }
+
+    public ByteBuffer getPooledBuffer()
+    {
+        if (this.getFreeBuffers().isEmpty())
+        {
+            return ByteBuffer.wrap(new byte[HELPER_BUFFER_SIZE]).order(BYTE_ORDER);
+        }
+        else
+        {
+            return this.getFreeBuffers().removeFirst();
+        }
+    }
+
+    public void recycleBuffer(ByteBuffer buf)
+    {
+        if (this.getFreeBuffers().size() < HELPER_BUFFER_COUNT)
+        {
+            buf.clear();
+            this.getFreeBuffers().addLast(buf);
+        }
+    }
+
+    public FastList<ByteBuffer> getFreeBuffers()
+    {
+        return _bufferPool;
+    }
+    
+    public SelectionKey registerClientSocket(SocketChannel sc, int interestOps) throws ClosedChannelException
+    {
+        SelectionKey sk = null;
+        
+        sk = sc.register(this.getSelector(), interestOps);
+
+        return sk;
+    }
+
+    public void run()
+    {
+        System.out.println("Selector Started");
+        int totalKeys = 0;
+        Iterator<SelectionKey> iter;
+        SelectionKey key;
+        MMOConnection<T> con;
+        FastList.Node<MMOConnection<T>> n, end, temp;
+        
+        // main loop
+        for (;;)
+        {
+            // check for shutdown
+            if (this.isShuttingDown())
+            {
+                this.closeSelectorThread();
+                break;
+            }
+
+            try
+            {
+                totalKeys = this.getSelector().selectNow();
+            }
+            catch (IOException e)
+            {
+                //TODO logging
+                e.printStackTrace();
+            }
+            //System.out.println("Selector Selected "+totalKeys);
+
+            if (totalKeys > 0)
+            {
+                Set<SelectionKey> keys = this.getSelector().selectedKeys();
+                iter = keys.iterator();
+
+
+
+                while (iter.hasNext())
+                {
+                    key = iter.next();
+                    iter.remove();
+
+                    switch (key.readyOps())
+                    {
+                        case SelectionKey.OP_CONNECT:
+                            this.finishConnection(key);
+                            break;
+                        case SelectionKey.OP_ACCEPT:
+                            this.acceptConnection(key);
+                            break;
+                        case SelectionKey.OP_READ:
+                            this.readPacket(key);
+                            break;
+                        case SelectionKey.OP_WRITE:
+                            this.writePacket(key);
+                            break;
+                        case SelectionKey.OP_READ | SelectionKey.OP_WRITE:
+                            this.writePacket(key);
+                            // key might have been invalidated on writePacket
+                            if (key.isValid())
+                            {
+                                this.readPacket(key);
+                            }
+                            break;
+                    }
+                }
+            }
+            
+            // process pending close
+            for (n = this.getPendingClose().head(), end = this.getPendingClose().tail(); (n = n.getNext()) != end;)
+            {
+                con = n.getValue();
+                if (con.getSendQueue().isEmpty())
+                {
+                    temp = n.getPrevious();
+                    this.getPendingClose().delete(n);
+                    n = temp;
+                    this.closeConnectionImpl(con);
+                }
+            }
+            
+            try
+            {
+                Thread.sleep(1);
+            }
+            catch (InterruptedException e)
+            {
+                e.printStackTrace();
+            }
+        }
+
+
+    }
+
+    @SuppressWarnings("unchecked")
+    protected void finishConnection(SelectionKey key)
+    {
+        try
+        {
+            ((SocketChannel) key.channel()).finishConnect();
+        }
+        catch (IOException e)
+        {
+            T client = (T) key.attachment();
+            client.getConnection().onForcedDisconnection();
+            this.closeConnectionImpl(client.getConnection());
+        }
+
+        // key might have been invalidated on finishConnect()
+        if (key.isValid())
+        {
+            key.interestOps(key.interestOps() | SelectionKey.OP_READ);
+            key.interestOps(key.interestOps() & ~SelectionKey.OP_CONNECT);
+        }
+    }
+
+    protected void acceptConnection(SelectionKey key)
+    {
+        SocketChannel sc;
+        try
+        {
+            while ((sc = ((ServerSocketChannel) key.channel()).accept()) != null)
+            {
+                if (this.getAcceptFilter() == null || this.getAcceptFilter().accept(sc))
+                {
+                    sc.configureBlocking(false);
+                    SelectionKey clientKey = sc.register(this.getSelector(), SelectionKey.OP_READ /*| SelectionKey.OP_WRITE*/);
+                    clientKey.attach(this.getClientFactory().create(new MMOConnection<T>(this, sc, clientKey)));
+                }
+                else
+                {
+                    key.cancel();
+                    sc.socket().close();
+                }
+            }
+        }
+        catch (IOException e)
+        {
+            e.printStackTrace();
+        }
+    }
+
+    @SuppressWarnings("unchecked")
+    protected void readPacket(SelectionKey key)
+    {
+        T client = (T) key.attachment();
+        MMOConnection con = client.getConnection();
+
+        ByteBuffer buf;
+        if ((buf = con.getReadBuffer()) == null)
+        {
+            buf = READ_BUFFER;
+        }
+        else
+        {
+            //buf.limit(buf.capacity());
+            //buf.position()
+            //System.out.println("TEM BUF PENDENTE LIMIT: "+buf.limit());
+        }
+        int result = -2;
+        
+        // if we try to to do a read with no space in the buffer it will read 0 bytes
+        // going into infinite loop
+        if (buf.position() == buf.limit())
+        {
+            // should never happen
+            System.out.println("POS ANTES SC.READ(): "+buf.position()+" limit: "+buf.limit());
+            System.out.println("NOOBISH ERROR "+( buf == READ_BUFFER ? "READ_BUFFER" : "temp"));
+            System.exit(0);
+        }
+
+        try
+        {
+            result = con.getSocketChannel().read(buf);
+        }
+        catch (IOException e)
+        {
+            //error handling goes bellow
+        }
+        
+        //System.out.println("LEU: "+result+" pos: "+buf.position());
+        if (result > 0)
+        {
+            // TODO this should be done vefore even reading
+            if (!con.isClosed())
+            {
+                buf.flip();
+                // try to read as many packets as possible
+                while (this.tryReadPacket(client, buf));
+            }
+        }
+        else if (result == 0)
+        {
+            // read interest but nothing to read? wtf?
+            System.out.println("NOOBISH ERROR 2 THE MISSION");
+            System.exit(0);
+        }
+        else if (result == -1)
+        {
+            this.closeConnectionImpl(con);
+        }
+        else
+        {
+            con.onForcedDisconnection();
+            this.closeConnectionImpl(con);
+        }
+    }
+
+    protected boolean tryReadPacket(T client, ByteBuffer buf)
+    {
+        MMOConnection con = client.getConnection();
+        //System.out.println("BUFF POS ANTES DE LER: "+buf.position()+" - REMAINING: "+buf.remaining());
+
+        if (buf.hasRemaining())
+        {
+            int result = buf.remaining();
+
+            // then check if there are enough bytes for the header
+            if (result >= HEADER_SIZE)
+            {
+                // then read header and check if we have the whole packet
+                int size = this.getHeaderValue(buf);
+                //System.out.println("IF: ("+size+" <= "+result+") => (size <= result)");
+                if (size <= result)
+                {
+                    //System.out.println("BOA");
+
+                    // avoid parsing dummy packets (packets without body)
+                    if (size > HEADER_SIZE)
+                    {
+                        this.parseClientPacket(buf, size, client);
+                    }
+
+                    // if we are done with this buffer
+                    if (!buf.hasRemaining())
+                    {
+                        //System.out.println("BOA 2");
+                        if (buf != READ_BUFFER)
+                        {
+                            con.setReadBuffer(null);
+                            this.recycleBuffer(buf);
+                        }
+                        else
+                        {
+                            READ_BUFFER.clear();
+                        }
+
+                        return false;
+                    }
+                    else
+                    {
+                        // do nothing
+                    }
+
+                    return true;
+                }
+                else
+                {
+                    //System.out.println("ENABLEI");
+                    client.getConnection().enableReadInterest();
+                    
+                    //System.out.println("LIMIT "+buf.limit());
+                    if (buf == READ_BUFFER)
+                    {
+                        buf.position(buf.position() - HEADER_SIZE);
+                        this.allocateReadBuffer(con);
+                    }
+                    else
+                    {
+                        buf.position(buf.position() - HEADER_SIZE);
+                        buf.compact();
+                    }
+                    return false;
+                }
+            }
+            else
+            {
+                if (buf == READ_BUFFER)
+                {
+                    this.allocateReadBuffer(con);
+                }
+                return false;
+            }
+        }
+        else
+        {
+            //con.disableReadInterest();
+            return false; //empty buffer
+        }
+    }
+
+    protected void allocateReadBuffer(MMOConnection con)
+    {
+        //System.out.println("con: "+Integer.toHexString(con.hashCode()));
+        //Util.printHexDump(READ_BUFFER);
+        con.setReadBuffer(this.getPooledBuffer().put(READ_BUFFER));
+        READ_BUFFER.clear();
+    }
+
+    protected void parseClientPacket(ByteBuffer buf, int size, T client)
+    {
+        int pos = buf.position();
+        
+        boolean ret = client.decrypt(buf, size - HEADER_SIZE);
+        
+        buf.position(pos);
+       
+        if (buf.hasRemaining() && ret)
+        {
+            //  apply limit
+            int limit = buf.limit();
+            buf.limit(pos + size - HEADER_SIZE);
+            ReceivablePacket<T> cp = this.getPacketHandler().handlePacket(buf, client);
+
+            if (cp != null)
+            {
+                cp.setByteBuffer(buf);
+                cp.setClient(client);
+                
+                if (cp.read())
+                {
+                    this.getExecutor().execute(cp);
+                }
+            }
+            buf.limit(limit);
+        }
+        buf.position(pos + size - HEADER_SIZE);
+    }
+
+    @SuppressWarnings("unchecked")
+    protected void writePacket(SelectionKey key)
+    {
+        T client = ((T) key.attachment());
+        MMOConnection<T> con = client.getConnection();
+
+        ByteBuffer buf;
+        boolean sharedBuffer = false;
+        if ((buf = con.getWriteBuffer()) == null)
+        {
+            SendablePacket<T> sp = null;
+            synchronized (con.getSendQueue())
+            {
+                if (!con.getSendQueue().isEmpty())
+                {
+                    sp = con.getSendQueue().removeFirst();
+                }
+            }
+            if (sp == null)
+            {
+                System.out.println("OMG WRITE BUT NO WRITE");
+                return;
+            }
+            //System.out.println("WRITING: "+sp.getClass().getSimpleName());
+            this.prepareWriteBuffer(client, sp);
+            buf = sp.getByteBuffer();
+            //System.out.println("WRITED:: "+sp.getClass().getSimpleName());
+            //System.out.println("wp:" +buf.position());
+            buf.flip();
+            
+            sharedBuffer = true;
+        }
+
+        int size = buf.remaining();
+        int result = -1;
+
+        try
+        {
+            result = con.getSocketChannel().write(buf);
+        }
+        catch (IOException e)
+        {
+            // error handling goes on the if bellow
+        }
+
+        // check if no error happened
+        if (result > 0)
+        {
+            // check if we writed everything
+            if (result == size)
+            {
+                //System.out.println("WRITEI COMPLETO");
+                synchronized (con.getSendQueue())
+                {
+                    if (con.getSendQueue().isEmpty())
+                    {
+                        con.disableWriteInterest();
+                    }
+                }
+
+                // if it was a pooled buffer we can recycle
+                if (!sharedBuffer)
+                {
+                    this.recycleBuffer(buf);
+                    con.setWriteBuffer(null);
+                }
+            }
+            else //incomplete write
+            {
+                //System.out.println("WRITEI INCOMPLETO");
+                // if its the main buffer allocate a pool one
+                if (sharedBuffer)
+                {
+                    con.setWriteBuffer(this.getPooledBuffer().put(buf));
+                }
+                else
+                {
+                    con.setWriteBuffer(buf);
+                }
+            }
+        }
+        else
+        {
+            con.onForcedDisconnection();
+            this.closeConnectionImpl(con);
+        }
+    }
+
+    protected void prepareWriteBuffer(T client, SendablePacket<T> sp)
+    {
+        WRITE_BUFFER.clear();
+
+        //set the write buffer
+        sp.setByteBuffer(WRITE_BUFFER);
+
+        // reserve space for the size
+        int headerPos = sp.getByteBuffer().position();
+        sp.getByteBuffer().position(headerPos + HEADER_SIZE);
+
+        // write contents
+        sp.write();
+        
+
+        int size = sp.getByteBuffer().position() - headerPos - HEADER_SIZE;
+        sp.getByteBuffer().position(headerPos + HEADER_SIZE);
+        client.encrypt(sp.getByteBuffer(), size);
+        
+        // write size
+        sp.writeHeader(HEADER_TYPE, headerPos);
+    }
+
+    protected int getHeaderValue(ByteBuffer buf)
+    {
+        switch (HEADER_TYPE)
+        {
+            case BYTE_HEADER:
+                return buf.get() & 0xFF;
+            case SHORT_HEADER:
+                return buf.getShort() & 0xFFFF;
+            case INT_HEADER:
+                return buf.getInt();
+        }
+        return -1; // O.o
+    }
+
+    protected void setSelector(Selector selector)
+    {
+        _selector = selector;
+    }
+
+    public Selector getSelector()
+    {
+        return _selector;
+    }
+
+    protected void setExecutor(IMMOExecutor<T> executor)
+    {
+        _executor = executor;
+    }
+
+    protected IMMOExecutor<T> getExecutor()
+    {
+        return _executor;
+    }
+
+    protected void setPacketHandler(IPacketHandler<T> packetHandler)
+    {
+        _packetHandler = packetHandler;
+    }
+
+    public IPacketHandler<T> getPacketHandler()
+    {
+        return _packetHandler;
+    }
+
+    protected void setClientFactory(IClientFactory<T> clientFactory)
+    {
+        _clientFactory = clientFactory;
+    }
+
+    public IClientFactory<T> getClientFactory()
+    {
+        return _clientFactory;
+    }
+
+    public void setAcceptFilter(IAcceptFilter acceptFilter)
+    {
+        _acceptFilter = acceptFilter;
+    }
+    
+    public IAcceptFilter getAcceptFilter()
+    {
+        return _acceptFilter;
+    }
+    
+    public void closeConnection(MMOConnection<T> con)
+    {
+        synchronized (this.getPendingClose())
+        {
+            this.getPendingClose().addLast(con);
+        }
+    }
+    
+    protected void closeConnectionImpl(MMOConnection<T> con)
+    {
+        // notify connection
+        con.onDisconection();
+        
+        try
+        {
+            // close socket and the SocketChannel
+            con.getSocketChannel().socket().close();
+        }
+        catch (IOException e)
+        {
+            // ignore, we are closing anyway
+        }
+        
+        // clear attachment
+        con.getSelectionKey().attach(null);
+        // cancel key
+        con.getSelectionKey().cancel();
+    }
+    
+    protected FastList<MMOConnection<T>> getPendingClose()
+    {
+        return _pendingClose;
+    }
+    
+    public void shutdown()
+    {
+        _shutdown = true;
+    }
+
+    public boolean isShuttingDown()
+    {
+        return _shutdown;
+    }
+
+    protected void closeAllChannels()
+    {
+        Set<SelectionKey> keys = this.getSelector().keys();
+        for (Iterator<SelectionKey> iter = keys.iterator(); iter.hasNext();)
+        {
+            SelectionKey key = iter.next();
+            try
+            {
+                key.channel().close();
+            }
+            catch (IOException e)
+            {
+                // ignore
+            }
+        }
+    }
+
+    protected void closeSelectorThread() 
+    {
+        this.closeAllChannels();
+        try
+        {
+            this.getSelector().close();
+        }
+        catch (IOException e)
+        {
+            // Ignore
+        }
+    }
+}

+ 91 - 0
MMOCore/src/com/l2jserver/mmocore/network/SendablePacket.java

@@ -0,0 +1,91 @@
+/* This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA.
+ *
+ * http://www.gnu.org/copyleft/gpl.html
+ */
+package com.l2jserver.mmocore.network;
+
+
+import com.l2jserver.mmocore.network.SelectorConfig.HeaderSize;
+
+/**
+ * @author KenM
+ *
+ */
+public abstract class SendablePacket<T extends MMOClient> extends AbstractPacket<T>
+{
+    protected void writeC(int data)
+    {
+        this.getByteBuffer().put((byte) data);
+    }
+    
+    protected void writeF(double value)
+    {
+        this.getByteBuffer().putDouble(value);
+    }
+    
+    protected void writeH(int value)
+    {
+        this.getByteBuffer().putShort((short) value);
+    }
+    
+    protected void writeD(int value)
+    {
+        this.getByteBuffer().putInt(value);
+    }
+    
+    protected void writeQ(long value)
+    {
+        this.getByteBuffer().putLong(value);
+    }
+    
+    protected void writeB(byte[] data)
+    {
+        this.getByteBuffer().put(data);
+    }
+    
+    protected void writeS(CharSequence charSequence)
+    {
+        if (charSequence == null)
+        {
+            charSequence = "";
+        }
+        
+        int length = charSequence.length();
+        for (int i = 0; i < length; i++)
+        {
+            this.getByteBuffer().putChar(charSequence.charAt(i));
+        }
+        this.getByteBuffer().putChar('\000');
+    }
+    
+    protected abstract void write();
+    
+    protected void writeHeader(HeaderSize ht, int pos)
+    {
+        switch (ht)
+        {
+            case BYTE_HEADER:
+                this.getByteBuffer().put(pos, (byte) this.getByteBuffer().position());
+                break;
+            case SHORT_HEADER:
+                this.getByteBuffer().putShort(pos, (short) this.getByteBuffer().position());
+                break;
+            case INT_HEADER:
+                this.getByteBuffer().putInt(pos, this.getByteBuffer().position());
+                break;
+        }
+    }
+}

Some files were not shown because too many files changed in this diff