Skip to content

Commit

Permalink
feat: some improve (#180)
Browse files Browse the repository at this point in the history
* docs: add idea code styles

* refactor: rename NbtUtilsTest -> AllayNbtUtilsTest

* refactor: DAG and fix plugin load for dependency

* feat: implement entity and blockentity serializer
  • Loading branch information
CoolLoong authored Mar 8, 2024
1 parent 0971b25 commit b37bedf
Show file tree
Hide file tree
Showing 31 changed files with 1,189 additions and 449 deletions.
12 changes: 11 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
/.gradle/
/.idea/

.idea/**
### Add the codestyle to the repo
!/.idea/codeStyles
!/.idea/codeStyles/*
!/.idea/codeStyles/codeStyleConfig.xml
!/.idea/codeStyles/Project.xml
### Add the inspectionProfiles to the repo
!/.idea/inspectionProfiles
!/.idea/inspectionProfiles/Project_Default.xml

**/build/
**/bin/

Expand Down
8 changes: 8 additions & 0 deletions .idea/codeStyles/Project.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions .idea/codeStyles/codeStyleConfig.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions .idea/inspectionProfiles/Project_Default.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import org.joml.Vector3i;
import org.joml.Vector3ic;

import static org.allaymc.api.utils.NbtUtils.writeVector3f;
import static org.allaymc.api.utils.AllayNbtUtils.writeVector3f;

/**
* Allay Project 2024/1/27
Expand Down

This file was deleted.

133 changes: 0 additions & 133 deletions Allay-API/src/main/java/org/allaymc/api/datastruct/dag/DAG.java

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
* Copyright 2009 Stephen Winnall, CH-8143 Stallikon. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "Licence");
* you may not use this file except in compliance with the Licence.
* You may obtain a copy of the Licence at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the Licence is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the Licence for the specific language governing permissions and
* limitations under the Licence.
*
*/

/*
* All matters arising in law from the use of this software are subject
* exclusively to the jurisdiction and venue of the courts located in
* Zurich, Switzerland. See
*
* http://www.vimia.org/licences/JURISDICTION-1.0
*
*/

package org.allaymc.api.datastruct.dag;

/**
* This exception is thrown if a loop occurs in the DAG graph.
*
* @author steve | CoolLoong
*/
public class DAGCycleException extends Exception {
/**
* Constructs an instance of <code>DAGCycleException</code> with
* the specified detail message and details of objects causing the cycle.
*
* @param before the before object
* @param after the following object
*/
public DAGCycleException(Object before, Object after) {
super("(before: " + before + " - after: " + after + ")");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
/*
* Copyright 2009 Stephen Winnall, CH-8143 Stallikon. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "Licence");
* you may not use this file except in compliance with the Licence.
* You may obtain a copy of the Licence at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the Licence is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the Licence for the specific language governing permissions and
* limitations under the Licence.
*
*/

/*
* All matters arising in law from the use of this software are subject
* exclusively to the jurisdiction and venue of the courts located in
* Zurich, Switzerland. See
*
* http://www.vimia.org/licences/JURISDICTION-1.0
*/
package org.allaymc.api.datastruct.dag;

import java.util.List;
import java.util.Set;

/**
* DirectedAcyclicGraph is an implementation of a <a href="http://en.wikipedia.org/wiki/Directed_acyclic_graph">directed acyclic graph</a>
* that conforms to {@link Set}.
*
* @param <B> Node type.
*/
public interface DirectedAcyclicGraph<B> extends Set<B> {

/**
* set the parent node of the "after" node as the "before" node.
* <p>
* Note that before set, you need to call the {@link Set#add(Object)} method to add nodes.
* <p>
* If the node specified in the parameter is not in the graph, it will throw an {@link IllegalArgumentException}
*
* @param before the before node
* @param after the after node
* @throws DAGCycleException if a cycle occurs, this exception will be thrown
*/
void setBefore(B before, B after) throws DAGCycleException;

/**
* If the node specified in the parameter is not in the graph, it will throw an {@link IllegalArgumentException}
*
* @param member a node
* @return all parent nodes of this node. Note that if this node is not in the graph, an {@link NullPointerException} will be thrown.
*/
Set<B> getBefore(B member);

/**
* If the node specified in the parameter is not in the graph, it will throw an {@link IllegalArgumentException}
*
* @param before the before node
* @param after the after node
* @return Whether the "before" node is a parent node of the "after" node.
*/
boolean isBefore(B before, B after);

/**
* @return The result of topological sorting of this directed acyclic graph (DAG).
*/
List<B> getSortedList();

/**
* If the node specified in the parameter is null, it will throw an {@link NullPointerException}
*/
boolean add(B member);
}
Loading

0 comments on commit b37bedf

Please sign in to comment.