repo_name
stringlengths
7
104
file_path
stringlengths
13
198
context
stringlengths
67
7.15k
import_statement
stringlengths
16
4.43k
code
stringlengths
40
6.98k
prompt
stringlengths
227
8.27k
next_line
stringlengths
8
795
Torchmind/Candle
core/src/main/java/com/torchmind/candle/node/property/IntegerPropertyNode.java
// Path: api/src/main/java/com/torchmind/candle/api/IDocumentNode.java // public interface IDocumentNode extends IObjectNode { // String NAME = "###ROOT###"; // // /** // * {@inheritDoc} // */ // @Nonnull // @Override // default IDocumentNode document () { // return this; // } // // /** // * {@inheritDoc} // */ // @Override // default boolean isDocumentRoot () { // return true; // } // // /** // * {@inheritDoc} // */ // @Nonnull // @Override // default INamedNode name (@Nullable String name) { // throw new UnsupportedOperationException ("Cannot alter node name of root document node"); // } // // /** // * {@inheritDoc} // */ // @Nonnull // @Override // default String name () { // return NAME; // } // // /** // * {@inheritDoc} // */ // @Nonnull // @Override // default NodeType type () { // return NodeType.DOCUMENT; // } // } // // Path: api/src/main/java/com/torchmind/candle/api/NodeValueType.java // public enum NodeValueType { // /** // * Represents an array of a certain type of element. // */ // ARRAY, // // /** // * Represents a binary value (0 = false, 1 = true). // */ // BOOLEAN, // // /** // * Represents a default value. // */ // DEFAULT, // // /** // * Represents a value within a list of possible values. // */ // ENUM, // // /** // * Represents a floating point number. // */ // FLOAT, // // /** // * Represents an integer. // */ // INTEGER, // // /** // * Represents a null (empty) value. // */ // NULL, // // /** // * Represents a character sequence. // */ // STRING // }
import com.torchmind.candle.api.IDocumentNode; import com.torchmind.candle.api.NodeValueType; import javax.annotation.Nonnegative; import javax.annotation.Nonnull;
/* * Copyright 2015 Johannes Donath <johannesd@torchmind.com> * and other copyright owners as documented in the project's IP log. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.torchmind.candle.node.property; /** * Represents an integer value within the tree. * * @author Johannes Donath */ public class IntegerPropertyNode extends AbstractPropertyNode { private int value;
// Path: api/src/main/java/com/torchmind/candle/api/IDocumentNode.java // public interface IDocumentNode extends IObjectNode { // String NAME = "###ROOT###"; // // /** // * {@inheritDoc} // */ // @Nonnull // @Override // default IDocumentNode document () { // return this; // } // // /** // * {@inheritDoc} // */ // @Override // default boolean isDocumentRoot () { // return true; // } // // /** // * {@inheritDoc} // */ // @Nonnull // @Override // default INamedNode name (@Nullable String name) { // throw new UnsupportedOperationException ("Cannot alter node name of root document node"); // } // // /** // * {@inheritDoc} // */ // @Nonnull // @Override // default String name () { // return NAME; // } // // /** // * {@inheritDoc} // */ // @Nonnull // @Override // default NodeType type () { // return NodeType.DOCUMENT; // } // } // // Path: api/src/main/java/com/torchmind/candle/api/NodeValueType.java // public enum NodeValueType { // /** // * Represents an array of a certain type of element. // */ // ARRAY, // // /** // * Represents a binary value (0 = false, 1 = true). // */ // BOOLEAN, // // /** // * Represents a default value. // */ // DEFAULT, // // /** // * Represents a value within a list of possible values. // */ // ENUM, // // /** // * Represents a floating point number. // */ // FLOAT, // // /** // * Represents an integer. // */ // INTEGER, // // /** // * Represents a null (empty) value. // */ // NULL, // // /** // * Represents a character sequence. // */ // STRING // } // Path: core/src/main/java/com/torchmind/candle/node/property/IntegerPropertyNode.java import com.torchmind.candle.api.IDocumentNode; import com.torchmind.candle.api.NodeValueType; import javax.annotation.Nonnegative; import javax.annotation.Nonnull; /* * Copyright 2015 Johannes Donath <johannesd@torchmind.com> * and other copyright owners as documented in the project's IP log. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.torchmind.candle.node.property; /** * Represents an integer value within the tree. * * @author Johannes Donath */ public class IntegerPropertyNode extends AbstractPropertyNode { private int value;
public IntegerPropertyNode (@Nonnull IDocumentNode documentNode, @Nonnull String name, int value) {
Torchmind/Candle
core/src/main/java/com/torchmind/candle/node/property/IntegerPropertyNode.java
// Path: api/src/main/java/com/torchmind/candle/api/IDocumentNode.java // public interface IDocumentNode extends IObjectNode { // String NAME = "###ROOT###"; // // /** // * {@inheritDoc} // */ // @Nonnull // @Override // default IDocumentNode document () { // return this; // } // // /** // * {@inheritDoc} // */ // @Override // default boolean isDocumentRoot () { // return true; // } // // /** // * {@inheritDoc} // */ // @Nonnull // @Override // default INamedNode name (@Nullable String name) { // throw new UnsupportedOperationException ("Cannot alter node name of root document node"); // } // // /** // * {@inheritDoc} // */ // @Nonnull // @Override // default String name () { // return NAME; // } // // /** // * {@inheritDoc} // */ // @Nonnull // @Override // default NodeType type () { // return NodeType.DOCUMENT; // } // } // // Path: api/src/main/java/com/torchmind/candle/api/NodeValueType.java // public enum NodeValueType { // /** // * Represents an array of a certain type of element. // */ // ARRAY, // // /** // * Represents a binary value (0 = false, 1 = true). // */ // BOOLEAN, // // /** // * Represents a default value. // */ // DEFAULT, // // /** // * Represents a value within a list of possible values. // */ // ENUM, // // /** // * Represents a floating point number. // */ // FLOAT, // // /** // * Represents an integer. // */ // INTEGER, // // /** // * Represents a null (empty) value. // */ // NULL, // // /** // * Represents a character sequence. // */ // STRING // }
import com.torchmind.candle.api.IDocumentNode; import com.torchmind.candle.api.NodeValueType; import javax.annotation.Nonnegative; import javax.annotation.Nonnull;
/* * Copyright 2015 Johannes Donath <johannesd@torchmind.com> * and other copyright owners as documented in the project's IP log. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.torchmind.candle.node.property; /** * Represents an integer value within the tree. * * @author Johannes Donath */ public class IntegerPropertyNode extends AbstractPropertyNode { private int value; public IntegerPropertyNode (@Nonnull IDocumentNode documentNode, @Nonnull String name, int value) { super (documentNode, name); this.value (value); } /** * {@inheritDoc} */ public int value () { return this.value; } /** * {@inheritDoc} */ @Nonnull public IntegerPropertyNode value (int value) { this.value = value; return this; } /** * {@inheritDoc} */ @Nonnull @Override
// Path: api/src/main/java/com/torchmind/candle/api/IDocumentNode.java // public interface IDocumentNode extends IObjectNode { // String NAME = "###ROOT###"; // // /** // * {@inheritDoc} // */ // @Nonnull // @Override // default IDocumentNode document () { // return this; // } // // /** // * {@inheritDoc} // */ // @Override // default boolean isDocumentRoot () { // return true; // } // // /** // * {@inheritDoc} // */ // @Nonnull // @Override // default INamedNode name (@Nullable String name) { // throw new UnsupportedOperationException ("Cannot alter node name of root document node"); // } // // /** // * {@inheritDoc} // */ // @Nonnull // @Override // default String name () { // return NAME; // } // // /** // * {@inheritDoc} // */ // @Nonnull // @Override // default NodeType type () { // return NodeType.DOCUMENT; // } // } // // Path: api/src/main/java/com/torchmind/candle/api/NodeValueType.java // public enum NodeValueType { // /** // * Represents an array of a certain type of element. // */ // ARRAY, // // /** // * Represents a binary value (0 = false, 1 = true). // */ // BOOLEAN, // // /** // * Represents a default value. // */ // DEFAULT, // // /** // * Represents a value within a list of possible values. // */ // ENUM, // // /** // * Represents a floating point number. // */ // FLOAT, // // /** // * Represents an integer. // */ // INTEGER, // // /** // * Represents a null (empty) value. // */ // NULL, // // /** // * Represents a character sequence. // */ // STRING // } // Path: core/src/main/java/com/torchmind/candle/node/property/IntegerPropertyNode.java import com.torchmind.candle.api.IDocumentNode; import com.torchmind.candle.api.NodeValueType; import javax.annotation.Nonnegative; import javax.annotation.Nonnull; /* * Copyright 2015 Johannes Donath <johannesd@torchmind.com> * and other copyright owners as documented in the project's IP log. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.torchmind.candle.node.property; /** * Represents an integer value within the tree. * * @author Johannes Donath */ public class IntegerPropertyNode extends AbstractPropertyNode { private int value; public IntegerPropertyNode (@Nonnull IDocumentNode documentNode, @Nonnull String name, int value) { super (documentNode, name); this.value (value); } /** * {@inheritDoc} */ public int value () { return this.value; } /** * {@inheritDoc} */ @Nonnull public IntegerPropertyNode value (int value) { this.value = value; return this; } /** * {@inheritDoc} */ @Nonnull @Override
public NodeValueType valueType () {
Torchmind/Candle
core/src/main/java/com/torchmind/candle/node/property/BooleanPropertyNode.java
// Path: api/src/main/java/com/torchmind/candle/api/IDocumentNode.java // public interface IDocumentNode extends IObjectNode { // String NAME = "###ROOT###"; // // /** // * {@inheritDoc} // */ // @Nonnull // @Override // default IDocumentNode document () { // return this; // } // // /** // * {@inheritDoc} // */ // @Override // default boolean isDocumentRoot () { // return true; // } // // /** // * {@inheritDoc} // */ // @Nonnull // @Override // default INamedNode name (@Nullable String name) { // throw new UnsupportedOperationException ("Cannot alter node name of root document node"); // } // // /** // * {@inheritDoc} // */ // @Nonnull // @Override // default String name () { // return NAME; // } // // /** // * {@inheritDoc} // */ // @Nonnull // @Override // default NodeType type () { // return NodeType.DOCUMENT; // } // } // // Path: api/src/main/java/com/torchmind/candle/api/NodeValueType.java // public enum NodeValueType { // /** // * Represents an array of a certain type of element. // */ // ARRAY, // // /** // * Represents a binary value (0 = false, 1 = true). // */ // BOOLEAN, // // /** // * Represents a default value. // */ // DEFAULT, // // /** // * Represents a value within a list of possible values. // */ // ENUM, // // /** // * Represents a floating point number. // */ // FLOAT, // // /** // * Represents an integer. // */ // INTEGER, // // /** // * Represents a null (empty) value. // */ // NULL, // // /** // * Represents a character sequence. // */ // STRING // }
import com.torchmind.candle.api.IDocumentNode; import com.torchmind.candle.api.NodeValueType; import javax.annotation.Nonnull;
/* * Copyright 2015 Johannes Donath <johannesd@torchmind.com> * and other copyright owners as documented in the project's IP log. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.torchmind.candle.node.property; /** * Represents a boolean within the node tree. * * @author Johannes Donath */ public class BooleanPropertyNode extends AbstractPropertyNode { private boolean value;
// Path: api/src/main/java/com/torchmind/candle/api/IDocumentNode.java // public interface IDocumentNode extends IObjectNode { // String NAME = "###ROOT###"; // // /** // * {@inheritDoc} // */ // @Nonnull // @Override // default IDocumentNode document () { // return this; // } // // /** // * {@inheritDoc} // */ // @Override // default boolean isDocumentRoot () { // return true; // } // // /** // * {@inheritDoc} // */ // @Nonnull // @Override // default INamedNode name (@Nullable String name) { // throw new UnsupportedOperationException ("Cannot alter node name of root document node"); // } // // /** // * {@inheritDoc} // */ // @Nonnull // @Override // default String name () { // return NAME; // } // // /** // * {@inheritDoc} // */ // @Nonnull // @Override // default NodeType type () { // return NodeType.DOCUMENT; // } // } // // Path: api/src/main/java/com/torchmind/candle/api/NodeValueType.java // public enum NodeValueType { // /** // * Represents an array of a certain type of element. // */ // ARRAY, // // /** // * Represents a binary value (0 = false, 1 = true). // */ // BOOLEAN, // // /** // * Represents a default value. // */ // DEFAULT, // // /** // * Represents a value within a list of possible values. // */ // ENUM, // // /** // * Represents a floating point number. // */ // FLOAT, // // /** // * Represents an integer. // */ // INTEGER, // // /** // * Represents a null (empty) value. // */ // NULL, // // /** // * Represents a character sequence. // */ // STRING // } // Path: core/src/main/java/com/torchmind/candle/node/property/BooleanPropertyNode.java import com.torchmind.candle.api.IDocumentNode; import com.torchmind.candle.api.NodeValueType; import javax.annotation.Nonnull; /* * Copyright 2015 Johannes Donath <johannesd@torchmind.com> * and other copyright owners as documented in the project's IP log. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.torchmind.candle.node.property; /** * Represents a boolean within the node tree. * * @author Johannes Donath */ public class BooleanPropertyNode extends AbstractPropertyNode { private boolean value;
public BooleanPropertyNode (@Nonnull IDocumentNode documentNode, @Nonnull String name, boolean value) {
Torchmind/Candle
core/src/main/java/com/torchmind/candle/node/property/BooleanPropertyNode.java
// Path: api/src/main/java/com/torchmind/candle/api/IDocumentNode.java // public interface IDocumentNode extends IObjectNode { // String NAME = "###ROOT###"; // // /** // * {@inheritDoc} // */ // @Nonnull // @Override // default IDocumentNode document () { // return this; // } // // /** // * {@inheritDoc} // */ // @Override // default boolean isDocumentRoot () { // return true; // } // // /** // * {@inheritDoc} // */ // @Nonnull // @Override // default INamedNode name (@Nullable String name) { // throw new UnsupportedOperationException ("Cannot alter node name of root document node"); // } // // /** // * {@inheritDoc} // */ // @Nonnull // @Override // default String name () { // return NAME; // } // // /** // * {@inheritDoc} // */ // @Nonnull // @Override // default NodeType type () { // return NodeType.DOCUMENT; // } // } // // Path: api/src/main/java/com/torchmind/candle/api/NodeValueType.java // public enum NodeValueType { // /** // * Represents an array of a certain type of element. // */ // ARRAY, // // /** // * Represents a binary value (0 = false, 1 = true). // */ // BOOLEAN, // // /** // * Represents a default value. // */ // DEFAULT, // // /** // * Represents a value within a list of possible values. // */ // ENUM, // // /** // * Represents a floating point number. // */ // FLOAT, // // /** // * Represents an integer. // */ // INTEGER, // // /** // * Represents a null (empty) value. // */ // NULL, // // /** // * Represents a character sequence. // */ // STRING // }
import com.torchmind.candle.api.IDocumentNode; import com.torchmind.candle.api.NodeValueType; import javax.annotation.Nonnull;
/* * Copyright 2015 Johannes Donath <johannesd@torchmind.com> * and other copyright owners as documented in the project's IP log. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.torchmind.candle.node.property; /** * Represents a boolean within the node tree. * * @author Johannes Donath */ public class BooleanPropertyNode extends AbstractPropertyNode { private boolean value; public BooleanPropertyNode (@Nonnull IDocumentNode documentNode, @Nonnull String name, boolean value) { super (documentNode, name); this.value (value); } /** * Retrieves the boolean value. */ public boolean value () { return this.value; } /** * Sets the boolean value. * * @param value The value. * @return The node. */ @Nonnull public BooleanPropertyNode value (boolean value) { this.value = value; return this; } /** * {@inheritDoc} */ @Nonnull @Override
// Path: api/src/main/java/com/torchmind/candle/api/IDocumentNode.java // public interface IDocumentNode extends IObjectNode { // String NAME = "###ROOT###"; // // /** // * {@inheritDoc} // */ // @Nonnull // @Override // default IDocumentNode document () { // return this; // } // // /** // * {@inheritDoc} // */ // @Override // default boolean isDocumentRoot () { // return true; // } // // /** // * {@inheritDoc} // */ // @Nonnull // @Override // default INamedNode name (@Nullable String name) { // throw new UnsupportedOperationException ("Cannot alter node name of root document node"); // } // // /** // * {@inheritDoc} // */ // @Nonnull // @Override // default String name () { // return NAME; // } // // /** // * {@inheritDoc} // */ // @Nonnull // @Override // default NodeType type () { // return NodeType.DOCUMENT; // } // } // // Path: api/src/main/java/com/torchmind/candle/api/NodeValueType.java // public enum NodeValueType { // /** // * Represents an array of a certain type of element. // */ // ARRAY, // // /** // * Represents a binary value (0 = false, 1 = true). // */ // BOOLEAN, // // /** // * Represents a default value. // */ // DEFAULT, // // /** // * Represents a value within a list of possible values. // */ // ENUM, // // /** // * Represents a floating point number. // */ // FLOAT, // // /** // * Represents an integer. // */ // INTEGER, // // /** // * Represents a null (empty) value. // */ // NULL, // // /** // * Represents a character sequence. // */ // STRING // } // Path: core/src/main/java/com/torchmind/candle/node/property/BooleanPropertyNode.java import com.torchmind.candle.api.IDocumentNode; import com.torchmind.candle.api.NodeValueType; import javax.annotation.Nonnull; /* * Copyright 2015 Johannes Donath <johannesd@torchmind.com> * and other copyright owners as documented in the project's IP log. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.torchmind.candle.node.property; /** * Represents a boolean within the node tree. * * @author Johannes Donath */ public class BooleanPropertyNode extends AbstractPropertyNode { private boolean value; public BooleanPropertyNode (@Nonnull IDocumentNode documentNode, @Nonnull String name, boolean value) { super (documentNode, name); this.value (value); } /** * Retrieves the boolean value. */ public boolean value () { return this.value; } /** * Sets the boolean value. * * @param value The value. * @return The node. */ @Nonnull public BooleanPropertyNode value (boolean value) { this.value = value; return this; } /** * {@inheritDoc} */ @Nonnull @Override
public NodeValueType valueType () {
Torchmind/Candle
core/src/main/java/com/torchmind/candle/antlr/ParserErrorStrategy.java
// Path: api/src/main/java/com/torchmind/candle/api/error/CandleParserException.java // public class CandleParserException extends CandleException { // // protected CandleParserException (String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { // super (message, cause, enableSuppression, writableStackTrace); // } // // public CandleParserException () { // super (); // } // // public CandleParserException (String message) { // super (message); // } // // public CandleParserException (String message, Throwable cause) { // super (message, cause); // } // // public CandleParserException (Throwable cause) { // super (cause); // } // }
import com.torchmind.candle.api.error.CandleParserException; import org.antlr.v4.runtime.BailErrorStrategy; import org.antlr.v4.runtime.Parser; import org.antlr.v4.runtime.RecognitionException; import org.antlr.v4.runtime.Token; import org.antlr.v4.runtime.misc.ParseCancellationException;
/* * Copyright 2015 Johannes Donath <johannesd@torchmind.com> * and other copyright owners as documented in the project's IP log. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.torchmind.candle.antlr; /** * Wraps parser errors for user convenience. * * @author Johannes Donath */ public class ParserErrorStrategy extends BailErrorStrategy { /** * {@inheritDoc} */ @Override public void recover (Parser recognizer, RecognitionException e) { try { super.recover (recognizer, e); } catch (ParseCancellationException ex) {
// Path: api/src/main/java/com/torchmind/candle/api/error/CandleParserException.java // public class CandleParserException extends CandleException { // // protected CandleParserException (String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { // super (message, cause, enableSuppression, writableStackTrace); // } // // public CandleParserException () { // super (); // } // // public CandleParserException (String message) { // super (message); // } // // public CandleParserException (String message, Throwable cause) { // super (message, cause); // } // // public CandleParserException (Throwable cause) { // super (cause); // } // } // Path: core/src/main/java/com/torchmind/candle/antlr/ParserErrorStrategy.java import com.torchmind.candle.api.error.CandleParserException; import org.antlr.v4.runtime.BailErrorStrategy; import org.antlr.v4.runtime.Parser; import org.antlr.v4.runtime.RecognitionException; import org.antlr.v4.runtime.Token; import org.antlr.v4.runtime.misc.ParseCancellationException; /* * Copyright 2015 Johannes Donath <johannesd@torchmind.com> * and other copyright owners as documented in the project's IP log. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.torchmind.candle.antlr; /** * Wraps parser errors for user convenience. * * @author Johannes Donath */ public class ParserErrorStrategy extends BailErrorStrategy { /** * {@inheritDoc} */ @Override public void recover (Parser recognizer, RecognitionException e) { try { super.recover (recognizer, e); } catch (ParseCancellationException ex) {
throw new RuntimeException (new CandleParserException (ex.getMessage (), ex));
Torchmind/Candle
core/src/main/java/com/torchmind/candle/node/CommentNode.java
// Path: api/src/main/java/com/torchmind/candle/api/ICommentNode.java // public interface ICommentNode extends INode { // // /** // * Checks whether the node represents a multiline comment. // * // * @return The comment. // */ // boolean isMultiline (); // // /** // * Sets the comment contents. // * // * @param text The text. // * @return The node. // */ // @Nonnull // ICommentNode text (@Nonnull String text); // // /** // * Retrieves the comment contents. // * // * @return The text. // */ // @Nonnull // String text (); // // /** // * {@inheritDoc} // */ // @Nonnull // @Override // default NodeType type () { // return NodeType.COMMENT; // } // } // // Path: api/src/main/java/com/torchmind/candle/api/IDocumentNode.java // public interface IDocumentNode extends IObjectNode { // String NAME = "###ROOT###"; // // /** // * {@inheritDoc} // */ // @Nonnull // @Override // default IDocumentNode document () { // return this; // } // // /** // * {@inheritDoc} // */ // @Override // default boolean isDocumentRoot () { // return true; // } // // /** // * {@inheritDoc} // */ // @Nonnull // @Override // default INamedNode name (@Nullable String name) { // throw new UnsupportedOperationException ("Cannot alter node name of root document node"); // } // // /** // * {@inheritDoc} // */ // @Nonnull // @Override // default String name () { // return NAME; // } // // /** // * {@inheritDoc} // */ // @Nonnull // @Override // default NodeType type () { // return NodeType.DOCUMENT; // } // }
import com.torchmind.candle.api.ICommentNode; import com.torchmind.candle.api.IDocumentNode; import javax.annotation.Nonnull;
/* * Copyright 2015 Johannes Donath <johannesd@torchmind.com> * and other copyright owners as documented in the project's IP log. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.torchmind.candle.node; /** * Provides an implementation of {@link } * * @author Johannes Donath */ public class CommentNode extends AbstractNode implements ICommentNode { private String content; private boolean multiline;
// Path: api/src/main/java/com/torchmind/candle/api/ICommentNode.java // public interface ICommentNode extends INode { // // /** // * Checks whether the node represents a multiline comment. // * // * @return The comment. // */ // boolean isMultiline (); // // /** // * Sets the comment contents. // * // * @param text The text. // * @return The node. // */ // @Nonnull // ICommentNode text (@Nonnull String text); // // /** // * Retrieves the comment contents. // * // * @return The text. // */ // @Nonnull // String text (); // // /** // * {@inheritDoc} // */ // @Nonnull // @Override // default NodeType type () { // return NodeType.COMMENT; // } // } // // Path: api/src/main/java/com/torchmind/candle/api/IDocumentNode.java // public interface IDocumentNode extends IObjectNode { // String NAME = "###ROOT###"; // // /** // * {@inheritDoc} // */ // @Nonnull // @Override // default IDocumentNode document () { // return this; // } // // /** // * {@inheritDoc} // */ // @Override // default boolean isDocumentRoot () { // return true; // } // // /** // * {@inheritDoc} // */ // @Nonnull // @Override // default INamedNode name (@Nullable String name) { // throw new UnsupportedOperationException ("Cannot alter node name of root document node"); // } // // /** // * {@inheritDoc} // */ // @Nonnull // @Override // default String name () { // return NAME; // } // // /** // * {@inheritDoc} // */ // @Nonnull // @Override // default NodeType type () { // return NodeType.DOCUMENT; // } // } // Path: core/src/main/java/com/torchmind/candle/node/CommentNode.java import com.torchmind.candle.api.ICommentNode; import com.torchmind.candle.api.IDocumentNode; import javax.annotation.Nonnull; /* * Copyright 2015 Johannes Donath <johannesd@torchmind.com> * and other copyright owners as documented in the project's IP log. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.torchmind.candle.node; /** * Provides an implementation of {@link } * * @author Johannes Donath */ public class CommentNode extends AbstractNode implements ICommentNode { private String content; private boolean multiline;
public CommentNode (@Nonnull IDocumentNode documentNode, @Nonnull String content) {
Torchmind/Candle
core/src/main/java/com/torchmind/candle/node/property/array/BooleanArrayPropertyNode.java
// Path: api/src/main/java/com/torchmind/candle/api/IDocumentNode.java // public interface IDocumentNode extends IObjectNode { // String NAME = "###ROOT###"; // // /** // * {@inheritDoc} // */ // @Nonnull // @Override // default IDocumentNode document () { // return this; // } // // /** // * {@inheritDoc} // */ // @Override // default boolean isDocumentRoot () { // return true; // } // // /** // * {@inheritDoc} // */ // @Nonnull // @Override // default INamedNode name (@Nullable String name) { // throw new UnsupportedOperationException ("Cannot alter node name of root document node"); // } // // /** // * {@inheritDoc} // */ // @Nonnull // @Override // default String name () { // return NAME; // } // // /** // * {@inheritDoc} // */ // @Nonnull // @Override // default NodeType type () { // return NodeType.DOCUMENT; // } // } // // Path: api/src/main/java/com/torchmind/candle/api/NodeValueType.java // public enum NodeValueType { // /** // * Represents an array of a certain type of element. // */ // ARRAY, // // /** // * Represents a binary value (0 = false, 1 = true). // */ // BOOLEAN, // // /** // * Represents a default value. // */ // DEFAULT, // // /** // * Represents a value within a list of possible values. // */ // ENUM, // // /** // * Represents a floating point number. // */ // FLOAT, // // /** // * Represents an integer. // */ // INTEGER, // // /** // * Represents a null (empty) value. // */ // NULL, // // /** // * Represents a character sequence. // */ // STRING // }
import com.torchmind.candle.api.IDocumentNode; import com.torchmind.candle.api.NodeValueType; import javax.annotation.Nonnull; import java.util.Arrays;
/* * Copyright 2015 Johannes Donath <johannesd@torchmind.com> * and other copyright owners as documented in the project's IP log. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.torchmind.candle.node.property.array; /** * Represents a boolean array property within the tree. * * @author Johannes Donath */ public class BooleanArrayPropertyNode extends AbstractArrayPropertyNode { private boolean[] array;
// Path: api/src/main/java/com/torchmind/candle/api/IDocumentNode.java // public interface IDocumentNode extends IObjectNode { // String NAME = "###ROOT###"; // // /** // * {@inheritDoc} // */ // @Nonnull // @Override // default IDocumentNode document () { // return this; // } // // /** // * {@inheritDoc} // */ // @Override // default boolean isDocumentRoot () { // return true; // } // // /** // * {@inheritDoc} // */ // @Nonnull // @Override // default INamedNode name (@Nullable String name) { // throw new UnsupportedOperationException ("Cannot alter node name of root document node"); // } // // /** // * {@inheritDoc} // */ // @Nonnull // @Override // default String name () { // return NAME; // } // // /** // * {@inheritDoc} // */ // @Nonnull // @Override // default NodeType type () { // return NodeType.DOCUMENT; // } // } // // Path: api/src/main/java/com/torchmind/candle/api/NodeValueType.java // public enum NodeValueType { // /** // * Represents an array of a certain type of element. // */ // ARRAY, // // /** // * Represents a binary value (0 = false, 1 = true). // */ // BOOLEAN, // // /** // * Represents a default value. // */ // DEFAULT, // // /** // * Represents a value within a list of possible values. // */ // ENUM, // // /** // * Represents a floating point number. // */ // FLOAT, // // /** // * Represents an integer. // */ // INTEGER, // // /** // * Represents a null (empty) value. // */ // NULL, // // /** // * Represents a character sequence. // */ // STRING // } // Path: core/src/main/java/com/torchmind/candle/node/property/array/BooleanArrayPropertyNode.java import com.torchmind.candle.api.IDocumentNode; import com.torchmind.candle.api.NodeValueType; import javax.annotation.Nonnull; import java.util.Arrays; /* * Copyright 2015 Johannes Donath <johannesd@torchmind.com> * and other copyright owners as documented in the project's IP log. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.torchmind.candle.node.property.array; /** * Represents a boolean array property within the tree. * * @author Johannes Donath */ public class BooleanArrayPropertyNode extends AbstractArrayPropertyNode { private boolean[] array;
public BooleanArrayPropertyNode (@Nonnull IDocumentNode documentNode, @Nonnull String name, @Nonnull boolean[] array) {
Torchmind/Candle
core/src/main/java/com/torchmind/candle/node/property/array/BooleanArrayPropertyNode.java
// Path: api/src/main/java/com/torchmind/candle/api/IDocumentNode.java // public interface IDocumentNode extends IObjectNode { // String NAME = "###ROOT###"; // // /** // * {@inheritDoc} // */ // @Nonnull // @Override // default IDocumentNode document () { // return this; // } // // /** // * {@inheritDoc} // */ // @Override // default boolean isDocumentRoot () { // return true; // } // // /** // * {@inheritDoc} // */ // @Nonnull // @Override // default INamedNode name (@Nullable String name) { // throw new UnsupportedOperationException ("Cannot alter node name of root document node"); // } // // /** // * {@inheritDoc} // */ // @Nonnull // @Override // default String name () { // return NAME; // } // // /** // * {@inheritDoc} // */ // @Nonnull // @Override // default NodeType type () { // return NodeType.DOCUMENT; // } // } // // Path: api/src/main/java/com/torchmind/candle/api/NodeValueType.java // public enum NodeValueType { // /** // * Represents an array of a certain type of element. // */ // ARRAY, // // /** // * Represents a binary value (0 = false, 1 = true). // */ // BOOLEAN, // // /** // * Represents a default value. // */ // DEFAULT, // // /** // * Represents a value within a list of possible values. // */ // ENUM, // // /** // * Represents a floating point number. // */ // FLOAT, // // /** // * Represents an integer. // */ // INTEGER, // // /** // * Represents a null (empty) value. // */ // NULL, // // /** // * Represents a character sequence. // */ // STRING // }
import com.torchmind.candle.api.IDocumentNode; import com.torchmind.candle.api.NodeValueType; import javax.annotation.Nonnull; import java.util.Arrays;
/* * Copyright 2015 Johannes Donath <johannesd@torchmind.com> * and other copyright owners as documented in the project's IP log. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.torchmind.candle.node.property.array; /** * Represents a boolean array property within the tree. * * @author Johannes Donath */ public class BooleanArrayPropertyNode extends AbstractArrayPropertyNode { private boolean[] array; public BooleanArrayPropertyNode (@Nonnull IDocumentNode documentNode, @Nonnull String name, @Nonnull boolean[] array) { super (documentNode, name); this.array (array); } public BooleanArrayPropertyNode (@Nonnull IDocumentNode documentNode, @Nonnull String name, @Nonnull Boolean[] array) { super (documentNode, name); boolean[] primitiveArray = new boolean[array.length]; for (int i = 0; i < primitiveArray.length; i++) { primitiveArray[i] = array[i]; } this.array (primitiveArray); } /** * Retrieves the boolean array. * * @return The array. */ @Nonnull public boolean[] array () { return this.array; } /** * Sets the boolean array. * * @param array The array. * @return The node. */ @Nonnull public BooleanArrayPropertyNode array (@Nonnull boolean[] array) { this.array = array; return this; } @Nonnull @Override
// Path: api/src/main/java/com/torchmind/candle/api/IDocumentNode.java // public interface IDocumentNode extends IObjectNode { // String NAME = "###ROOT###"; // // /** // * {@inheritDoc} // */ // @Nonnull // @Override // default IDocumentNode document () { // return this; // } // // /** // * {@inheritDoc} // */ // @Override // default boolean isDocumentRoot () { // return true; // } // // /** // * {@inheritDoc} // */ // @Nonnull // @Override // default INamedNode name (@Nullable String name) { // throw new UnsupportedOperationException ("Cannot alter node name of root document node"); // } // // /** // * {@inheritDoc} // */ // @Nonnull // @Override // default String name () { // return NAME; // } // // /** // * {@inheritDoc} // */ // @Nonnull // @Override // default NodeType type () { // return NodeType.DOCUMENT; // } // } // // Path: api/src/main/java/com/torchmind/candle/api/NodeValueType.java // public enum NodeValueType { // /** // * Represents an array of a certain type of element. // */ // ARRAY, // // /** // * Represents a binary value (0 = false, 1 = true). // */ // BOOLEAN, // // /** // * Represents a default value. // */ // DEFAULT, // // /** // * Represents a value within a list of possible values. // */ // ENUM, // // /** // * Represents a floating point number. // */ // FLOAT, // // /** // * Represents an integer. // */ // INTEGER, // // /** // * Represents a null (empty) value. // */ // NULL, // // /** // * Represents a character sequence. // */ // STRING // } // Path: core/src/main/java/com/torchmind/candle/node/property/array/BooleanArrayPropertyNode.java import com.torchmind.candle.api.IDocumentNode; import com.torchmind.candle.api.NodeValueType; import javax.annotation.Nonnull; import java.util.Arrays; /* * Copyright 2015 Johannes Donath <johannesd@torchmind.com> * and other copyright owners as documented in the project's IP log. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.torchmind.candle.node.property.array; /** * Represents a boolean array property within the tree. * * @author Johannes Donath */ public class BooleanArrayPropertyNode extends AbstractArrayPropertyNode { private boolean[] array; public BooleanArrayPropertyNode (@Nonnull IDocumentNode documentNode, @Nonnull String name, @Nonnull boolean[] array) { super (documentNode, name); this.array (array); } public BooleanArrayPropertyNode (@Nonnull IDocumentNode documentNode, @Nonnull String name, @Nonnull Boolean[] array) { super (documentNode, name); boolean[] primitiveArray = new boolean[array.length]; for (int i = 0; i < primitiveArray.length; i++) { primitiveArray[i] = array[i]; } this.array (primitiveArray); } /** * Retrieves the boolean array. * * @return The array. */ @Nonnull public boolean[] array () { return this.array; } /** * Sets the boolean array. * * @param array The array. * @return The node. */ @Nonnull public BooleanArrayPropertyNode array (@Nonnull boolean[] array) { this.array = array; return this; } @Nonnull @Override
public NodeValueType itemType () {
Torchmind/Candle
core/src/main/java/com/torchmind/candle/node/property/DefaultPropertyNode.java
// Path: api/src/main/java/com/torchmind/candle/api/IDocumentNode.java // public interface IDocumentNode extends IObjectNode { // String NAME = "###ROOT###"; // // /** // * {@inheritDoc} // */ // @Nonnull // @Override // default IDocumentNode document () { // return this; // } // // /** // * {@inheritDoc} // */ // @Override // default boolean isDocumentRoot () { // return true; // } // // /** // * {@inheritDoc} // */ // @Nonnull // @Override // default INamedNode name (@Nullable String name) { // throw new UnsupportedOperationException ("Cannot alter node name of root document node"); // } // // /** // * {@inheritDoc} // */ // @Nonnull // @Override // default String name () { // return NAME; // } // // /** // * {@inheritDoc} // */ // @Nonnull // @Override // default NodeType type () { // return NodeType.DOCUMENT; // } // } // // Path: api/src/main/java/com/torchmind/candle/api/NodeValueType.java // public enum NodeValueType { // /** // * Represents an array of a certain type of element. // */ // ARRAY, // // /** // * Represents a binary value (0 = false, 1 = true). // */ // BOOLEAN, // // /** // * Represents a default value. // */ // DEFAULT, // // /** // * Represents a value within a list of possible values. // */ // ENUM, // // /** // * Represents a floating point number. // */ // FLOAT, // // /** // * Represents an integer. // */ // INTEGER, // // /** // * Represents a null (empty) value. // */ // NULL, // // /** // * Represents a character sequence. // */ // STRING // }
import com.torchmind.candle.api.IDocumentNode; import com.torchmind.candle.api.NodeValueType; import javax.annotation.Nonnull;
/* * Copyright 2015 Johannes Donath <johannesd@torchmind.com> * and other copyright owners as documented in the project's IP log. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.torchmind.candle.node.property; /** * Represents a default value. * * @author Johannes Donath */ public class DefaultPropertyNode extends AbstractPropertyNode { public DefaultPropertyNode (@Nonnull IDocumentNode documentNode, @Nonnull String name) { super (documentNode, name); } /** * {@inheritDoc} */ @Nonnull @Override
// Path: api/src/main/java/com/torchmind/candle/api/IDocumentNode.java // public interface IDocumentNode extends IObjectNode { // String NAME = "###ROOT###"; // // /** // * {@inheritDoc} // */ // @Nonnull // @Override // default IDocumentNode document () { // return this; // } // // /** // * {@inheritDoc} // */ // @Override // default boolean isDocumentRoot () { // return true; // } // // /** // * {@inheritDoc} // */ // @Nonnull // @Override // default INamedNode name (@Nullable String name) { // throw new UnsupportedOperationException ("Cannot alter node name of root document node"); // } // // /** // * {@inheritDoc} // */ // @Nonnull // @Override // default String name () { // return NAME; // } // // /** // * {@inheritDoc} // */ // @Nonnull // @Override // default NodeType type () { // return NodeType.DOCUMENT; // } // } // // Path: api/src/main/java/com/torchmind/candle/api/NodeValueType.java // public enum NodeValueType { // /** // * Represents an array of a certain type of element. // */ // ARRAY, // // /** // * Represents a binary value (0 = false, 1 = true). // */ // BOOLEAN, // // /** // * Represents a default value. // */ // DEFAULT, // // /** // * Represents a value within a list of possible values. // */ // ENUM, // // /** // * Represents a floating point number. // */ // FLOAT, // // /** // * Represents an integer. // */ // INTEGER, // // /** // * Represents a null (empty) value. // */ // NULL, // // /** // * Represents a character sequence. // */ // STRING // } // Path: core/src/main/java/com/torchmind/candle/node/property/DefaultPropertyNode.java import com.torchmind.candle.api.IDocumentNode; import com.torchmind.candle.api.NodeValueType; import javax.annotation.Nonnull; /* * Copyright 2015 Johannes Donath <johannesd@torchmind.com> * and other copyright owners as documented in the project's IP log. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.torchmind.candle.node.property; /** * Represents a default value. * * @author Johannes Donath */ public class DefaultPropertyNode extends AbstractPropertyNode { public DefaultPropertyNode (@Nonnull IDocumentNode documentNode, @Nonnull String name) { super (documentNode, name); } /** * {@inheritDoc} */ @Nonnull @Override
public DefaultPropertyNode ensureValueType (@Nonnull NodeValueType valueType) throws IllegalStateException {
Torchmind/Candle
core/src/main/java/com/torchmind/candle/node/property/array/StringArrayPropertyNode.java
// Path: api/src/main/java/com/torchmind/candle/api/IDocumentNode.java // public interface IDocumentNode extends IObjectNode { // String NAME = "###ROOT###"; // // /** // * {@inheritDoc} // */ // @Nonnull // @Override // default IDocumentNode document () { // return this; // } // // /** // * {@inheritDoc} // */ // @Override // default boolean isDocumentRoot () { // return true; // } // // /** // * {@inheritDoc} // */ // @Nonnull // @Override // default INamedNode name (@Nullable String name) { // throw new UnsupportedOperationException ("Cannot alter node name of root document node"); // } // // /** // * {@inheritDoc} // */ // @Nonnull // @Override // default String name () { // return NAME; // } // // /** // * {@inheritDoc} // */ // @Nonnull // @Override // default NodeType type () { // return NodeType.DOCUMENT; // } // } // // Path: api/src/main/java/com/torchmind/candle/api/NodeValueType.java // public enum NodeValueType { // /** // * Represents an array of a certain type of element. // */ // ARRAY, // // /** // * Represents a binary value (0 = false, 1 = true). // */ // BOOLEAN, // // /** // * Represents a default value. // */ // DEFAULT, // // /** // * Represents a value within a list of possible values. // */ // ENUM, // // /** // * Represents a floating point number. // */ // FLOAT, // // /** // * Represents an integer. // */ // INTEGER, // // /** // * Represents a null (empty) value. // */ // NULL, // // /** // * Represents a character sequence. // */ // STRING // }
import com.torchmind.candle.api.IDocumentNode; import com.torchmind.candle.api.NodeValueType; import javax.annotation.Nonnull; import java.util.Arrays;
/* * Copyright 2015 Johannes Donath <johannesd@torchmind.com> * and other copyright owners as documented in the project's IP log. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.torchmind.candle.node.property.array; /** * Represents a string array property within the tree. * * @author Johannes Donath */ public class StringArrayPropertyNode extends AbstractArrayPropertyNode { private String[] array;
// Path: api/src/main/java/com/torchmind/candle/api/IDocumentNode.java // public interface IDocumentNode extends IObjectNode { // String NAME = "###ROOT###"; // // /** // * {@inheritDoc} // */ // @Nonnull // @Override // default IDocumentNode document () { // return this; // } // // /** // * {@inheritDoc} // */ // @Override // default boolean isDocumentRoot () { // return true; // } // // /** // * {@inheritDoc} // */ // @Nonnull // @Override // default INamedNode name (@Nullable String name) { // throw new UnsupportedOperationException ("Cannot alter node name of root document node"); // } // // /** // * {@inheritDoc} // */ // @Nonnull // @Override // default String name () { // return NAME; // } // // /** // * {@inheritDoc} // */ // @Nonnull // @Override // default NodeType type () { // return NodeType.DOCUMENT; // } // } // // Path: api/src/main/java/com/torchmind/candle/api/NodeValueType.java // public enum NodeValueType { // /** // * Represents an array of a certain type of element. // */ // ARRAY, // // /** // * Represents a binary value (0 = false, 1 = true). // */ // BOOLEAN, // // /** // * Represents a default value. // */ // DEFAULT, // // /** // * Represents a value within a list of possible values. // */ // ENUM, // // /** // * Represents a floating point number. // */ // FLOAT, // // /** // * Represents an integer. // */ // INTEGER, // // /** // * Represents a null (empty) value. // */ // NULL, // // /** // * Represents a character sequence. // */ // STRING // } // Path: core/src/main/java/com/torchmind/candle/node/property/array/StringArrayPropertyNode.java import com.torchmind.candle.api.IDocumentNode; import com.torchmind.candle.api.NodeValueType; import javax.annotation.Nonnull; import java.util.Arrays; /* * Copyright 2015 Johannes Donath <johannesd@torchmind.com> * and other copyright owners as documented in the project's IP log. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.torchmind.candle.node.property.array; /** * Represents a string array property within the tree. * * @author Johannes Donath */ public class StringArrayPropertyNode extends AbstractArrayPropertyNode { private String[] array;
public StringArrayPropertyNode (@Nonnull IDocumentNode documentNode, @Nonnull String name, @Nonnull String[] array) {
Torchmind/Candle
core/src/main/java/com/torchmind/candle/node/property/array/StringArrayPropertyNode.java
// Path: api/src/main/java/com/torchmind/candle/api/IDocumentNode.java // public interface IDocumentNode extends IObjectNode { // String NAME = "###ROOT###"; // // /** // * {@inheritDoc} // */ // @Nonnull // @Override // default IDocumentNode document () { // return this; // } // // /** // * {@inheritDoc} // */ // @Override // default boolean isDocumentRoot () { // return true; // } // // /** // * {@inheritDoc} // */ // @Nonnull // @Override // default INamedNode name (@Nullable String name) { // throw new UnsupportedOperationException ("Cannot alter node name of root document node"); // } // // /** // * {@inheritDoc} // */ // @Nonnull // @Override // default String name () { // return NAME; // } // // /** // * {@inheritDoc} // */ // @Nonnull // @Override // default NodeType type () { // return NodeType.DOCUMENT; // } // } // // Path: api/src/main/java/com/torchmind/candle/api/NodeValueType.java // public enum NodeValueType { // /** // * Represents an array of a certain type of element. // */ // ARRAY, // // /** // * Represents a binary value (0 = false, 1 = true). // */ // BOOLEAN, // // /** // * Represents a default value. // */ // DEFAULT, // // /** // * Represents a value within a list of possible values. // */ // ENUM, // // /** // * Represents a floating point number. // */ // FLOAT, // // /** // * Represents an integer. // */ // INTEGER, // // /** // * Represents a null (empty) value. // */ // NULL, // // /** // * Represents a character sequence. // */ // STRING // }
import com.torchmind.candle.api.IDocumentNode; import com.torchmind.candle.api.NodeValueType; import javax.annotation.Nonnull; import java.util.Arrays;
/* * Copyright 2015 Johannes Donath <johannesd@torchmind.com> * and other copyright owners as documented in the project's IP log. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.torchmind.candle.node.property.array; /** * Represents a string array property within the tree. * * @author Johannes Donath */ public class StringArrayPropertyNode extends AbstractArrayPropertyNode { private String[] array; public StringArrayPropertyNode (@Nonnull IDocumentNode documentNode, @Nonnull String name, @Nonnull String[] array) { super (documentNode, name); this.array (array); } /** * Retrieves the string array. * * @return The array. */ public String[] array () { return this.array; } /** * Sets the string array. * * @param array The array. * @return The node. */ public StringArrayPropertyNode array (String[] array) { this.array = array; return this; } /** * {@inheritDoc} */ @Nonnull @Override
// Path: api/src/main/java/com/torchmind/candle/api/IDocumentNode.java // public interface IDocumentNode extends IObjectNode { // String NAME = "###ROOT###"; // // /** // * {@inheritDoc} // */ // @Nonnull // @Override // default IDocumentNode document () { // return this; // } // // /** // * {@inheritDoc} // */ // @Override // default boolean isDocumentRoot () { // return true; // } // // /** // * {@inheritDoc} // */ // @Nonnull // @Override // default INamedNode name (@Nullable String name) { // throw new UnsupportedOperationException ("Cannot alter node name of root document node"); // } // // /** // * {@inheritDoc} // */ // @Nonnull // @Override // default String name () { // return NAME; // } // // /** // * {@inheritDoc} // */ // @Nonnull // @Override // default NodeType type () { // return NodeType.DOCUMENT; // } // } // // Path: api/src/main/java/com/torchmind/candle/api/NodeValueType.java // public enum NodeValueType { // /** // * Represents an array of a certain type of element. // */ // ARRAY, // // /** // * Represents a binary value (0 = false, 1 = true). // */ // BOOLEAN, // // /** // * Represents a default value. // */ // DEFAULT, // // /** // * Represents a value within a list of possible values. // */ // ENUM, // // /** // * Represents a floating point number. // */ // FLOAT, // // /** // * Represents an integer. // */ // INTEGER, // // /** // * Represents a null (empty) value. // */ // NULL, // // /** // * Represents a character sequence. // */ // STRING // } // Path: core/src/main/java/com/torchmind/candle/node/property/array/StringArrayPropertyNode.java import com.torchmind.candle.api.IDocumentNode; import com.torchmind.candle.api.NodeValueType; import javax.annotation.Nonnull; import java.util.Arrays; /* * Copyright 2015 Johannes Donath <johannesd@torchmind.com> * and other copyright owners as documented in the project's IP log. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.torchmind.candle.node.property.array; /** * Represents a string array property within the tree. * * @author Johannes Donath */ public class StringArrayPropertyNode extends AbstractArrayPropertyNode { private String[] array; public StringArrayPropertyNode (@Nonnull IDocumentNode documentNode, @Nonnull String name, @Nonnull String[] array) { super (documentNode, name); this.array (array); } /** * Retrieves the string array. * * @return The array. */ public String[] array () { return this.array; } /** * Sets the string array. * * @param array The array. * @return The node. */ public StringArrayPropertyNode array (String[] array) { this.array = array; return this; } /** * {@inheritDoc} */ @Nonnull @Override
public NodeValueType itemType () {
Torchmind/Candle
core/src/main/java/com/torchmind/candle/node/property/AbstractPropertyNode.java
// Path: api/src/main/java/com/torchmind/candle/api/IDocumentNode.java // public interface IDocumentNode extends IObjectNode { // String NAME = "###ROOT###"; // // /** // * {@inheritDoc} // */ // @Nonnull // @Override // default IDocumentNode document () { // return this; // } // // /** // * {@inheritDoc} // */ // @Override // default boolean isDocumentRoot () { // return true; // } // // /** // * {@inheritDoc} // */ // @Nonnull // @Override // default INamedNode name (@Nullable String name) { // throw new UnsupportedOperationException ("Cannot alter node name of root document node"); // } // // /** // * {@inheritDoc} // */ // @Nonnull // @Override // default String name () { // return NAME; // } // // /** // * {@inheritDoc} // */ // @Nonnull // @Override // default NodeType type () { // return NodeType.DOCUMENT; // } // } // // Path: api/src/main/java/com/torchmind/candle/api/IPropertyNode.java // public interface IPropertyNode extends INamedNode { // // /** // * Ensures that a node value consists of a certain type. // * // * @param valueType The value type. // * @return The node. // * // * @throws java.lang.IllegalStateException when the expected value type differs. // */ // @Nonnull // IPropertyNode ensureValueType (@Nonnull NodeValueType valueType) throws IllegalStateException; // // /** // * {@inheritDoc} // */ // @Nonnull // @Override // default NodeType type () { // return NodeType.PROPERTY; // } // // /** // * Retrieves the node value type. // * // * @return The type. // */ // @Nonnull // NodeValueType valueType (); // } // // Path: api/src/main/java/com/torchmind/candle/api/NodeValueType.java // public enum NodeValueType { // /** // * Represents an array of a certain type of element. // */ // ARRAY, // // /** // * Represents a binary value (0 = false, 1 = true). // */ // BOOLEAN, // // /** // * Represents a default value. // */ // DEFAULT, // // /** // * Represents a value within a list of possible values. // */ // ENUM, // // /** // * Represents a floating point number. // */ // FLOAT, // // /** // * Represents an integer. // */ // INTEGER, // // /** // * Represents a null (empty) value. // */ // NULL, // // /** // * Represents a character sequence. // */ // STRING // } // // Path: core/src/main/java/com/torchmind/candle/node/AbstractNamedNode.java // public abstract class AbstractNamedNode extends AbstractNode implements INamedNode { // private String name; // // protected AbstractNamedNode () { // super (); // } // // public AbstractNamedNode (@Nonnull IDocumentNode documentNode, @Nonnull String name) { // super (documentNode); // // this.name (name); // } // // /** // * {@inheritDoc} // */ // @Nonnull // @Override // public String name () { // return this.name; // } // // /** // * {@inheritDoc} // */ // @Nonnull // @Override // public INamedNode name (@Nonnull String name) { // this.name = name; // return this; // } // // /** // * {@inheritDoc} // */ // @Override // public String toString () { // return String.format ("name=\"%s\"", this.name ()); // } // }
import com.torchmind.candle.api.IDocumentNode; import com.torchmind.candle.api.IPropertyNode; import com.torchmind.candle.api.NodeValueType; import com.torchmind.candle.node.AbstractNamedNode; import javax.annotation.Nonnull;
/* * Copyright 2015 Johannes Donath <johannesd@torchmind.com> * and other copyright owners as documented in the project's IP log. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.torchmind.candle.node.property; /** * Provides an abstract implementation of {@link com.torchmind.candle.api.IPropertyNode}. * * @author Johannes Donath */ public abstract class AbstractPropertyNode extends AbstractNamedNode implements IPropertyNode { public AbstractPropertyNode (@Nonnull IDocumentNode documentNode, @Nonnull String name) { super (documentNode, name); } /** * {@inheritDoc} */ @Nonnull @Override
// Path: api/src/main/java/com/torchmind/candle/api/IDocumentNode.java // public interface IDocumentNode extends IObjectNode { // String NAME = "###ROOT###"; // // /** // * {@inheritDoc} // */ // @Nonnull // @Override // default IDocumentNode document () { // return this; // } // // /** // * {@inheritDoc} // */ // @Override // default boolean isDocumentRoot () { // return true; // } // // /** // * {@inheritDoc} // */ // @Nonnull // @Override // default INamedNode name (@Nullable String name) { // throw new UnsupportedOperationException ("Cannot alter node name of root document node"); // } // // /** // * {@inheritDoc} // */ // @Nonnull // @Override // default String name () { // return NAME; // } // // /** // * {@inheritDoc} // */ // @Nonnull // @Override // default NodeType type () { // return NodeType.DOCUMENT; // } // } // // Path: api/src/main/java/com/torchmind/candle/api/IPropertyNode.java // public interface IPropertyNode extends INamedNode { // // /** // * Ensures that a node value consists of a certain type. // * // * @param valueType The value type. // * @return The node. // * // * @throws java.lang.IllegalStateException when the expected value type differs. // */ // @Nonnull // IPropertyNode ensureValueType (@Nonnull NodeValueType valueType) throws IllegalStateException; // // /** // * {@inheritDoc} // */ // @Nonnull // @Override // default NodeType type () { // return NodeType.PROPERTY; // } // // /** // * Retrieves the node value type. // * // * @return The type. // */ // @Nonnull // NodeValueType valueType (); // } // // Path: api/src/main/java/com/torchmind/candle/api/NodeValueType.java // public enum NodeValueType { // /** // * Represents an array of a certain type of element. // */ // ARRAY, // // /** // * Represents a binary value (0 = false, 1 = true). // */ // BOOLEAN, // // /** // * Represents a default value. // */ // DEFAULT, // // /** // * Represents a value within a list of possible values. // */ // ENUM, // // /** // * Represents a floating point number. // */ // FLOAT, // // /** // * Represents an integer. // */ // INTEGER, // // /** // * Represents a null (empty) value. // */ // NULL, // // /** // * Represents a character sequence. // */ // STRING // } // // Path: core/src/main/java/com/torchmind/candle/node/AbstractNamedNode.java // public abstract class AbstractNamedNode extends AbstractNode implements INamedNode { // private String name; // // protected AbstractNamedNode () { // super (); // } // // public AbstractNamedNode (@Nonnull IDocumentNode documentNode, @Nonnull String name) { // super (documentNode); // // this.name (name); // } // // /** // * {@inheritDoc} // */ // @Nonnull // @Override // public String name () { // return this.name; // } // // /** // * {@inheritDoc} // */ // @Nonnull // @Override // public INamedNode name (@Nonnull String name) { // this.name = name; // return this; // } // // /** // * {@inheritDoc} // */ // @Override // public String toString () { // return String.format ("name=\"%s\"", this.name ()); // } // } // Path: core/src/main/java/com/torchmind/candle/node/property/AbstractPropertyNode.java import com.torchmind.candle.api.IDocumentNode; import com.torchmind.candle.api.IPropertyNode; import com.torchmind.candle.api.NodeValueType; import com.torchmind.candle.node.AbstractNamedNode; import javax.annotation.Nonnull; /* * Copyright 2015 Johannes Donath <johannesd@torchmind.com> * and other copyright owners as documented in the project's IP log. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.torchmind.candle.node.property; /** * Provides an abstract implementation of {@link com.torchmind.candle.api.IPropertyNode}. * * @author Johannes Donath */ public abstract class AbstractPropertyNode extends AbstractNamedNode implements IPropertyNode { public AbstractPropertyNode (@Nonnull IDocumentNode documentNode, @Nonnull String name) { super (documentNode, name); } /** * {@inheritDoc} */ @Nonnull @Override
public IPropertyNode ensureValueType (@Nonnull NodeValueType valueType) throws IllegalStateException {
Torchmind/Candle
core/src/main/java/com/torchmind/candle/node/AbstractNamedNode.java
// Path: api/src/main/java/com/torchmind/candle/api/IDocumentNode.java // public interface IDocumentNode extends IObjectNode { // String NAME = "###ROOT###"; // // /** // * {@inheritDoc} // */ // @Nonnull // @Override // default IDocumentNode document () { // return this; // } // // /** // * {@inheritDoc} // */ // @Override // default boolean isDocumentRoot () { // return true; // } // // /** // * {@inheritDoc} // */ // @Nonnull // @Override // default INamedNode name (@Nullable String name) { // throw new UnsupportedOperationException ("Cannot alter node name of root document node"); // } // // /** // * {@inheritDoc} // */ // @Nonnull // @Override // default String name () { // return NAME; // } // // /** // * {@inheritDoc} // */ // @Nonnull // @Override // default NodeType type () { // return NodeType.DOCUMENT; // } // } // // Path: api/src/main/java/com/torchmind/candle/api/INamedNode.java // public interface INamedNode extends INode { // // /** // * Retrieves the node name. // * // * @return The name. // */ // @Nonnull // String name (); // // /** // * Sets the node name. // * // * @param name The name. // * @return The node. // */ // @Nonnull // INamedNode name (@Nonnull String name); // }
import com.torchmind.candle.api.IDocumentNode; import com.torchmind.candle.api.INamedNode; import javax.annotation.Nonnull;
/* * Copyright 2015 Johannes Donath <johannesd@torchmind.com> * and other copyright owners as documented in the project's IP log. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.torchmind.candle.node; /** * Provides an abstract implementation of {@link com.torchmind.candle.api.INamedNode}. * * @author Johannes Donath */ public abstract class AbstractNamedNode extends AbstractNode implements INamedNode { private String name; protected AbstractNamedNode () { super (); }
// Path: api/src/main/java/com/torchmind/candle/api/IDocumentNode.java // public interface IDocumentNode extends IObjectNode { // String NAME = "###ROOT###"; // // /** // * {@inheritDoc} // */ // @Nonnull // @Override // default IDocumentNode document () { // return this; // } // // /** // * {@inheritDoc} // */ // @Override // default boolean isDocumentRoot () { // return true; // } // // /** // * {@inheritDoc} // */ // @Nonnull // @Override // default INamedNode name (@Nullable String name) { // throw new UnsupportedOperationException ("Cannot alter node name of root document node"); // } // // /** // * {@inheritDoc} // */ // @Nonnull // @Override // default String name () { // return NAME; // } // // /** // * {@inheritDoc} // */ // @Nonnull // @Override // default NodeType type () { // return NodeType.DOCUMENT; // } // } // // Path: api/src/main/java/com/torchmind/candle/api/INamedNode.java // public interface INamedNode extends INode { // // /** // * Retrieves the node name. // * // * @return The name. // */ // @Nonnull // String name (); // // /** // * Sets the node name. // * // * @param name The name. // * @return The node. // */ // @Nonnull // INamedNode name (@Nonnull String name); // } // Path: core/src/main/java/com/torchmind/candle/node/AbstractNamedNode.java import com.torchmind.candle.api.IDocumentNode; import com.torchmind.candle.api.INamedNode; import javax.annotation.Nonnull; /* * Copyright 2015 Johannes Donath <johannesd@torchmind.com> * and other copyright owners as documented in the project's IP log. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.torchmind.candle.node; /** * Provides an abstract implementation of {@link com.torchmind.candle.api.INamedNode}. * * @author Johannes Donath */ public abstract class AbstractNamedNode extends AbstractNode implements INamedNode { private String name; protected AbstractNamedNode () { super (); }
public AbstractNamedNode (@Nonnull IDocumentNode documentNode, @Nonnull String name) {
Torchmind/Candle
core/src/main/java/com/torchmind/candle/node/property/array/IntegerArrayPropertyNode.java
// Path: api/src/main/java/com/torchmind/candle/api/IDocumentNode.java // public interface IDocumentNode extends IObjectNode { // String NAME = "###ROOT###"; // // /** // * {@inheritDoc} // */ // @Nonnull // @Override // default IDocumentNode document () { // return this; // } // // /** // * {@inheritDoc} // */ // @Override // default boolean isDocumentRoot () { // return true; // } // // /** // * {@inheritDoc} // */ // @Nonnull // @Override // default INamedNode name (@Nullable String name) { // throw new UnsupportedOperationException ("Cannot alter node name of root document node"); // } // // /** // * {@inheritDoc} // */ // @Nonnull // @Override // default String name () { // return NAME; // } // // /** // * {@inheritDoc} // */ // @Nonnull // @Override // default NodeType type () { // return NodeType.DOCUMENT; // } // } // // Path: api/src/main/java/com/torchmind/candle/api/NodeValueType.java // public enum NodeValueType { // /** // * Represents an array of a certain type of element. // */ // ARRAY, // // /** // * Represents a binary value (0 = false, 1 = true). // */ // BOOLEAN, // // /** // * Represents a default value. // */ // DEFAULT, // // /** // * Represents a value within a list of possible values. // */ // ENUM, // // /** // * Represents a floating point number. // */ // FLOAT, // // /** // * Represents an integer. // */ // INTEGER, // // /** // * Represents a null (empty) value. // */ // NULL, // // /** // * Represents a character sequence. // */ // STRING // }
import com.torchmind.candle.api.IDocumentNode; import com.torchmind.candle.api.NodeValueType; import javax.annotation.Nonnegative; import javax.annotation.Nonnull; import java.util.Arrays;
/* * Copyright 2015 Johannes Donath <johannesd@torchmind.com> * and other copyright owners as documented in the project's IP log. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.torchmind.candle.node.property.array; /** * Represents integer array properties within the tree. * * @author Johannes Donath */ public class IntegerArrayPropertyNode extends AbstractArrayPropertyNode { private int[] array;
// Path: api/src/main/java/com/torchmind/candle/api/IDocumentNode.java // public interface IDocumentNode extends IObjectNode { // String NAME = "###ROOT###"; // // /** // * {@inheritDoc} // */ // @Nonnull // @Override // default IDocumentNode document () { // return this; // } // // /** // * {@inheritDoc} // */ // @Override // default boolean isDocumentRoot () { // return true; // } // // /** // * {@inheritDoc} // */ // @Nonnull // @Override // default INamedNode name (@Nullable String name) { // throw new UnsupportedOperationException ("Cannot alter node name of root document node"); // } // // /** // * {@inheritDoc} // */ // @Nonnull // @Override // default String name () { // return NAME; // } // // /** // * {@inheritDoc} // */ // @Nonnull // @Override // default NodeType type () { // return NodeType.DOCUMENT; // } // } // // Path: api/src/main/java/com/torchmind/candle/api/NodeValueType.java // public enum NodeValueType { // /** // * Represents an array of a certain type of element. // */ // ARRAY, // // /** // * Represents a binary value (0 = false, 1 = true). // */ // BOOLEAN, // // /** // * Represents a default value. // */ // DEFAULT, // // /** // * Represents a value within a list of possible values. // */ // ENUM, // // /** // * Represents a floating point number. // */ // FLOAT, // // /** // * Represents an integer. // */ // INTEGER, // // /** // * Represents a null (empty) value. // */ // NULL, // // /** // * Represents a character sequence. // */ // STRING // } // Path: core/src/main/java/com/torchmind/candle/node/property/array/IntegerArrayPropertyNode.java import com.torchmind.candle.api.IDocumentNode; import com.torchmind.candle.api.NodeValueType; import javax.annotation.Nonnegative; import javax.annotation.Nonnull; import java.util.Arrays; /* * Copyright 2015 Johannes Donath <johannesd@torchmind.com> * and other copyright owners as documented in the project's IP log. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.torchmind.candle.node.property.array; /** * Represents integer array properties within the tree. * * @author Johannes Donath */ public class IntegerArrayPropertyNode extends AbstractArrayPropertyNode { private int[] array;
public IntegerArrayPropertyNode (@Nonnull IDocumentNode documentNode, @Nonnull String name, @Nonnull int[] array) {
Torchmind/Candle
core/src/main/java/com/torchmind/candle/node/property/array/IntegerArrayPropertyNode.java
// Path: api/src/main/java/com/torchmind/candle/api/IDocumentNode.java // public interface IDocumentNode extends IObjectNode { // String NAME = "###ROOT###"; // // /** // * {@inheritDoc} // */ // @Nonnull // @Override // default IDocumentNode document () { // return this; // } // // /** // * {@inheritDoc} // */ // @Override // default boolean isDocumentRoot () { // return true; // } // // /** // * {@inheritDoc} // */ // @Nonnull // @Override // default INamedNode name (@Nullable String name) { // throw new UnsupportedOperationException ("Cannot alter node name of root document node"); // } // // /** // * {@inheritDoc} // */ // @Nonnull // @Override // default String name () { // return NAME; // } // // /** // * {@inheritDoc} // */ // @Nonnull // @Override // default NodeType type () { // return NodeType.DOCUMENT; // } // } // // Path: api/src/main/java/com/torchmind/candle/api/NodeValueType.java // public enum NodeValueType { // /** // * Represents an array of a certain type of element. // */ // ARRAY, // // /** // * Represents a binary value (0 = false, 1 = true). // */ // BOOLEAN, // // /** // * Represents a default value. // */ // DEFAULT, // // /** // * Represents a value within a list of possible values. // */ // ENUM, // // /** // * Represents a floating point number. // */ // FLOAT, // // /** // * Represents an integer. // */ // INTEGER, // // /** // * Represents a null (empty) value. // */ // NULL, // // /** // * Represents a character sequence. // */ // STRING // }
import com.torchmind.candle.api.IDocumentNode; import com.torchmind.candle.api.NodeValueType; import javax.annotation.Nonnegative; import javax.annotation.Nonnull; import java.util.Arrays;
* @return The node. */ @Nonnull public IntegerArrayPropertyNode array (@Nonnull int[] array) { this.array = array; return this; } /** * Retrieves the unsigned integer array. * * @return The array. */ @Nonnull @Nonnegative public int[] arrayUnsigned () { for (int current : this.array) { if (current < 0) { throw new IllegalStateException ("Expected an unsigned value but got " + current); } } return this.array; } /** * {@inheritDoc} */ @Nonnull @Override
// Path: api/src/main/java/com/torchmind/candle/api/IDocumentNode.java // public interface IDocumentNode extends IObjectNode { // String NAME = "###ROOT###"; // // /** // * {@inheritDoc} // */ // @Nonnull // @Override // default IDocumentNode document () { // return this; // } // // /** // * {@inheritDoc} // */ // @Override // default boolean isDocumentRoot () { // return true; // } // // /** // * {@inheritDoc} // */ // @Nonnull // @Override // default INamedNode name (@Nullable String name) { // throw new UnsupportedOperationException ("Cannot alter node name of root document node"); // } // // /** // * {@inheritDoc} // */ // @Nonnull // @Override // default String name () { // return NAME; // } // // /** // * {@inheritDoc} // */ // @Nonnull // @Override // default NodeType type () { // return NodeType.DOCUMENT; // } // } // // Path: api/src/main/java/com/torchmind/candle/api/NodeValueType.java // public enum NodeValueType { // /** // * Represents an array of a certain type of element. // */ // ARRAY, // // /** // * Represents a binary value (0 = false, 1 = true). // */ // BOOLEAN, // // /** // * Represents a default value. // */ // DEFAULT, // // /** // * Represents a value within a list of possible values. // */ // ENUM, // // /** // * Represents a floating point number. // */ // FLOAT, // // /** // * Represents an integer. // */ // INTEGER, // // /** // * Represents a null (empty) value. // */ // NULL, // // /** // * Represents a character sequence. // */ // STRING // } // Path: core/src/main/java/com/torchmind/candle/node/property/array/IntegerArrayPropertyNode.java import com.torchmind.candle.api.IDocumentNode; import com.torchmind.candle.api.NodeValueType; import javax.annotation.Nonnegative; import javax.annotation.Nonnull; import java.util.Arrays; * @return The node. */ @Nonnull public IntegerArrayPropertyNode array (@Nonnull int[] array) { this.array = array; return this; } /** * Retrieves the unsigned integer array. * * @return The array. */ @Nonnull @Nonnegative public int[] arrayUnsigned () { for (int current : this.array) { if (current < 0) { throw new IllegalStateException ("Expected an unsigned value but got " + current); } } return this.array; } /** * {@inheritDoc} */ @Nonnull @Override
public NodeValueType itemType () {
Torchmind/Candle
core/src/main/java/com/torchmind/candle/node/property/array/EnumArrayPropertyNode.java
// Path: api/src/main/java/com/torchmind/candle/api/IDocumentNode.java // public interface IDocumentNode extends IObjectNode { // String NAME = "###ROOT###"; // // /** // * {@inheritDoc} // */ // @Nonnull // @Override // default IDocumentNode document () { // return this; // } // // /** // * {@inheritDoc} // */ // @Override // default boolean isDocumentRoot () { // return true; // } // // /** // * {@inheritDoc} // */ // @Nonnull // @Override // default INamedNode name (@Nullable String name) { // throw new UnsupportedOperationException ("Cannot alter node name of root document node"); // } // // /** // * {@inheritDoc} // */ // @Nonnull // @Override // default String name () { // return NAME; // } // // /** // * {@inheritDoc} // */ // @Nonnull // @Override // default NodeType type () { // return NodeType.DOCUMENT; // } // } // // Path: api/src/main/java/com/torchmind/candle/api/NodeValueType.java // public enum NodeValueType { // /** // * Represents an array of a certain type of element. // */ // ARRAY, // // /** // * Represents a binary value (0 = false, 1 = true). // */ // BOOLEAN, // // /** // * Represents a default value. // */ // DEFAULT, // // /** // * Represents a value within a list of possible values. // */ // ENUM, // // /** // * Represents a floating point number. // */ // FLOAT, // // /** // * Represents an integer. // */ // INTEGER, // // /** // * Represents a null (empty) value. // */ // NULL, // // /** // * Represents a character sequence. // */ // STRING // }
import com.torchmind.candle.api.IDocumentNode; import com.torchmind.candle.api.NodeValueType; import javax.annotation.Nonnull; import java.lang.reflect.Array; import java.util.Arrays;
/* * Copyright 2015 Johannes Donath <johannesd@torchmind.com> * and other copyright owners as documented in the project's IP log. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.torchmind.candle.node.property.array; /** * Represents an enum array property within the tree. * * @author Johannes Donath */ public class EnumArrayPropertyNode extends AbstractArrayPropertyNode { private String[] array;
// Path: api/src/main/java/com/torchmind/candle/api/IDocumentNode.java // public interface IDocumentNode extends IObjectNode { // String NAME = "###ROOT###"; // // /** // * {@inheritDoc} // */ // @Nonnull // @Override // default IDocumentNode document () { // return this; // } // // /** // * {@inheritDoc} // */ // @Override // default boolean isDocumentRoot () { // return true; // } // // /** // * {@inheritDoc} // */ // @Nonnull // @Override // default INamedNode name (@Nullable String name) { // throw new UnsupportedOperationException ("Cannot alter node name of root document node"); // } // // /** // * {@inheritDoc} // */ // @Nonnull // @Override // default String name () { // return NAME; // } // // /** // * {@inheritDoc} // */ // @Nonnull // @Override // default NodeType type () { // return NodeType.DOCUMENT; // } // } // // Path: api/src/main/java/com/torchmind/candle/api/NodeValueType.java // public enum NodeValueType { // /** // * Represents an array of a certain type of element. // */ // ARRAY, // // /** // * Represents a binary value (0 = false, 1 = true). // */ // BOOLEAN, // // /** // * Represents a default value. // */ // DEFAULT, // // /** // * Represents a value within a list of possible values. // */ // ENUM, // // /** // * Represents a floating point number. // */ // FLOAT, // // /** // * Represents an integer. // */ // INTEGER, // // /** // * Represents a null (empty) value. // */ // NULL, // // /** // * Represents a character sequence. // */ // STRING // } // Path: core/src/main/java/com/torchmind/candle/node/property/array/EnumArrayPropertyNode.java import com.torchmind.candle.api.IDocumentNode; import com.torchmind.candle.api.NodeValueType; import javax.annotation.Nonnull; import java.lang.reflect.Array; import java.util.Arrays; /* * Copyright 2015 Johannes Donath <johannesd@torchmind.com> * and other copyright owners as documented in the project's IP log. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.torchmind.candle.node.property.array; /** * Represents an enum array property within the tree. * * @author Johannes Donath */ public class EnumArrayPropertyNode extends AbstractArrayPropertyNode { private String[] array;
public EnumArrayPropertyNode (@Nonnull IDocumentNode documentNode, @Nonnull String name, @Nonnull String[] array) {
Torchmind/Candle
core/src/main/java/com/torchmind/candle/node/property/array/EnumArrayPropertyNode.java
// Path: api/src/main/java/com/torchmind/candle/api/IDocumentNode.java // public interface IDocumentNode extends IObjectNode { // String NAME = "###ROOT###"; // // /** // * {@inheritDoc} // */ // @Nonnull // @Override // default IDocumentNode document () { // return this; // } // // /** // * {@inheritDoc} // */ // @Override // default boolean isDocumentRoot () { // return true; // } // // /** // * {@inheritDoc} // */ // @Nonnull // @Override // default INamedNode name (@Nullable String name) { // throw new UnsupportedOperationException ("Cannot alter node name of root document node"); // } // // /** // * {@inheritDoc} // */ // @Nonnull // @Override // default String name () { // return NAME; // } // // /** // * {@inheritDoc} // */ // @Nonnull // @Override // default NodeType type () { // return NodeType.DOCUMENT; // } // } // // Path: api/src/main/java/com/torchmind/candle/api/NodeValueType.java // public enum NodeValueType { // /** // * Represents an array of a certain type of element. // */ // ARRAY, // // /** // * Represents a binary value (0 = false, 1 = true). // */ // BOOLEAN, // // /** // * Represents a default value. // */ // DEFAULT, // // /** // * Represents a value within a list of possible values. // */ // ENUM, // // /** // * Represents a floating point number. // */ // FLOAT, // // /** // * Represents an integer. // */ // INTEGER, // // /** // * Represents a null (empty) value. // */ // NULL, // // /** // * Represents a character sequence. // */ // STRING // }
import com.torchmind.candle.api.IDocumentNode; import com.torchmind.candle.api.NodeValueType; import javax.annotation.Nonnull; import java.lang.reflect.Array; import java.util.Arrays;
* @param array The array. * @return The node. */ @Nonnull public EnumArrayPropertyNode array (@Nonnull String[] array) { this.array = array; return this; } /** * Sets the enum array. * * @param array The array. * @param <T> The enum type. * @return The node. */ @Nonnull public <T extends Enum> EnumArrayPropertyNode array (@Nonnull T[] array) { String[] convertedArray = new String[array.length]; for (int i = 0; i < array.length; i++) { convertedArray[i] = (array[i] != null ? array[i].name () : null); } return this.array (convertedArray); } /** * {@inheritDoc} */ @Nonnull @Override
// Path: api/src/main/java/com/torchmind/candle/api/IDocumentNode.java // public interface IDocumentNode extends IObjectNode { // String NAME = "###ROOT###"; // // /** // * {@inheritDoc} // */ // @Nonnull // @Override // default IDocumentNode document () { // return this; // } // // /** // * {@inheritDoc} // */ // @Override // default boolean isDocumentRoot () { // return true; // } // // /** // * {@inheritDoc} // */ // @Nonnull // @Override // default INamedNode name (@Nullable String name) { // throw new UnsupportedOperationException ("Cannot alter node name of root document node"); // } // // /** // * {@inheritDoc} // */ // @Nonnull // @Override // default String name () { // return NAME; // } // // /** // * {@inheritDoc} // */ // @Nonnull // @Override // default NodeType type () { // return NodeType.DOCUMENT; // } // } // // Path: api/src/main/java/com/torchmind/candle/api/NodeValueType.java // public enum NodeValueType { // /** // * Represents an array of a certain type of element. // */ // ARRAY, // // /** // * Represents a binary value (0 = false, 1 = true). // */ // BOOLEAN, // // /** // * Represents a default value. // */ // DEFAULT, // // /** // * Represents a value within a list of possible values. // */ // ENUM, // // /** // * Represents a floating point number. // */ // FLOAT, // // /** // * Represents an integer. // */ // INTEGER, // // /** // * Represents a null (empty) value. // */ // NULL, // // /** // * Represents a character sequence. // */ // STRING // } // Path: core/src/main/java/com/torchmind/candle/node/property/array/EnumArrayPropertyNode.java import com.torchmind.candle.api.IDocumentNode; import com.torchmind.candle.api.NodeValueType; import javax.annotation.Nonnull; import java.lang.reflect.Array; import java.util.Arrays; * @param array The array. * @return The node. */ @Nonnull public EnumArrayPropertyNode array (@Nonnull String[] array) { this.array = array; return this; } /** * Sets the enum array. * * @param array The array. * @param <T> The enum type. * @return The node. */ @Nonnull public <T extends Enum> EnumArrayPropertyNode array (@Nonnull T[] array) { String[] convertedArray = new String[array.length]; for (int i = 0; i < array.length; i++) { convertedArray[i] = (array[i] != null ? array[i].name () : null); } return this.array (convertedArray); } /** * {@inheritDoc} */ @Nonnull @Override
public NodeValueType itemType () {
Torchmind/Candle
core/src/main/java/com/torchmind/candle/node/AbstractNode.java
// Path: api/src/main/java/com/torchmind/candle/api/IDocumentNode.java // public interface IDocumentNode extends IObjectNode { // String NAME = "###ROOT###"; // // /** // * {@inheritDoc} // */ // @Nonnull // @Override // default IDocumentNode document () { // return this; // } // // /** // * {@inheritDoc} // */ // @Override // default boolean isDocumentRoot () { // return true; // } // // /** // * {@inheritDoc} // */ // @Nonnull // @Override // default INamedNode name (@Nullable String name) { // throw new UnsupportedOperationException ("Cannot alter node name of root document node"); // } // // /** // * {@inheritDoc} // */ // @Nonnull // @Override // default String name () { // return NAME; // } // // /** // * {@inheritDoc} // */ // @Nonnull // @Override // default NodeType type () { // return NodeType.DOCUMENT; // } // } // // Path: api/src/main/java/com/torchmind/candle/api/INode.java // public interface INode { // // /** // * Retrieves the parent document node. // * // * @return The node. // */ // @Nonnull // IDocumentNode document (); // // /** // * Ensures that a node consists of a certain type. // * // * @param type The type. // * @return The node. // * // * @throws java.lang.IllegalStateException when the node type differs. // */ // @Nonnull // INode ensureType (@Nonnull NodeType type) throws IllegalStateException; // // /** // * Retrieves the node type. // * // * @return The type. // */ // @Nonnull // NodeType type (); // } // // Path: api/src/main/java/com/torchmind/candle/api/NodeType.java // public enum NodeType { // /** // * Represents a Single-Line or Multi-Line comment. // * Nodes that identify themselves as comment nodes implement {@link com.torchmind.candle.api.ICommentNode}. // */ // COMMENT, // // /** // * Represents an inclusion. // * <strong>Note:</strong> There are no definitions for this node type yet as this type has not been fully documented // * in the Candle specification yet. // */ // INCLUDE, // // /** // * Represents a document. // * Nodes that identify themselves as document nodes implement {@link com.torchmind.candle.api.IDocumentNode}. // */ // DOCUMENT, // // /** // * Represents an object. // * Nodes that identify themselves as object nodes implement {@link com.torchmind.candle.api.IObjectNode}. // */ // OBJECT, // // /** // * Represents a property. // * Nodes that identify themselves as property nodes implement {@link com.torchmind.candle.api.IPropertyNode}. // */ // PROPERTY // }
import com.torchmind.candle.api.IDocumentNode; import com.torchmind.candle.api.INode; import com.torchmind.candle.api.NodeType; import javax.annotation.Nonnull;
/* * Copyright 2015 Johannes Donath <johannesd@torchmind.com> * and other copyright owners as documented in the project's IP log. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.torchmind.candle.node; /** * Provides an abstract utility implementation of {@link com.torchmind.candle.api.INode}. * * @author Johannes Donath */ public abstract class AbstractNode implements INode { private IDocumentNode documentNode; protected AbstractNode () { } public AbstractNode (@Nonnull IDocumentNode documentNode) { super (); this.documentNode = documentNode; } /** * {@inheritDoc} */ @Nonnull @Override public IDocumentNode document () { return this.documentNode; } /** * {@inheritDoc} */ @Nonnull @Override
// Path: api/src/main/java/com/torchmind/candle/api/IDocumentNode.java // public interface IDocumentNode extends IObjectNode { // String NAME = "###ROOT###"; // // /** // * {@inheritDoc} // */ // @Nonnull // @Override // default IDocumentNode document () { // return this; // } // // /** // * {@inheritDoc} // */ // @Override // default boolean isDocumentRoot () { // return true; // } // // /** // * {@inheritDoc} // */ // @Nonnull // @Override // default INamedNode name (@Nullable String name) { // throw new UnsupportedOperationException ("Cannot alter node name of root document node"); // } // // /** // * {@inheritDoc} // */ // @Nonnull // @Override // default String name () { // return NAME; // } // // /** // * {@inheritDoc} // */ // @Nonnull // @Override // default NodeType type () { // return NodeType.DOCUMENT; // } // } // // Path: api/src/main/java/com/torchmind/candle/api/INode.java // public interface INode { // // /** // * Retrieves the parent document node. // * // * @return The node. // */ // @Nonnull // IDocumentNode document (); // // /** // * Ensures that a node consists of a certain type. // * // * @param type The type. // * @return The node. // * // * @throws java.lang.IllegalStateException when the node type differs. // */ // @Nonnull // INode ensureType (@Nonnull NodeType type) throws IllegalStateException; // // /** // * Retrieves the node type. // * // * @return The type. // */ // @Nonnull // NodeType type (); // } // // Path: api/src/main/java/com/torchmind/candle/api/NodeType.java // public enum NodeType { // /** // * Represents a Single-Line or Multi-Line comment. // * Nodes that identify themselves as comment nodes implement {@link com.torchmind.candle.api.ICommentNode}. // */ // COMMENT, // // /** // * Represents an inclusion. // * <strong>Note:</strong> There are no definitions for this node type yet as this type has not been fully documented // * in the Candle specification yet. // */ // INCLUDE, // // /** // * Represents a document. // * Nodes that identify themselves as document nodes implement {@link com.torchmind.candle.api.IDocumentNode}. // */ // DOCUMENT, // // /** // * Represents an object. // * Nodes that identify themselves as object nodes implement {@link com.torchmind.candle.api.IObjectNode}. // */ // OBJECT, // // /** // * Represents a property. // * Nodes that identify themselves as property nodes implement {@link com.torchmind.candle.api.IPropertyNode}. // */ // PROPERTY // } // Path: core/src/main/java/com/torchmind/candle/node/AbstractNode.java import com.torchmind.candle.api.IDocumentNode; import com.torchmind.candle.api.INode; import com.torchmind.candle.api.NodeType; import javax.annotation.Nonnull; /* * Copyright 2015 Johannes Donath <johannesd@torchmind.com> * and other copyright owners as documented in the project's IP log. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.torchmind.candle.node; /** * Provides an abstract utility implementation of {@link com.torchmind.candle.api.INode}. * * @author Johannes Donath */ public abstract class AbstractNode implements INode { private IDocumentNode documentNode; protected AbstractNode () { } public AbstractNode (@Nonnull IDocumentNode documentNode) { super (); this.documentNode = documentNode; } /** * {@inheritDoc} */ @Nonnull @Override public IDocumentNode document () { return this.documentNode; } /** * {@inheritDoc} */ @Nonnull @Override
public AbstractNode ensureType (@Nonnull NodeType type) throws IllegalStateException {
Torchmind/Candle
core/src/main/java/com/torchmind/candle/node/property/FloatPropertyNode.java
// Path: api/src/main/java/com/torchmind/candle/api/IDocumentNode.java // public interface IDocumentNode extends IObjectNode { // String NAME = "###ROOT###"; // // /** // * {@inheritDoc} // */ // @Nonnull // @Override // default IDocumentNode document () { // return this; // } // // /** // * {@inheritDoc} // */ // @Override // default boolean isDocumentRoot () { // return true; // } // // /** // * {@inheritDoc} // */ // @Nonnull // @Override // default INamedNode name (@Nullable String name) { // throw new UnsupportedOperationException ("Cannot alter node name of root document node"); // } // // /** // * {@inheritDoc} // */ // @Nonnull // @Override // default String name () { // return NAME; // } // // /** // * {@inheritDoc} // */ // @Nonnull // @Override // default NodeType type () { // return NodeType.DOCUMENT; // } // } // // Path: api/src/main/java/com/torchmind/candle/api/NodeValueType.java // public enum NodeValueType { // /** // * Represents an array of a certain type of element. // */ // ARRAY, // // /** // * Represents a binary value (0 = false, 1 = true). // */ // BOOLEAN, // // /** // * Represents a default value. // */ // DEFAULT, // // /** // * Represents a value within a list of possible values. // */ // ENUM, // // /** // * Represents a floating point number. // */ // FLOAT, // // /** // * Represents an integer. // */ // INTEGER, // // /** // * Represents a null (empty) value. // */ // NULL, // // /** // * Represents a character sequence. // */ // STRING // }
import com.torchmind.candle.api.IDocumentNode; import com.torchmind.candle.api.NodeValueType; import javax.annotation.Nonnegative; import javax.annotation.Nonnull;
/* * Copyright 2015 Johannes Donath <johannesd@torchmind.com> * and other copyright owners as documented in the project's IP log. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.torchmind.candle.node.property; /** * Represents a float value within the tree. * * @author Johannes Donath */ public class FloatPropertyNode extends AbstractPropertyNode { private float value;
// Path: api/src/main/java/com/torchmind/candle/api/IDocumentNode.java // public interface IDocumentNode extends IObjectNode { // String NAME = "###ROOT###"; // // /** // * {@inheritDoc} // */ // @Nonnull // @Override // default IDocumentNode document () { // return this; // } // // /** // * {@inheritDoc} // */ // @Override // default boolean isDocumentRoot () { // return true; // } // // /** // * {@inheritDoc} // */ // @Nonnull // @Override // default INamedNode name (@Nullable String name) { // throw new UnsupportedOperationException ("Cannot alter node name of root document node"); // } // // /** // * {@inheritDoc} // */ // @Nonnull // @Override // default String name () { // return NAME; // } // // /** // * {@inheritDoc} // */ // @Nonnull // @Override // default NodeType type () { // return NodeType.DOCUMENT; // } // } // // Path: api/src/main/java/com/torchmind/candle/api/NodeValueType.java // public enum NodeValueType { // /** // * Represents an array of a certain type of element. // */ // ARRAY, // // /** // * Represents a binary value (0 = false, 1 = true). // */ // BOOLEAN, // // /** // * Represents a default value. // */ // DEFAULT, // // /** // * Represents a value within a list of possible values. // */ // ENUM, // // /** // * Represents a floating point number. // */ // FLOAT, // // /** // * Represents an integer. // */ // INTEGER, // // /** // * Represents a null (empty) value. // */ // NULL, // // /** // * Represents a character sequence. // */ // STRING // } // Path: core/src/main/java/com/torchmind/candle/node/property/FloatPropertyNode.java import com.torchmind.candle.api.IDocumentNode; import com.torchmind.candle.api.NodeValueType; import javax.annotation.Nonnegative; import javax.annotation.Nonnull; /* * Copyright 2015 Johannes Donath <johannesd@torchmind.com> * and other copyright owners as documented in the project's IP log. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.torchmind.candle.node.property; /** * Represents a float value within the tree. * * @author Johannes Donath */ public class FloatPropertyNode extends AbstractPropertyNode { private float value;
public FloatPropertyNode (@Nonnull IDocumentNode documentNode, @Nonnull String name, float value) {
Torchmind/Candle
core/src/main/java/com/torchmind/candle/node/property/FloatPropertyNode.java
// Path: api/src/main/java/com/torchmind/candle/api/IDocumentNode.java // public interface IDocumentNode extends IObjectNode { // String NAME = "###ROOT###"; // // /** // * {@inheritDoc} // */ // @Nonnull // @Override // default IDocumentNode document () { // return this; // } // // /** // * {@inheritDoc} // */ // @Override // default boolean isDocumentRoot () { // return true; // } // // /** // * {@inheritDoc} // */ // @Nonnull // @Override // default INamedNode name (@Nullable String name) { // throw new UnsupportedOperationException ("Cannot alter node name of root document node"); // } // // /** // * {@inheritDoc} // */ // @Nonnull // @Override // default String name () { // return NAME; // } // // /** // * {@inheritDoc} // */ // @Nonnull // @Override // default NodeType type () { // return NodeType.DOCUMENT; // } // } // // Path: api/src/main/java/com/torchmind/candle/api/NodeValueType.java // public enum NodeValueType { // /** // * Represents an array of a certain type of element. // */ // ARRAY, // // /** // * Represents a binary value (0 = false, 1 = true). // */ // BOOLEAN, // // /** // * Represents a default value. // */ // DEFAULT, // // /** // * Represents a value within a list of possible values. // */ // ENUM, // // /** // * Represents a floating point number. // */ // FLOAT, // // /** // * Represents an integer. // */ // INTEGER, // // /** // * Represents a null (empty) value. // */ // NULL, // // /** // * Represents a character sequence. // */ // STRING // }
import com.torchmind.candle.api.IDocumentNode; import com.torchmind.candle.api.NodeValueType; import javax.annotation.Nonnegative; import javax.annotation.Nonnull;
/* * Copyright 2015 Johannes Donath <johannesd@torchmind.com> * and other copyright owners as documented in the project's IP log. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.torchmind.candle.node.property; /** * Represents a float value within the tree. * * @author Johannes Donath */ public class FloatPropertyNode extends AbstractPropertyNode { private float value; public FloatPropertyNode (@Nonnull IDocumentNode documentNode, @Nonnull String name, float value) { super (documentNode, name); this.value (value); } /** * Retrieves the float value. * * @return The value. */ public float value () { return this.value; } /** * Sets the float value. * * @param value The value. * @return The node. */ @Nonnull public FloatPropertyNode value (float value) { this.value = value; return this; } /** * {@inheritDoc} */ @Nonnull @Override
// Path: api/src/main/java/com/torchmind/candle/api/IDocumentNode.java // public interface IDocumentNode extends IObjectNode { // String NAME = "###ROOT###"; // // /** // * {@inheritDoc} // */ // @Nonnull // @Override // default IDocumentNode document () { // return this; // } // // /** // * {@inheritDoc} // */ // @Override // default boolean isDocumentRoot () { // return true; // } // // /** // * {@inheritDoc} // */ // @Nonnull // @Override // default INamedNode name (@Nullable String name) { // throw new UnsupportedOperationException ("Cannot alter node name of root document node"); // } // // /** // * {@inheritDoc} // */ // @Nonnull // @Override // default String name () { // return NAME; // } // // /** // * {@inheritDoc} // */ // @Nonnull // @Override // default NodeType type () { // return NodeType.DOCUMENT; // } // } // // Path: api/src/main/java/com/torchmind/candle/api/NodeValueType.java // public enum NodeValueType { // /** // * Represents an array of a certain type of element. // */ // ARRAY, // // /** // * Represents a binary value (0 = false, 1 = true). // */ // BOOLEAN, // // /** // * Represents a default value. // */ // DEFAULT, // // /** // * Represents a value within a list of possible values. // */ // ENUM, // // /** // * Represents a floating point number. // */ // FLOAT, // // /** // * Represents an integer. // */ // INTEGER, // // /** // * Represents a null (empty) value. // */ // NULL, // // /** // * Represents a character sequence. // */ // STRING // } // Path: core/src/main/java/com/torchmind/candle/node/property/FloatPropertyNode.java import com.torchmind.candle.api.IDocumentNode; import com.torchmind.candle.api.NodeValueType; import javax.annotation.Nonnegative; import javax.annotation.Nonnull; /* * Copyright 2015 Johannes Donath <johannesd@torchmind.com> * and other copyright owners as documented in the project's IP log. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.torchmind.candle.node.property; /** * Represents a float value within the tree. * * @author Johannes Donath */ public class FloatPropertyNode extends AbstractPropertyNode { private float value; public FloatPropertyNode (@Nonnull IDocumentNode documentNode, @Nonnull String name, float value) { super (documentNode, name); this.value (value); } /** * Retrieves the float value. * * @return The value. */ public float value () { return this.value; } /** * Sets the float value. * * @param value The value. * @return The node. */ @Nonnull public FloatPropertyNode value (float value) { this.value = value; return this; } /** * {@inheritDoc} */ @Nonnull @Override
public NodeValueType valueType () {
Torchmind/Candle
core/src/main/java/com/torchmind/candle/node/property/StringPropertyNode.java
// Path: api/src/main/java/com/torchmind/candle/api/IDocumentNode.java // public interface IDocumentNode extends IObjectNode { // String NAME = "###ROOT###"; // // /** // * {@inheritDoc} // */ // @Nonnull // @Override // default IDocumentNode document () { // return this; // } // // /** // * {@inheritDoc} // */ // @Override // default boolean isDocumentRoot () { // return true; // } // // /** // * {@inheritDoc} // */ // @Nonnull // @Override // default INamedNode name (@Nullable String name) { // throw new UnsupportedOperationException ("Cannot alter node name of root document node"); // } // // /** // * {@inheritDoc} // */ // @Nonnull // @Override // default String name () { // return NAME; // } // // /** // * {@inheritDoc} // */ // @Nonnull // @Override // default NodeType type () { // return NodeType.DOCUMENT; // } // } // // Path: api/src/main/java/com/torchmind/candle/api/NodeValueType.java // public enum NodeValueType { // /** // * Represents an array of a certain type of element. // */ // ARRAY, // // /** // * Represents a binary value (0 = false, 1 = true). // */ // BOOLEAN, // // /** // * Represents a default value. // */ // DEFAULT, // // /** // * Represents a value within a list of possible values. // */ // ENUM, // // /** // * Represents a floating point number. // */ // FLOAT, // // /** // * Represents an integer. // */ // INTEGER, // // /** // * Represents a null (empty) value. // */ // NULL, // // /** // * Represents a character sequence. // */ // STRING // }
import com.torchmind.candle.api.IDocumentNode; import com.torchmind.candle.api.NodeValueType; import javax.annotation.Nonnull;
/* * Copyright 2015 Johannes Donath <johannesd@torchmind.com> * and other copyright owners as documented in the project's IP log. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.torchmind.candle.node.property; /** * Represents a string value within the tree. * * @author Johannes Donath */ public class StringPropertyNode extends AbstractPropertyNode { private String value;
// Path: api/src/main/java/com/torchmind/candle/api/IDocumentNode.java // public interface IDocumentNode extends IObjectNode { // String NAME = "###ROOT###"; // // /** // * {@inheritDoc} // */ // @Nonnull // @Override // default IDocumentNode document () { // return this; // } // // /** // * {@inheritDoc} // */ // @Override // default boolean isDocumentRoot () { // return true; // } // // /** // * {@inheritDoc} // */ // @Nonnull // @Override // default INamedNode name (@Nullable String name) { // throw new UnsupportedOperationException ("Cannot alter node name of root document node"); // } // // /** // * {@inheritDoc} // */ // @Nonnull // @Override // default String name () { // return NAME; // } // // /** // * {@inheritDoc} // */ // @Nonnull // @Override // default NodeType type () { // return NodeType.DOCUMENT; // } // } // // Path: api/src/main/java/com/torchmind/candle/api/NodeValueType.java // public enum NodeValueType { // /** // * Represents an array of a certain type of element. // */ // ARRAY, // // /** // * Represents a binary value (0 = false, 1 = true). // */ // BOOLEAN, // // /** // * Represents a default value. // */ // DEFAULT, // // /** // * Represents a value within a list of possible values. // */ // ENUM, // // /** // * Represents a floating point number. // */ // FLOAT, // // /** // * Represents an integer. // */ // INTEGER, // // /** // * Represents a null (empty) value. // */ // NULL, // // /** // * Represents a character sequence. // */ // STRING // } // Path: core/src/main/java/com/torchmind/candle/node/property/StringPropertyNode.java import com.torchmind.candle.api.IDocumentNode; import com.torchmind.candle.api.NodeValueType; import javax.annotation.Nonnull; /* * Copyright 2015 Johannes Donath <johannesd@torchmind.com> * and other copyright owners as documented in the project's IP log. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.torchmind.candle.node.property; /** * Represents a string value within the tree. * * @author Johannes Donath */ public class StringPropertyNode extends AbstractPropertyNode { private String value;
public StringPropertyNode (@Nonnull IDocumentNode documentNode, @Nonnull String name, @Nonnull String value) {
Torchmind/Candle
core/src/main/java/com/torchmind/candle/node/property/StringPropertyNode.java
// Path: api/src/main/java/com/torchmind/candle/api/IDocumentNode.java // public interface IDocumentNode extends IObjectNode { // String NAME = "###ROOT###"; // // /** // * {@inheritDoc} // */ // @Nonnull // @Override // default IDocumentNode document () { // return this; // } // // /** // * {@inheritDoc} // */ // @Override // default boolean isDocumentRoot () { // return true; // } // // /** // * {@inheritDoc} // */ // @Nonnull // @Override // default INamedNode name (@Nullable String name) { // throw new UnsupportedOperationException ("Cannot alter node name of root document node"); // } // // /** // * {@inheritDoc} // */ // @Nonnull // @Override // default String name () { // return NAME; // } // // /** // * {@inheritDoc} // */ // @Nonnull // @Override // default NodeType type () { // return NodeType.DOCUMENT; // } // } // // Path: api/src/main/java/com/torchmind/candle/api/NodeValueType.java // public enum NodeValueType { // /** // * Represents an array of a certain type of element. // */ // ARRAY, // // /** // * Represents a binary value (0 = false, 1 = true). // */ // BOOLEAN, // // /** // * Represents a default value. // */ // DEFAULT, // // /** // * Represents a value within a list of possible values. // */ // ENUM, // // /** // * Represents a floating point number. // */ // FLOAT, // // /** // * Represents an integer. // */ // INTEGER, // // /** // * Represents a null (empty) value. // */ // NULL, // // /** // * Represents a character sequence. // */ // STRING // }
import com.torchmind.candle.api.IDocumentNode; import com.torchmind.candle.api.NodeValueType; import javax.annotation.Nonnull;
/* * Copyright 2015 Johannes Donath <johannesd@torchmind.com> * and other copyright owners as documented in the project's IP log. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.torchmind.candle.node.property; /** * Represents a string value within the tree. * * @author Johannes Donath */ public class StringPropertyNode extends AbstractPropertyNode { private String value; public StringPropertyNode (@Nonnull IDocumentNode documentNode, @Nonnull String name, @Nonnull String value) { super (documentNode, name); this.value (value); } /** * Retrieves the string value. */ @Nonnull public String value () { return this.value; } /** * Sets the string value. * * @param value The value. * @return The node. */ @Nonnull public StringPropertyNode value (@Nonnull String value) { this.value = value; return this; } /** * {@inheritDoc} */ @Nonnull @Override
// Path: api/src/main/java/com/torchmind/candle/api/IDocumentNode.java // public interface IDocumentNode extends IObjectNode { // String NAME = "###ROOT###"; // // /** // * {@inheritDoc} // */ // @Nonnull // @Override // default IDocumentNode document () { // return this; // } // // /** // * {@inheritDoc} // */ // @Override // default boolean isDocumentRoot () { // return true; // } // // /** // * {@inheritDoc} // */ // @Nonnull // @Override // default INamedNode name (@Nullable String name) { // throw new UnsupportedOperationException ("Cannot alter node name of root document node"); // } // // /** // * {@inheritDoc} // */ // @Nonnull // @Override // default String name () { // return NAME; // } // // /** // * {@inheritDoc} // */ // @Nonnull // @Override // default NodeType type () { // return NodeType.DOCUMENT; // } // } // // Path: api/src/main/java/com/torchmind/candle/api/NodeValueType.java // public enum NodeValueType { // /** // * Represents an array of a certain type of element. // */ // ARRAY, // // /** // * Represents a binary value (0 = false, 1 = true). // */ // BOOLEAN, // // /** // * Represents a default value. // */ // DEFAULT, // // /** // * Represents a value within a list of possible values. // */ // ENUM, // // /** // * Represents a floating point number. // */ // FLOAT, // // /** // * Represents an integer. // */ // INTEGER, // // /** // * Represents a null (empty) value. // */ // NULL, // // /** // * Represents a character sequence. // */ // STRING // } // Path: core/src/main/java/com/torchmind/candle/node/property/StringPropertyNode.java import com.torchmind.candle.api.IDocumentNode; import com.torchmind.candle.api.NodeValueType; import javax.annotation.Nonnull; /* * Copyright 2015 Johannes Donath <johannesd@torchmind.com> * and other copyright owners as documented in the project's IP log. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.torchmind.candle.node.property; /** * Represents a string value within the tree. * * @author Johannes Donath */ public class StringPropertyNode extends AbstractPropertyNode { private String value; public StringPropertyNode (@Nonnull IDocumentNode documentNode, @Nonnull String name, @Nonnull String value) { super (documentNode, name); this.value (value); } /** * Retrieves the string value. */ @Nonnull public String value () { return this.value; } /** * Sets the string value. * * @param value The value. * @return The node. */ @Nonnull public StringPropertyNode value (@Nonnull String value) { this.value = value; return this; } /** * {@inheritDoc} */ @Nonnull @Override
public NodeValueType valueType () {
Torchmind/Candle
core/src/main/java/com/torchmind/candle/node/property/array/AbstractArrayPropertyNode.java
// Path: api/src/main/java/com/torchmind/candle/api/IArrayPropertyNode.java // public interface IArrayPropertyNode extends IPropertyNode { // // /** // * Ensures the array consists of a certain type of element. // * // * @param valueType The expected value type. // * @return The node. // * // * @throws java.lang.IllegalStateException when the expected value type differs. // */ // @Nonnull // IArrayPropertyNode ensureItemType (@Nonnull NodeValueType valueType) throws IllegalStateException; // // /** // * Retrieves the array item type. // * // * @return The type. // */ // @Nonnull // NodeValueType itemType (); // // /** // * Retrieves the array length. // * // * @return The length. // */ // @Nonnegative // int length (); // // /** // * {@inheritDoc} // */ // @Nonnull // @Override // default NodeValueType valueType () { // return NodeValueType.ARRAY; // } // } // // Path: api/src/main/java/com/torchmind/candle/api/IDocumentNode.java // public interface IDocumentNode extends IObjectNode { // String NAME = "###ROOT###"; // // /** // * {@inheritDoc} // */ // @Nonnull // @Override // default IDocumentNode document () { // return this; // } // // /** // * {@inheritDoc} // */ // @Override // default boolean isDocumentRoot () { // return true; // } // // /** // * {@inheritDoc} // */ // @Nonnull // @Override // default INamedNode name (@Nullable String name) { // throw new UnsupportedOperationException ("Cannot alter node name of root document node"); // } // // /** // * {@inheritDoc} // */ // @Nonnull // @Override // default String name () { // return NAME; // } // // /** // * {@inheritDoc} // */ // @Nonnull // @Override // default NodeType type () { // return NodeType.DOCUMENT; // } // } // // Path: api/src/main/java/com/torchmind/candle/api/NodeValueType.java // public enum NodeValueType { // /** // * Represents an array of a certain type of element. // */ // ARRAY, // // /** // * Represents a binary value (0 = false, 1 = true). // */ // BOOLEAN, // // /** // * Represents a default value. // */ // DEFAULT, // // /** // * Represents a value within a list of possible values. // */ // ENUM, // // /** // * Represents a floating point number. // */ // FLOAT, // // /** // * Represents an integer. // */ // INTEGER, // // /** // * Represents a null (empty) value. // */ // NULL, // // /** // * Represents a character sequence. // */ // STRING // } // // Path: core/src/main/java/com/torchmind/candle/node/property/AbstractPropertyNode.java // public abstract class AbstractPropertyNode extends AbstractNamedNode implements IPropertyNode { // // public AbstractPropertyNode (@Nonnull IDocumentNode documentNode, @Nonnull String name) { // super (documentNode, name); // } // // /** // * {@inheritDoc} // */ // @Nonnull // @Override // public IPropertyNode ensureValueType (@Nonnull NodeValueType valueType) throws IllegalStateException { // if (this.valueType () != valueType) { // throw new IllegalStateException ("Expected value node representing type " + valueType + " but found " + this.valueType ()); // } // return this; // } // }
import com.torchmind.candle.api.IArrayPropertyNode; import com.torchmind.candle.api.IDocumentNode; import com.torchmind.candle.api.NodeValueType; import com.torchmind.candle.node.property.AbstractPropertyNode; import javax.annotation.Nonnull;
/* * Copyright 2015 Johannes Donath <johannesd@torchmind.com> * and other copyright owners as documented in the project's IP log. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.torchmind.candle.node.property.array; /** * Provides an abstract implementation of {@link com.torchmind.candle.api.IArrayPropertyNode}. * * @author Johannes Donath */ public abstract class AbstractArrayPropertyNode extends AbstractPropertyNode implements IArrayPropertyNode { public AbstractArrayPropertyNode (@Nonnull IDocumentNode documentNode, @Nonnull String name) { super (documentNode, name); } /** * {@inheritDoc} */ @Nonnull @Override
// Path: api/src/main/java/com/torchmind/candle/api/IArrayPropertyNode.java // public interface IArrayPropertyNode extends IPropertyNode { // // /** // * Ensures the array consists of a certain type of element. // * // * @param valueType The expected value type. // * @return The node. // * // * @throws java.lang.IllegalStateException when the expected value type differs. // */ // @Nonnull // IArrayPropertyNode ensureItemType (@Nonnull NodeValueType valueType) throws IllegalStateException; // // /** // * Retrieves the array item type. // * // * @return The type. // */ // @Nonnull // NodeValueType itemType (); // // /** // * Retrieves the array length. // * // * @return The length. // */ // @Nonnegative // int length (); // // /** // * {@inheritDoc} // */ // @Nonnull // @Override // default NodeValueType valueType () { // return NodeValueType.ARRAY; // } // } // // Path: api/src/main/java/com/torchmind/candle/api/IDocumentNode.java // public interface IDocumentNode extends IObjectNode { // String NAME = "###ROOT###"; // // /** // * {@inheritDoc} // */ // @Nonnull // @Override // default IDocumentNode document () { // return this; // } // // /** // * {@inheritDoc} // */ // @Override // default boolean isDocumentRoot () { // return true; // } // // /** // * {@inheritDoc} // */ // @Nonnull // @Override // default INamedNode name (@Nullable String name) { // throw new UnsupportedOperationException ("Cannot alter node name of root document node"); // } // // /** // * {@inheritDoc} // */ // @Nonnull // @Override // default String name () { // return NAME; // } // // /** // * {@inheritDoc} // */ // @Nonnull // @Override // default NodeType type () { // return NodeType.DOCUMENT; // } // } // // Path: api/src/main/java/com/torchmind/candle/api/NodeValueType.java // public enum NodeValueType { // /** // * Represents an array of a certain type of element. // */ // ARRAY, // // /** // * Represents a binary value (0 = false, 1 = true). // */ // BOOLEAN, // // /** // * Represents a default value. // */ // DEFAULT, // // /** // * Represents a value within a list of possible values. // */ // ENUM, // // /** // * Represents a floating point number. // */ // FLOAT, // // /** // * Represents an integer. // */ // INTEGER, // // /** // * Represents a null (empty) value. // */ // NULL, // // /** // * Represents a character sequence. // */ // STRING // } // // Path: core/src/main/java/com/torchmind/candle/node/property/AbstractPropertyNode.java // public abstract class AbstractPropertyNode extends AbstractNamedNode implements IPropertyNode { // // public AbstractPropertyNode (@Nonnull IDocumentNode documentNode, @Nonnull String name) { // super (documentNode, name); // } // // /** // * {@inheritDoc} // */ // @Nonnull // @Override // public IPropertyNode ensureValueType (@Nonnull NodeValueType valueType) throws IllegalStateException { // if (this.valueType () != valueType) { // throw new IllegalStateException ("Expected value node representing type " + valueType + " but found " + this.valueType ()); // } // return this; // } // } // Path: core/src/main/java/com/torchmind/candle/node/property/array/AbstractArrayPropertyNode.java import com.torchmind.candle.api.IArrayPropertyNode; import com.torchmind.candle.api.IDocumentNode; import com.torchmind.candle.api.NodeValueType; import com.torchmind.candle.node.property.AbstractPropertyNode; import javax.annotation.Nonnull; /* * Copyright 2015 Johannes Donath <johannesd@torchmind.com> * and other copyright owners as documented in the project's IP log. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.torchmind.candle.node.property.array; /** * Provides an abstract implementation of {@link com.torchmind.candle.api.IArrayPropertyNode}. * * @author Johannes Donath */ public abstract class AbstractArrayPropertyNode extends AbstractPropertyNode implements IArrayPropertyNode { public AbstractArrayPropertyNode (@Nonnull IDocumentNode documentNode, @Nonnull String name) { super (documentNode, name); } /** * {@inheritDoc} */ @Nonnull @Override
public AbstractArrayPropertyNode ensureItemType (@Nonnull NodeValueType valueType) throws IllegalStateException {
tractionsoftware/gwt-traction
src/main/java/com/tractionsoftware/gwt/user/client/util/MiscUtils.java
// Path: src/main/java/com/tractionsoftware/gwt/user/client/impl/DocumentStyleImpl.java // public class DocumentStyleImpl { // // public native String getComputedStyle(Element elem, String hyphenName, String camelName) /*-{ // try { // var cStyle = $doc.defaultView.getComputedStyle(elem); // return cStyle && cStyle.getPropertyValue ? cStyle.getPropertyValue(hyphenName) : null; // } catch(e) {return null;} // }-*/; // // }
import com.google.gwt.core.client.GWT; import com.google.gwt.dom.client.Element; import com.google.gwt.dom.client.NativeEvent; import com.tractionsoftware.gwt.user.client.impl.DocumentStyleImpl;
/* * Copyright 2010 Traction Software, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not * use this file except in compliance with the License. You may obtain a copy of * the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the * License for the specific language governing permissions and limitations under * the License. */ package com.tractionsoftware.gwt.user.client.util; /** * Miscellaneous utility functions that are used in a few different places. */ public class MiscUtils { /** * Note: It seems like NativeEvent.getCharCode() would be equivalent. */ public static native char getCharCode(NativeEvent e) /*-{ return e.charCode || e.keyCode; }-*/; public static final String getComputedStyle(Element e, String camelName) { // sometimes IE throws an exception. thanks IE! try { return getStyleImpl().getComputedStyle(e, hyphenize(camelName), camelName); } catch (Exception xcp) { return null; } } public static final int getComputedStyleInt(Element e, String camelName) { String num = getComputedStyle(e, camelName); return num != null ? parseInt(num) : 0; } public static final int parseInt(String val) { return parseInt(val, 10); } public static final native int parseInt(String val, int radix) /*-{ return parseInt(val, radix) || 0; }-*/; // ---------------------------------------------------------------------- // DocumentStyleImpl.getComputedStyle from gwtquery
// Path: src/main/java/com/tractionsoftware/gwt/user/client/impl/DocumentStyleImpl.java // public class DocumentStyleImpl { // // public native String getComputedStyle(Element elem, String hyphenName, String camelName) /*-{ // try { // var cStyle = $doc.defaultView.getComputedStyle(elem); // return cStyle && cStyle.getPropertyValue ? cStyle.getPropertyValue(hyphenName) : null; // } catch(e) {return null;} // }-*/; // // } // Path: src/main/java/com/tractionsoftware/gwt/user/client/util/MiscUtils.java import com.google.gwt.core.client.GWT; import com.google.gwt.dom.client.Element; import com.google.gwt.dom.client.NativeEvent; import com.tractionsoftware.gwt.user.client.impl.DocumentStyleImpl; /* * Copyright 2010 Traction Software, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not * use this file except in compliance with the License. You may obtain a copy of * the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the * License for the specific language governing permissions and limitations under * the License. */ package com.tractionsoftware.gwt.user.client.util; /** * Miscellaneous utility functions that are used in a few different places. */ public class MiscUtils { /** * Note: It seems like NativeEvent.getCharCode() would be equivalent. */ public static native char getCharCode(NativeEvent e) /*-{ return e.charCode || e.keyCode; }-*/; public static final String getComputedStyle(Element e, String camelName) { // sometimes IE throws an exception. thanks IE! try { return getStyleImpl().getComputedStyle(e, hyphenize(camelName), camelName); } catch (Exception xcp) { return null; } } public static final int getComputedStyleInt(Element e, String camelName) { String num = getComputedStyle(e, camelName); return num != null ? parseInt(num) : 0; } public static final int parseInt(String val) { return parseInt(val, 10); } public static final native int parseInt(String val, int radix) /*-{ return parseInt(val, radix) || 0; }-*/; // ---------------------------------------------------------------------- // DocumentStyleImpl.getComputedStyle from gwtquery
private static DocumentStyleImpl styleImpl = null;
tractionsoftware/gwt-traction
src-demo/com/tractionsoftware/gwt/demo/autosizingtextarea/client/AutoSizingTextAreaDemo.java
// Path: src/main/java/com/tractionsoftware/gwt/user/client/ui/AutoSizingTextArea.java // public class AutoSizingTextArea extends AutoSizingBase<TextAreaWithSelection, TextArea> implements ResizeHandler { // // protected int divExtra = 0; // protected HandlerRegistration resizeRegistration = null; // // public AutoSizingTextArea() { // this(new TextAreaWithSelection()); // } // private AutoSizingTextArea(TextAreaWithSelection box) { // super(box, new TextArea()); // } // public AutoSizingTextArea(TextAreaWithSelection box, int minSize, int maxSize) { // super(box, new TextArea()); // setMinSize(minSize); // setMaxSize(maxSize); // } // // @Override // protected void onLoad() { // Element boxElement = box.getElement(); // // int lineHeight = MiscUtils.getComputedStyleInt(boxElement, "lineHeight"); // setExtraSize(lineHeight); // // setMinFromCss("minHeight"); // setMaxFromCss("maxHeight"); // // // we also need to make sure the widths are the same. // matchStyles("width"); // // // don't let the shadow have any size // shadow.setHeight("0"); // // divExtra = 0; // divExtra += MiscUtils.getComputedStyleInt(boxElement, "paddingTop"); // divExtra += MiscUtils.getComputedStyleInt(boxElement, "paddingBottom"); // // resizeRegistration = Window.addResizeHandler(this); // // super.onLoad(); // } // // @Override // protected void onUnload() { // // fix leak reported in issue #4 // if (resizeRegistration != null) { // resizeRegistration.removeHandler(); // resizeRegistration = null; // } // // super.onUnload(); // } // // @Override // public void onResize(ResizeEvent event) { // matchStyles("width"); // adjustSize(); // } // // @Override // public void setHeight(int height) { // div.setHeight(divExtra+height+"px"); // box.setHeight(height+"px"); // } // // /** // * Returns the size of the shadow element // */ // @Override // public int getShadowSize() { // Element shadowElement = shadow.getElement(); // shadowElement.setScrollTop(10000); // return shadowElement.getScrollTop(); // } // // /** // * @param text the text that should be set on the shadow to // * determine the appropriate size of the widget // */ // @Override // public void setShadowText(String text) { // shadow.setValue(text); // } // // /** // * @param size will take into account minSize, maxSize, and // * extraSize. the implementation should just call setWidth or // * setHeight as appropriate. // */ // @Override // public void setSize(int size) { // setHeight(size); // if (size == maxSize) { // box.getElement().getStyle().setProperty("overflow", "auto"); // } // } // // @Override // public void setText(String text) { // box.setText(text); // Scheduler.get().scheduleDeferred(new ScheduledCommand() { // @Override // public void execute() { // sync(); // } // }); // } // // } // // Path: src/main/java/com/tractionsoftware/gwt/user/client/ui/TextAreaWithSelection.java // public final class TextAreaWithSelection extends TextArea implements HasTextSelection {}
import com.google.gwt.core.client.EntryPoint; import com.google.gwt.user.client.ui.RootPanel; import com.tractionsoftware.gwt.user.client.ui.AutoSizingTextArea; import com.tractionsoftware.gwt.user.client.ui.TextAreaWithSelection;
/* * Copyright 2010 Traction Software, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not * use this file except in compliance with the License. You may obtain a copy of * the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the * License for the specific language governing permissions and limitations under * the License. */ package com.tractionsoftware.gwt.demo.autosizingtextarea.client; public class AutoSizingTextAreaDemo implements EntryPoint { @Override public void onModuleLoad() {
// Path: src/main/java/com/tractionsoftware/gwt/user/client/ui/AutoSizingTextArea.java // public class AutoSizingTextArea extends AutoSizingBase<TextAreaWithSelection, TextArea> implements ResizeHandler { // // protected int divExtra = 0; // protected HandlerRegistration resizeRegistration = null; // // public AutoSizingTextArea() { // this(new TextAreaWithSelection()); // } // private AutoSizingTextArea(TextAreaWithSelection box) { // super(box, new TextArea()); // } // public AutoSizingTextArea(TextAreaWithSelection box, int minSize, int maxSize) { // super(box, new TextArea()); // setMinSize(minSize); // setMaxSize(maxSize); // } // // @Override // protected void onLoad() { // Element boxElement = box.getElement(); // // int lineHeight = MiscUtils.getComputedStyleInt(boxElement, "lineHeight"); // setExtraSize(lineHeight); // // setMinFromCss("minHeight"); // setMaxFromCss("maxHeight"); // // // we also need to make sure the widths are the same. // matchStyles("width"); // // // don't let the shadow have any size // shadow.setHeight("0"); // // divExtra = 0; // divExtra += MiscUtils.getComputedStyleInt(boxElement, "paddingTop"); // divExtra += MiscUtils.getComputedStyleInt(boxElement, "paddingBottom"); // // resizeRegistration = Window.addResizeHandler(this); // // super.onLoad(); // } // // @Override // protected void onUnload() { // // fix leak reported in issue #4 // if (resizeRegistration != null) { // resizeRegistration.removeHandler(); // resizeRegistration = null; // } // // super.onUnload(); // } // // @Override // public void onResize(ResizeEvent event) { // matchStyles("width"); // adjustSize(); // } // // @Override // public void setHeight(int height) { // div.setHeight(divExtra+height+"px"); // box.setHeight(height+"px"); // } // // /** // * Returns the size of the shadow element // */ // @Override // public int getShadowSize() { // Element shadowElement = shadow.getElement(); // shadowElement.setScrollTop(10000); // return shadowElement.getScrollTop(); // } // // /** // * @param text the text that should be set on the shadow to // * determine the appropriate size of the widget // */ // @Override // public void setShadowText(String text) { // shadow.setValue(text); // } // // /** // * @param size will take into account minSize, maxSize, and // * extraSize. the implementation should just call setWidth or // * setHeight as appropriate. // */ // @Override // public void setSize(int size) { // setHeight(size); // if (size == maxSize) { // box.getElement().getStyle().setProperty("overflow", "auto"); // } // } // // @Override // public void setText(String text) { // box.setText(text); // Scheduler.get().scheduleDeferred(new ScheduledCommand() { // @Override // public void execute() { // sync(); // } // }); // } // // } // // Path: src/main/java/com/tractionsoftware/gwt/user/client/ui/TextAreaWithSelection.java // public final class TextAreaWithSelection extends TextArea implements HasTextSelection {} // Path: src-demo/com/tractionsoftware/gwt/demo/autosizingtextarea/client/AutoSizingTextAreaDemo.java import com.google.gwt.core.client.EntryPoint; import com.google.gwt.user.client.ui.RootPanel; import com.tractionsoftware.gwt.user.client.ui.AutoSizingTextArea; import com.tractionsoftware.gwt.user.client.ui.TextAreaWithSelection; /* * Copyright 2010 Traction Software, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not * use this file except in compliance with the License. You may obtain a copy of * the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the * License for the specific language governing permissions and limitations under * the License. */ package com.tractionsoftware.gwt.demo.autosizingtextarea.client; public class AutoSizingTextAreaDemo implements EntryPoint { @Override public void onModuleLoad() {
AutoSizingTextArea small = new AutoSizingTextArea(new TextAreaWithSelection(), 50, 600);
tractionsoftware/gwt-traction
src-demo/com/tractionsoftware/gwt/demo/autosizingtextarea/client/AutoSizingTextAreaDemo.java
// Path: src/main/java/com/tractionsoftware/gwt/user/client/ui/AutoSizingTextArea.java // public class AutoSizingTextArea extends AutoSizingBase<TextAreaWithSelection, TextArea> implements ResizeHandler { // // protected int divExtra = 0; // protected HandlerRegistration resizeRegistration = null; // // public AutoSizingTextArea() { // this(new TextAreaWithSelection()); // } // private AutoSizingTextArea(TextAreaWithSelection box) { // super(box, new TextArea()); // } // public AutoSizingTextArea(TextAreaWithSelection box, int minSize, int maxSize) { // super(box, new TextArea()); // setMinSize(minSize); // setMaxSize(maxSize); // } // // @Override // protected void onLoad() { // Element boxElement = box.getElement(); // // int lineHeight = MiscUtils.getComputedStyleInt(boxElement, "lineHeight"); // setExtraSize(lineHeight); // // setMinFromCss("minHeight"); // setMaxFromCss("maxHeight"); // // // we also need to make sure the widths are the same. // matchStyles("width"); // // // don't let the shadow have any size // shadow.setHeight("0"); // // divExtra = 0; // divExtra += MiscUtils.getComputedStyleInt(boxElement, "paddingTop"); // divExtra += MiscUtils.getComputedStyleInt(boxElement, "paddingBottom"); // // resizeRegistration = Window.addResizeHandler(this); // // super.onLoad(); // } // // @Override // protected void onUnload() { // // fix leak reported in issue #4 // if (resizeRegistration != null) { // resizeRegistration.removeHandler(); // resizeRegistration = null; // } // // super.onUnload(); // } // // @Override // public void onResize(ResizeEvent event) { // matchStyles("width"); // adjustSize(); // } // // @Override // public void setHeight(int height) { // div.setHeight(divExtra+height+"px"); // box.setHeight(height+"px"); // } // // /** // * Returns the size of the shadow element // */ // @Override // public int getShadowSize() { // Element shadowElement = shadow.getElement(); // shadowElement.setScrollTop(10000); // return shadowElement.getScrollTop(); // } // // /** // * @param text the text that should be set on the shadow to // * determine the appropriate size of the widget // */ // @Override // public void setShadowText(String text) { // shadow.setValue(text); // } // // /** // * @param size will take into account minSize, maxSize, and // * extraSize. the implementation should just call setWidth or // * setHeight as appropriate. // */ // @Override // public void setSize(int size) { // setHeight(size); // if (size == maxSize) { // box.getElement().getStyle().setProperty("overflow", "auto"); // } // } // // @Override // public void setText(String text) { // box.setText(text); // Scheduler.get().scheduleDeferred(new ScheduledCommand() { // @Override // public void execute() { // sync(); // } // }); // } // // } // // Path: src/main/java/com/tractionsoftware/gwt/user/client/ui/TextAreaWithSelection.java // public final class TextAreaWithSelection extends TextArea implements HasTextSelection {}
import com.google.gwt.core.client.EntryPoint; import com.google.gwt.user.client.ui.RootPanel; import com.tractionsoftware.gwt.user.client.ui.AutoSizingTextArea; import com.tractionsoftware.gwt.user.client.ui.TextAreaWithSelection;
/* * Copyright 2010 Traction Software, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not * use this file except in compliance with the License. You may obtain a copy of * the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the * License for the specific language governing permissions and limitations under * the License. */ package com.tractionsoftware.gwt.demo.autosizingtextarea.client; public class AutoSizingTextAreaDemo implements EntryPoint { @Override public void onModuleLoad() {
// Path: src/main/java/com/tractionsoftware/gwt/user/client/ui/AutoSizingTextArea.java // public class AutoSizingTextArea extends AutoSizingBase<TextAreaWithSelection, TextArea> implements ResizeHandler { // // protected int divExtra = 0; // protected HandlerRegistration resizeRegistration = null; // // public AutoSizingTextArea() { // this(new TextAreaWithSelection()); // } // private AutoSizingTextArea(TextAreaWithSelection box) { // super(box, new TextArea()); // } // public AutoSizingTextArea(TextAreaWithSelection box, int minSize, int maxSize) { // super(box, new TextArea()); // setMinSize(minSize); // setMaxSize(maxSize); // } // // @Override // protected void onLoad() { // Element boxElement = box.getElement(); // // int lineHeight = MiscUtils.getComputedStyleInt(boxElement, "lineHeight"); // setExtraSize(lineHeight); // // setMinFromCss("minHeight"); // setMaxFromCss("maxHeight"); // // // we also need to make sure the widths are the same. // matchStyles("width"); // // // don't let the shadow have any size // shadow.setHeight("0"); // // divExtra = 0; // divExtra += MiscUtils.getComputedStyleInt(boxElement, "paddingTop"); // divExtra += MiscUtils.getComputedStyleInt(boxElement, "paddingBottom"); // // resizeRegistration = Window.addResizeHandler(this); // // super.onLoad(); // } // // @Override // protected void onUnload() { // // fix leak reported in issue #4 // if (resizeRegistration != null) { // resizeRegistration.removeHandler(); // resizeRegistration = null; // } // // super.onUnload(); // } // // @Override // public void onResize(ResizeEvent event) { // matchStyles("width"); // adjustSize(); // } // // @Override // public void setHeight(int height) { // div.setHeight(divExtra+height+"px"); // box.setHeight(height+"px"); // } // // /** // * Returns the size of the shadow element // */ // @Override // public int getShadowSize() { // Element shadowElement = shadow.getElement(); // shadowElement.setScrollTop(10000); // return shadowElement.getScrollTop(); // } // // /** // * @param text the text that should be set on the shadow to // * determine the appropriate size of the widget // */ // @Override // public void setShadowText(String text) { // shadow.setValue(text); // } // // /** // * @param size will take into account minSize, maxSize, and // * extraSize. the implementation should just call setWidth or // * setHeight as appropriate. // */ // @Override // public void setSize(int size) { // setHeight(size); // if (size == maxSize) { // box.getElement().getStyle().setProperty("overflow", "auto"); // } // } // // @Override // public void setText(String text) { // box.setText(text); // Scheduler.get().scheduleDeferred(new ScheduledCommand() { // @Override // public void execute() { // sync(); // } // }); // } // // } // // Path: src/main/java/com/tractionsoftware/gwt/user/client/ui/TextAreaWithSelection.java // public final class TextAreaWithSelection extends TextArea implements HasTextSelection {} // Path: src-demo/com/tractionsoftware/gwt/demo/autosizingtextarea/client/AutoSizingTextAreaDemo.java import com.google.gwt.core.client.EntryPoint; import com.google.gwt.user.client.ui.RootPanel; import com.tractionsoftware.gwt.user.client.ui.AutoSizingTextArea; import com.tractionsoftware.gwt.user.client.ui.TextAreaWithSelection; /* * Copyright 2010 Traction Software, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not * use this file except in compliance with the License. You may obtain a copy of * the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the * License for the specific language governing permissions and limitations under * the License. */ package com.tractionsoftware.gwt.demo.autosizingtextarea.client; public class AutoSizingTextAreaDemo implements EntryPoint { @Override public void onModuleLoad() {
AutoSizingTextArea small = new AutoSizingTextArea(new TextAreaWithSelection(), 50, 600);
tractionsoftware/gwt-traction
src/main/java/com/tractionsoftware/gwt/user/client/ui/AutoSizingTextArea.java
// Path: src/main/java/com/tractionsoftware/gwt/user/client/util/MiscUtils.java // public class MiscUtils { // // /** // * Note: It seems like NativeEvent.getCharCode() would be equivalent. // */ // public static native char getCharCode(NativeEvent e) // /*-{ // return e.charCode || e.keyCode; // }-*/; // // public static final String getComputedStyle(Element e, String camelName) { // // sometimes IE throws an exception. thanks IE! // try { // return getStyleImpl().getComputedStyle(e, hyphenize(camelName), camelName); // } // catch (Exception xcp) { // return null; // } // } // // public static final int getComputedStyleInt(Element e, String camelName) { // String num = getComputedStyle(e, camelName); // return num != null ? parseInt(num) : 0; // } // // public static final int parseInt(String val) { // return parseInt(val, 10); // } // // public static final native int parseInt(String val, int radix) // /*-{ // return parseInt(val, radix) || 0; // }-*/; // // // ---------------------------------------------------------------------- // // DocumentStyleImpl.getComputedStyle from gwtquery // // private static DocumentStyleImpl styleImpl = null; // private static DocumentStyleImpl getStyleImpl() { // if (styleImpl == null) { // styleImpl = GWT.create(DocumentStyleImpl.class); // } // return styleImpl; // } // // /** // * Hyphenize style property names. for instance: fontName -> // * font-name // */ // private static native String hyphenize(String name) /*-{ // return name.replace(/([A-Z])/g, "-$1").toLowerCase(); // }-*/; // // }
import com.google.gwt.core.client.Scheduler; import com.google.gwt.core.client.Scheduler.ScheduledCommand; import com.google.gwt.dom.client.Element; import com.google.gwt.event.logical.shared.ResizeEvent; import com.google.gwt.event.logical.shared.ResizeHandler; import com.google.gwt.event.shared.HandlerRegistration; import com.google.gwt.user.client.Window; import com.google.gwt.user.client.ui.TextArea; import com.tractionsoftware.gwt.user.client.util.MiscUtils;
/* * Copyright 2010 Traction Software, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not * use this file except in compliance with the License. You may obtain a copy of * the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the * License for the specific language governing permissions and limitations under * the License. */ package com.tractionsoftware.gwt.user.client.ui; /** * This attaches to an input, listening for KeyDown/KeyUp, and * automatically resizing the text area. It does this using an * invisible textarea that matches the text of the input. */ public class AutoSizingTextArea extends AutoSizingBase<TextAreaWithSelection, TextArea> implements ResizeHandler { protected int divExtra = 0; protected HandlerRegistration resizeRegistration = null; public AutoSizingTextArea() { this(new TextAreaWithSelection()); } private AutoSizingTextArea(TextAreaWithSelection box) { super(box, new TextArea()); } public AutoSizingTextArea(TextAreaWithSelection box, int minSize, int maxSize) { super(box, new TextArea()); setMinSize(minSize); setMaxSize(maxSize); } @Override protected void onLoad() { Element boxElement = box.getElement();
// Path: src/main/java/com/tractionsoftware/gwt/user/client/util/MiscUtils.java // public class MiscUtils { // // /** // * Note: It seems like NativeEvent.getCharCode() would be equivalent. // */ // public static native char getCharCode(NativeEvent e) // /*-{ // return e.charCode || e.keyCode; // }-*/; // // public static final String getComputedStyle(Element e, String camelName) { // // sometimes IE throws an exception. thanks IE! // try { // return getStyleImpl().getComputedStyle(e, hyphenize(camelName), camelName); // } // catch (Exception xcp) { // return null; // } // } // // public static final int getComputedStyleInt(Element e, String camelName) { // String num = getComputedStyle(e, camelName); // return num != null ? parseInt(num) : 0; // } // // public static final int parseInt(String val) { // return parseInt(val, 10); // } // // public static final native int parseInt(String val, int radix) // /*-{ // return parseInt(val, radix) || 0; // }-*/; // // // ---------------------------------------------------------------------- // // DocumentStyleImpl.getComputedStyle from gwtquery // // private static DocumentStyleImpl styleImpl = null; // private static DocumentStyleImpl getStyleImpl() { // if (styleImpl == null) { // styleImpl = GWT.create(DocumentStyleImpl.class); // } // return styleImpl; // } // // /** // * Hyphenize style property names. for instance: fontName -> // * font-name // */ // private static native String hyphenize(String name) /*-{ // return name.replace(/([A-Z])/g, "-$1").toLowerCase(); // }-*/; // // } // Path: src/main/java/com/tractionsoftware/gwt/user/client/ui/AutoSizingTextArea.java import com.google.gwt.core.client.Scheduler; import com.google.gwt.core.client.Scheduler.ScheduledCommand; import com.google.gwt.dom.client.Element; import com.google.gwt.event.logical.shared.ResizeEvent; import com.google.gwt.event.logical.shared.ResizeHandler; import com.google.gwt.event.shared.HandlerRegistration; import com.google.gwt.user.client.Window; import com.google.gwt.user.client.ui.TextArea; import com.tractionsoftware.gwt.user.client.util.MiscUtils; /* * Copyright 2010 Traction Software, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not * use this file except in compliance with the License. You may obtain a copy of * the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the * License for the specific language governing permissions and limitations under * the License. */ package com.tractionsoftware.gwt.user.client.ui; /** * This attaches to an input, listening for KeyDown/KeyUp, and * automatically resizing the text area. It does this using an * invisible textarea that matches the text of the input. */ public class AutoSizingTextArea extends AutoSizingBase<TextAreaWithSelection, TextArea> implements ResizeHandler { protected int divExtra = 0; protected HandlerRegistration resizeRegistration = null; public AutoSizingTextArea() { this(new TextAreaWithSelection()); } private AutoSizingTextArea(TextAreaWithSelection box) { super(box, new TextArea()); } public AutoSizingTextArea(TextAreaWithSelection box, int minSize, int maxSize) { super(box, new TextArea()); setMinSize(minSize); setMaxSize(maxSize); } @Override protected void onLoad() { Element boxElement = box.getElement();
int lineHeight = MiscUtils.getComputedStyleInt(boxElement, "lineHeight");
tractionsoftware/gwt-traction
src-demo/com/tractionsoftware/gwt/demo/utctimebox/client/UTCTimeBoxDemo.java
// Path: src/main/java/com/tractionsoftware/gwt/user/client/ui/UTCTimeBox.java // public class UTCTimeBox extends Composite implements HasValue<Long>, HasValueChangeHandlers<Long>, HasText, HasEnabled { // // public UTCTimeBoxImpl impl; // // /** // * By default the predefined SHORT time format will be used. // */ // public UTCTimeBox() { // this(DateTimeFormat.getFormat(PredefinedFormat.TIME_SHORT)); // } // // /** // * Allows a UTCTimeBox to be created with a specified format. // */ // public UTCTimeBox(DateTimeFormat timeFormat) { // // used deferred binding for the implementation // impl = GWT.create(UTCTimeBoxImpl.class); // impl.setTimeFormat(timeFormat); // initWidget(impl.asWidget()); // } // // @Override // public HandlerRegistration addValueChangeHandler(ValueChangeHandler<Long> handler) { // return impl.addValueChangeHandler(handler); // } // // @Override // public Long getValue() { // return impl.getValue(); // } // // @Override // public void setValue(Long value) { // impl.setValue(value); // } // // @Override // public void setValue(Long value, boolean fireEvents) { // impl.setValue(value, fireEvents); // } // // @Override // public String getText() { // return impl.getText(); // } // // @Override // public void setText(String text) { // impl.setText(text); // } // // @Override // public boolean isEnabled() { // return DomUtils.isEnabled(getElement()); // } // // @Override // public void setEnabled(boolean enabled) { // DomUtils.setEnabled(getElement(), enabled); // } // // /** // * The HTML5 implementation will ignore this. // */ // public void setVisibleLength(int length) { // impl.setVisibleLength(length); // } // // public void setTabIndex(int tabIndex) { // impl.setTabIndex(tabIndex); // } // // /** // * If this is a text based control, it will validate the value // * that has been typed. // */ // public void validate() { // impl.validate(); // } // // // ---------------------------------------------------------------------- // // utils // // public static final Long getValueForNextHour() { // Date date = new Date(); // long value = UTCDateBox.date2utc(date); // // // remove anything after an hour and add an hour // long hour = 60 * 60 * 1000; // value = value % UTCDateBox.DAY_IN_MS; // return value - (value % hour) + hour; // } // // }
import com.google.gwt.core.client.EntryPoint; import com.google.gwt.event.logical.shared.ValueChangeEvent; import com.google.gwt.event.logical.shared.ValueChangeHandler; import com.google.gwt.i18n.client.DateTimeFormat; import com.google.gwt.user.client.ui.CheckBox; import com.google.gwt.user.client.ui.ListBox; import com.google.gwt.user.client.ui.RootPanel; import com.tractionsoftware.gwt.user.client.ui.UTCTimeBox;
/* * Copyright 2010 Traction Software, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not * use this file except in compliance with the License. You may obtain a copy of * the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the * License for the specific language governing permissions and limitations under * the License. */ package com.tractionsoftware.gwt.demo.utctimebox.client; public class UTCTimeBoxDemo implements EntryPoint { private ListBox eventListBox;
// Path: src/main/java/com/tractionsoftware/gwt/user/client/ui/UTCTimeBox.java // public class UTCTimeBox extends Composite implements HasValue<Long>, HasValueChangeHandlers<Long>, HasText, HasEnabled { // // public UTCTimeBoxImpl impl; // // /** // * By default the predefined SHORT time format will be used. // */ // public UTCTimeBox() { // this(DateTimeFormat.getFormat(PredefinedFormat.TIME_SHORT)); // } // // /** // * Allows a UTCTimeBox to be created with a specified format. // */ // public UTCTimeBox(DateTimeFormat timeFormat) { // // used deferred binding for the implementation // impl = GWT.create(UTCTimeBoxImpl.class); // impl.setTimeFormat(timeFormat); // initWidget(impl.asWidget()); // } // // @Override // public HandlerRegistration addValueChangeHandler(ValueChangeHandler<Long> handler) { // return impl.addValueChangeHandler(handler); // } // // @Override // public Long getValue() { // return impl.getValue(); // } // // @Override // public void setValue(Long value) { // impl.setValue(value); // } // // @Override // public void setValue(Long value, boolean fireEvents) { // impl.setValue(value, fireEvents); // } // // @Override // public String getText() { // return impl.getText(); // } // // @Override // public void setText(String text) { // impl.setText(text); // } // // @Override // public boolean isEnabled() { // return DomUtils.isEnabled(getElement()); // } // // @Override // public void setEnabled(boolean enabled) { // DomUtils.setEnabled(getElement(), enabled); // } // // /** // * The HTML5 implementation will ignore this. // */ // public void setVisibleLength(int length) { // impl.setVisibleLength(length); // } // // public void setTabIndex(int tabIndex) { // impl.setTabIndex(tabIndex); // } // // /** // * If this is a text based control, it will validate the value // * that has been typed. // */ // public void validate() { // impl.validate(); // } // // // ---------------------------------------------------------------------- // // utils // // public static final Long getValueForNextHour() { // Date date = new Date(); // long value = UTCDateBox.date2utc(date); // // // remove anything after an hour and add an hour // long hour = 60 * 60 * 1000; // value = value % UTCDateBox.DAY_IN_MS; // return value - (value % hour) + hour; // } // // } // Path: src-demo/com/tractionsoftware/gwt/demo/utctimebox/client/UTCTimeBoxDemo.java import com.google.gwt.core.client.EntryPoint; import com.google.gwt.event.logical.shared.ValueChangeEvent; import com.google.gwt.event.logical.shared.ValueChangeHandler; import com.google.gwt.i18n.client.DateTimeFormat; import com.google.gwt.user.client.ui.CheckBox; import com.google.gwt.user.client.ui.ListBox; import com.google.gwt.user.client.ui.RootPanel; import com.tractionsoftware.gwt.user.client.ui.UTCTimeBox; /* * Copyright 2010 Traction Software, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not * use this file except in compliance with the License. You may obtain a copy of * the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the * License for the specific language governing permissions and limitations under * the License. */ package com.tractionsoftware.gwt.demo.utctimebox.client; public class UTCTimeBoxDemo implements EntryPoint { private ListBox eventListBox;
private UTCTimeBox timebox;
tractionsoftware/gwt-traction
src/main/java/com/tractionsoftware/gwt/user/client/ui/UTCTimeBox.java
// Path: src/main/java/com/tractionsoftware/gwt/user/client/ui/impl/UTCTimeBoxImpl.java // public interface UTCTimeBoxImpl extends IsWidget, HasValue<Long>, HasValueChangeHandlers<Long>, HasText { // // /** // * Sets the DateTimeFormat for this UTCTimeBox. The HTML5 // * implementation will ignore this. // */ // public void setTimeFormat(DateTimeFormat timeFormat); // // /** // * Sets the visible length of the time input. The HTML5 // * implementation will ignore this. // */ // public void setVisibleLength(int length); // // /** // * Validates the value that has been typed into the text input. // * The HTML5 implementation will do nothing. // */ // public void validate(); // // /** // * Sets the tab index for the control. // */ // public void setTabIndex(int tabIndex); // // } // // Path: src/main/java/com/tractionsoftware/gwt/user/client/util/DomUtils.java // public class DomUtils extends UIObject { // // /** // * This object is never created. // */ // private DomUtils() {} // // /** // * It's enough to just set the disabled attribute on the // * element, but we want to also add a "disabled" class so that we can // * style it. // * // * At some point we'll just be able to use .button:disabled, // * but that doesn't work in IE8- // */ // public static void setEnabled(Element element, boolean enabled) { // element.setPropertyBoolean("disabled", !enabled); // setStyleName(element, "disabled", !enabled); // } // // /** // * Returns true if the element has the disabled attribute. // */ // public static boolean isEnabled(Element element) { // return element.getPropertyBoolean("disabled"); // } // // }
import java.util.Date; import com.google.gwt.core.client.GWT; import com.google.gwt.event.logical.shared.HasValueChangeHandlers; import com.google.gwt.event.logical.shared.ValueChangeHandler; import com.google.gwt.event.shared.HandlerRegistration; import com.google.gwt.i18n.client.DateTimeFormat; import com.google.gwt.i18n.client.DateTimeFormat.PredefinedFormat; import com.google.gwt.user.client.ui.Composite; import com.google.gwt.user.client.ui.HasEnabled; import com.google.gwt.user.client.ui.HasText; import com.google.gwt.user.client.ui.HasValue; import com.tractionsoftware.gwt.user.client.ui.impl.UTCTimeBoxImpl; import com.tractionsoftware.gwt.user.client.util.DomUtils;
return impl.addValueChangeHandler(handler); } @Override public Long getValue() { return impl.getValue(); } @Override public void setValue(Long value) { impl.setValue(value); } @Override public void setValue(Long value, boolean fireEvents) { impl.setValue(value, fireEvents); } @Override public String getText() { return impl.getText(); } @Override public void setText(String text) { impl.setText(text); } @Override public boolean isEnabled() {
// Path: src/main/java/com/tractionsoftware/gwt/user/client/ui/impl/UTCTimeBoxImpl.java // public interface UTCTimeBoxImpl extends IsWidget, HasValue<Long>, HasValueChangeHandlers<Long>, HasText { // // /** // * Sets the DateTimeFormat for this UTCTimeBox. The HTML5 // * implementation will ignore this. // */ // public void setTimeFormat(DateTimeFormat timeFormat); // // /** // * Sets the visible length of the time input. The HTML5 // * implementation will ignore this. // */ // public void setVisibleLength(int length); // // /** // * Validates the value that has been typed into the text input. // * The HTML5 implementation will do nothing. // */ // public void validate(); // // /** // * Sets the tab index for the control. // */ // public void setTabIndex(int tabIndex); // // } // // Path: src/main/java/com/tractionsoftware/gwt/user/client/util/DomUtils.java // public class DomUtils extends UIObject { // // /** // * This object is never created. // */ // private DomUtils() {} // // /** // * It's enough to just set the disabled attribute on the // * element, but we want to also add a "disabled" class so that we can // * style it. // * // * At some point we'll just be able to use .button:disabled, // * but that doesn't work in IE8- // */ // public static void setEnabled(Element element, boolean enabled) { // element.setPropertyBoolean("disabled", !enabled); // setStyleName(element, "disabled", !enabled); // } // // /** // * Returns true if the element has the disabled attribute. // */ // public static boolean isEnabled(Element element) { // return element.getPropertyBoolean("disabled"); // } // // } // Path: src/main/java/com/tractionsoftware/gwt/user/client/ui/UTCTimeBox.java import java.util.Date; import com.google.gwt.core.client.GWT; import com.google.gwt.event.logical.shared.HasValueChangeHandlers; import com.google.gwt.event.logical.shared.ValueChangeHandler; import com.google.gwt.event.shared.HandlerRegistration; import com.google.gwt.i18n.client.DateTimeFormat; import com.google.gwt.i18n.client.DateTimeFormat.PredefinedFormat; import com.google.gwt.user.client.ui.Composite; import com.google.gwt.user.client.ui.HasEnabled; import com.google.gwt.user.client.ui.HasText; import com.google.gwt.user.client.ui.HasValue; import com.tractionsoftware.gwt.user.client.ui.impl.UTCTimeBoxImpl; import com.tractionsoftware.gwt.user.client.util.DomUtils; return impl.addValueChangeHandler(handler); } @Override public Long getValue() { return impl.getValue(); } @Override public void setValue(Long value) { impl.setValue(value); } @Override public void setValue(Long value, boolean fireEvents) { impl.setValue(value, fireEvents); } @Override public String getText() { return impl.getText(); } @Override public void setText(String text) { impl.setText(text); } @Override public boolean isEnabled() {
return DomUtils.isEnabled(getElement());
tractionsoftware/gwt-traction
src-demo/com/tractionsoftware/gwt/demo/viewport/client/ViewportDemo.java
// Path: src/main/java/com/tractionsoftware/gwt/user/client/Viewport.java // public class Viewport implements HasFocusHandlers, HasBlurHandlers { // // static final ViewportImpl impl = GWT.create(ViewportImpl.class); // // // ---------------------------------------------------------------------- // // singleton // // private static Viewport instance; // // /** // * Provides access to the singleton instance. // * // * @return returns the instance // */ // public static Viewport get() { // if (instance == null) { // instance = new Viewport(); // impl.addEventListeners(); // } // return instance; // } // // /** // * Determines whether or not the Viewport has focus. // * // * @return returns true if the Viewport has focus // */ // public static boolean hasFocus() { // return get().hasFocus; // } // // // ---------------------------------------------------------------------- // // // keep track of focus so that hasFocus() can work // private boolean hasFocus = true; // // // only allow get() to construct this // private Viewport() {} // // /** // * Adds a {@link FocusEvent} handler. // * // * @param handler the handler // * @return returns the handler registration // */ // @Override // public HandlerRegistration addFocusHandler(FocusHandler handler) { // return ensureHandlers().addHandler(FocusEvent.getType(), handler); // } // // /** // * Adds a {@link BlurEvent} handler. // * // * @param handler the handler // * @return returns the handler registration // */ // @Override // public HandlerRegistration addBlurHandler(BlurHandler handler) { // return ensureHandlers().addHandler(BlurEvent.getType(), handler); // } // // // ---------------------------------------------------------------------- // // event callbacks from ViewportImpl // // static void dispatchFocusEvent(Event event) { // dispatchEvent(event, true); // } // // static void dispatchBlurEvent(Event event) { // dispatchEvent(event, false); // } // // static void dispatchEvent(Event event, boolean hasFocus) { // if (instance != null) { // instance.hasFocus = hasFocus; // DomEvent.fireNativeEvent(event, instance); // } // } // // // ---------------------------------------------------------------------- // // borrowed from GWT // // private HandlerManager handlerManager; // // @Override // public void fireEvent(GwtEvent<?> event) { // if (handlerManager != null) { // handlerManager.fireEvent(event); // } // } // // /** // * Ensures the existence of the handler manager. // * // * @return the handler manager // * */ // HandlerManager ensureHandlers() { // return handlerManager == null ? handlerManager = new HandlerManager(this) // : handlerManager; // } // // HandlerManager getHandlerManager() { // return handlerManager; // } // // }
import com.google.gwt.core.client.EntryPoint; import com.google.gwt.user.client.Window; import com.google.gwt.user.client.ui.Label; import com.google.gwt.user.client.ui.ListBox; import com.google.gwt.user.client.ui.RootPanel; import com.google.gwt.event.dom.client.FocusEvent; import com.google.gwt.event.dom.client.FocusHandler; import com.google.gwt.event.dom.client.BlurEvent; import com.google.gwt.event.dom.client.BlurHandler; import com.tractionsoftware.gwt.user.client.Viewport; import java.util.Date;
/* * Copyright 2010 Traction Software, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not * use this file except in compliance with the License. You may obtain a copy of * the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the * License for the specific language governing permissions and limitations under * the License. */ package com.tractionsoftware.gwt.demo.viewport.client; public class ViewportDemo implements EntryPoint { private Label focusLabel; private ListBox eventListBox; @Override public void onModuleLoad() { focusLabel = new Label(); RootPanel.get("hasfocus").add(focusLabel); eventListBox = new ListBox(true); eventListBox.setVisibleItemCount(20); RootPanel.get("eventlog").add(eventListBox); update();
// Path: src/main/java/com/tractionsoftware/gwt/user/client/Viewport.java // public class Viewport implements HasFocusHandlers, HasBlurHandlers { // // static final ViewportImpl impl = GWT.create(ViewportImpl.class); // // // ---------------------------------------------------------------------- // // singleton // // private static Viewport instance; // // /** // * Provides access to the singleton instance. // * // * @return returns the instance // */ // public static Viewport get() { // if (instance == null) { // instance = new Viewport(); // impl.addEventListeners(); // } // return instance; // } // // /** // * Determines whether or not the Viewport has focus. // * // * @return returns true if the Viewport has focus // */ // public static boolean hasFocus() { // return get().hasFocus; // } // // // ---------------------------------------------------------------------- // // // keep track of focus so that hasFocus() can work // private boolean hasFocus = true; // // // only allow get() to construct this // private Viewport() {} // // /** // * Adds a {@link FocusEvent} handler. // * // * @param handler the handler // * @return returns the handler registration // */ // @Override // public HandlerRegistration addFocusHandler(FocusHandler handler) { // return ensureHandlers().addHandler(FocusEvent.getType(), handler); // } // // /** // * Adds a {@link BlurEvent} handler. // * // * @param handler the handler // * @return returns the handler registration // */ // @Override // public HandlerRegistration addBlurHandler(BlurHandler handler) { // return ensureHandlers().addHandler(BlurEvent.getType(), handler); // } // // // ---------------------------------------------------------------------- // // event callbacks from ViewportImpl // // static void dispatchFocusEvent(Event event) { // dispatchEvent(event, true); // } // // static void dispatchBlurEvent(Event event) { // dispatchEvent(event, false); // } // // static void dispatchEvent(Event event, boolean hasFocus) { // if (instance != null) { // instance.hasFocus = hasFocus; // DomEvent.fireNativeEvent(event, instance); // } // } // // // ---------------------------------------------------------------------- // // borrowed from GWT // // private HandlerManager handlerManager; // // @Override // public void fireEvent(GwtEvent<?> event) { // if (handlerManager != null) { // handlerManager.fireEvent(event); // } // } // // /** // * Ensures the existence of the handler manager. // * // * @return the handler manager // * */ // HandlerManager ensureHandlers() { // return handlerManager == null ? handlerManager = new HandlerManager(this) // : handlerManager; // } // // HandlerManager getHandlerManager() { // return handlerManager; // } // // } // Path: src-demo/com/tractionsoftware/gwt/demo/viewport/client/ViewportDemo.java import com.google.gwt.core.client.EntryPoint; import com.google.gwt.user.client.Window; import com.google.gwt.user.client.ui.Label; import com.google.gwt.user.client.ui.ListBox; import com.google.gwt.user.client.ui.RootPanel; import com.google.gwt.event.dom.client.FocusEvent; import com.google.gwt.event.dom.client.FocusHandler; import com.google.gwt.event.dom.client.BlurEvent; import com.google.gwt.event.dom.client.BlurHandler; import com.tractionsoftware.gwt.user.client.Viewport; import java.util.Date; /* * Copyright 2010 Traction Software, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not * use this file except in compliance with the License. You may obtain a copy of * the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the * License for the specific language governing permissions and limitations under * the License. */ package com.tractionsoftware.gwt.demo.viewport.client; public class ViewportDemo implements EntryPoint { private Label focusLabel; private ListBox eventListBox; @Override public void onModuleLoad() { focusLabel = new Label(); RootPanel.get("hasfocus").add(focusLabel); eventListBox = new ListBox(true); eventListBox.setVisibleItemCount(20); RootPanel.get("eventlog").add(eventListBox); update();
Viewport.get().addFocusHandler(new FocusHandler() {
tractionsoftware/gwt-traction
src/main/java/com/tractionsoftware/gwt/user/client/ui/AutoSizingBase.java
// Path: src/main/java/com/tractionsoftware/gwt/user/client/util/MiscUtils.java // public class MiscUtils { // // /** // * Note: It seems like NativeEvent.getCharCode() would be equivalent. // */ // public static native char getCharCode(NativeEvent e) // /*-{ // return e.charCode || e.keyCode; // }-*/; // // public static final String getComputedStyle(Element e, String camelName) { // // sometimes IE throws an exception. thanks IE! // try { // return getStyleImpl().getComputedStyle(e, hyphenize(camelName), camelName); // } // catch (Exception xcp) { // return null; // } // } // // public static final int getComputedStyleInt(Element e, String camelName) { // String num = getComputedStyle(e, camelName); // return num != null ? parseInt(num) : 0; // } // // public static final int parseInt(String val) { // return parseInt(val, 10); // } // // public static final native int parseInt(String val, int radix) // /*-{ // return parseInt(val, radix) || 0; // }-*/; // // // ---------------------------------------------------------------------- // // DocumentStyleImpl.getComputedStyle from gwtquery // // private static DocumentStyleImpl styleImpl = null; // private static DocumentStyleImpl getStyleImpl() { // if (styleImpl == null) { // styleImpl = GWT.create(DocumentStyleImpl.class); // } // return styleImpl; // } // // /** // * Hyphenize style property names. for instance: fontName -> // * font-name // */ // private static native String hyphenize(String name) /*-{ // return name.replace(/([A-Z])/g, "-$1").toLowerCase(); // }-*/; // // }
import com.google.gwt.core.client.GWT; import com.google.gwt.core.client.Scheduler; import com.google.gwt.core.client.Scheduler.ScheduledCommand; import com.google.gwt.event.dom.client.HasKeyDownHandlers; import com.google.gwt.event.dom.client.HasKeyUpHandlers; import com.google.gwt.event.dom.client.KeyCodeEvent; import com.google.gwt.event.dom.client.KeyCodes; import com.google.gwt.event.dom.client.KeyDownEvent; import com.google.gwt.event.dom.client.KeyDownHandler; import com.google.gwt.event.dom.client.KeyUpEvent; import com.google.gwt.event.dom.client.KeyUpHandler; import com.google.gwt.event.logical.shared.HasValueChangeHandlers; import com.google.gwt.event.logical.shared.ValueChangeEvent; import com.google.gwt.event.logical.shared.ValueChangeHandler; import com.google.gwt.user.client.ui.Composite; import com.google.gwt.user.client.ui.FlowPanel; import com.google.gwt.user.client.ui.Focusable; import com.google.gwt.user.client.ui.HasText; import com.google.gwt.user.client.ui.HasValue; import com.google.gwt.user.client.ui.Widget; import com.tractionsoftware.gwt.user.client.util.MiscUtils;
} public final void setExtraSize(int extraSize) { this.extraSize = extraSize; } // ---------------------------------------------------------------------- // check for max-height and min-height properties and use them // instead of anything configured. if you need to control the // min/max in code, don't set those css properties. // // also note that we remove the properties from the textarea AND // the shadow. this is important because otherwise they interfere // with the auto-sizing // public final void setMinFromCss(String property) { int min = getAndResetValueFromCss(property, "0"); if (min > 0) { setMinSize(min); } } public final void setMaxFromCss(String property) { int max = getAndResetValueFromCss(property, "none"); if (max > 0) { setMaxSize(max); } } public final int getAndResetValueFromCss(String property, String reset) {
// Path: src/main/java/com/tractionsoftware/gwt/user/client/util/MiscUtils.java // public class MiscUtils { // // /** // * Note: It seems like NativeEvent.getCharCode() would be equivalent. // */ // public static native char getCharCode(NativeEvent e) // /*-{ // return e.charCode || e.keyCode; // }-*/; // // public static final String getComputedStyle(Element e, String camelName) { // // sometimes IE throws an exception. thanks IE! // try { // return getStyleImpl().getComputedStyle(e, hyphenize(camelName), camelName); // } // catch (Exception xcp) { // return null; // } // } // // public static final int getComputedStyleInt(Element e, String camelName) { // String num = getComputedStyle(e, camelName); // return num != null ? parseInt(num) : 0; // } // // public static final int parseInt(String val) { // return parseInt(val, 10); // } // // public static final native int parseInt(String val, int radix) // /*-{ // return parseInt(val, radix) || 0; // }-*/; // // // ---------------------------------------------------------------------- // // DocumentStyleImpl.getComputedStyle from gwtquery // // private static DocumentStyleImpl styleImpl = null; // private static DocumentStyleImpl getStyleImpl() { // if (styleImpl == null) { // styleImpl = GWT.create(DocumentStyleImpl.class); // } // return styleImpl; // } // // /** // * Hyphenize style property names. for instance: fontName -> // * font-name // */ // private static native String hyphenize(String name) /*-{ // return name.replace(/([A-Z])/g, "-$1").toLowerCase(); // }-*/; // // } // Path: src/main/java/com/tractionsoftware/gwt/user/client/ui/AutoSizingBase.java import com.google.gwt.core.client.GWT; import com.google.gwt.core.client.Scheduler; import com.google.gwt.core.client.Scheduler.ScheduledCommand; import com.google.gwt.event.dom.client.HasKeyDownHandlers; import com.google.gwt.event.dom.client.HasKeyUpHandlers; import com.google.gwt.event.dom.client.KeyCodeEvent; import com.google.gwt.event.dom.client.KeyCodes; import com.google.gwt.event.dom.client.KeyDownEvent; import com.google.gwt.event.dom.client.KeyDownHandler; import com.google.gwt.event.dom.client.KeyUpEvent; import com.google.gwt.event.dom.client.KeyUpHandler; import com.google.gwt.event.logical.shared.HasValueChangeHandlers; import com.google.gwt.event.logical.shared.ValueChangeEvent; import com.google.gwt.event.logical.shared.ValueChangeHandler; import com.google.gwt.user.client.ui.Composite; import com.google.gwt.user.client.ui.FlowPanel; import com.google.gwt.user.client.ui.Focusable; import com.google.gwt.user.client.ui.HasText; import com.google.gwt.user.client.ui.HasValue; import com.google.gwt.user.client.ui.Widget; import com.tractionsoftware.gwt.user.client.util.MiscUtils; } public final void setExtraSize(int extraSize) { this.extraSize = extraSize; } // ---------------------------------------------------------------------- // check for max-height and min-height properties and use them // instead of anything configured. if you need to control the // min/max in code, don't set those css properties. // // also note that we remove the properties from the textarea AND // the shadow. this is important because otherwise they interfere // with the auto-sizing // public final void setMinFromCss(String property) { int min = getAndResetValueFromCss(property, "0"); if (min > 0) { setMinSize(min); } } public final void setMaxFromCss(String property) { int max = getAndResetValueFromCss(property, "none"); if (max > 0) { setMaxSize(max); } } public final int getAndResetValueFromCss(String property, String reset) {
int value = MiscUtils.getComputedStyleInt(box.getElement(), property);
tractionsoftware/gwt-traction
src-demo/com/tractionsoftware/gwt/demo/opacity/client/OpacityDemo.java
// Path: src/main/java/com/tractionsoftware/gwt/user/client/animation/OpacityAnimation.java // public class OpacityAnimation extends TractionAnimation { // // static final SetOpacityImpl impl = GWT.create(SetOpacityImpl.class); // // private Element[] elm; // private float fromOpacity; // // // note that we don't store toOpacity. instead we store the offset // // that we'll use to compute the animation. // private float addOpacity; // // /** // * Creates an OpacityAnimation // * // * @param elm The Elements to modify // * @param fromOpacity The opacity value at the start of the animation (0-1) // * @param toOpacity The opacity value at the end of the animation (0-1) // */ // public OpacityAnimation(Element[] elm, float fromOpacity, float toOpacity) { // this.elm = elm; // this.fromOpacity = fromOpacity; // this.addOpacity = toOpacity - fromOpacity; // } // // @Override // protected void onUpdate(double progress) { // float newOpacity = fromOpacity + (float) (addOpacity * progress); // for (Element e : elm) { // impl.setOpacity(e, newOpacity); // } // } // // /** // * Sets the animation to the starting point, canceling any // * animation in progress. // */ // @Override // public void setPositionAtStart() { // setPosition(0.0); // } // // /** // * Sets the animation to the end point, canceling any animation in // * progress. // */ // @Override // public void setPositionAtEnd() { // setPosition(1.0); // } // // /** // * Sets the animation to a particular point, cancelling an // * animation in progress. Note that the animation will always // * reset on run. // */ // @Override // public void setPosition(double progress) { // cancel(); // onUpdate(interpolate(progress)); // } // // }
import com.google.gwt.core.client.EntryPoint; import com.google.gwt.dom.client.Document; import com.google.gwt.dom.client.Element; import com.google.gwt.event.dom.client.ClickEvent; import com.google.gwt.event.dom.client.ClickHandler; import com.google.gwt.user.client.ui.Button; import com.google.gwt.user.client.ui.Label; import com.google.gwt.user.client.ui.Panel; import com.google.gwt.user.client.ui.RootPanel; import com.google.gwt.user.client.ui.TextBox; import com.tractionsoftware.gwt.user.client.animation.OpacityAnimation;
/* * Copyright 2010 Traction Software, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not * use this file except in compliance with the License. You may obtain a copy of * the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the * License for the specific language governing permissions and limitations under * the License. */ package com.tractionsoftware.gwt.demo.opacity.client; public class OpacityDemo implements EntryPoint { private TextBox startOpacity; private TextBox endOpacity; private TextBox duration; @Override public void onModuleLoad() { Panel controls = RootPanel.get("controls"); startOpacity = createTextBox("1.0"); endOpacity = createTextBox("0.1"); duration = createTextBox("5000"); addTextBox(controls, "Start Opacity", startOpacity); addTextBox(controls, "End Opacity", endOpacity); addTextBox(controls, "Duration", duration); Button start = new Button("Start"); start.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) {
// Path: src/main/java/com/tractionsoftware/gwt/user/client/animation/OpacityAnimation.java // public class OpacityAnimation extends TractionAnimation { // // static final SetOpacityImpl impl = GWT.create(SetOpacityImpl.class); // // private Element[] elm; // private float fromOpacity; // // // note that we don't store toOpacity. instead we store the offset // // that we'll use to compute the animation. // private float addOpacity; // // /** // * Creates an OpacityAnimation // * // * @param elm The Elements to modify // * @param fromOpacity The opacity value at the start of the animation (0-1) // * @param toOpacity The opacity value at the end of the animation (0-1) // */ // public OpacityAnimation(Element[] elm, float fromOpacity, float toOpacity) { // this.elm = elm; // this.fromOpacity = fromOpacity; // this.addOpacity = toOpacity - fromOpacity; // } // // @Override // protected void onUpdate(double progress) { // float newOpacity = fromOpacity + (float) (addOpacity * progress); // for (Element e : elm) { // impl.setOpacity(e, newOpacity); // } // } // // /** // * Sets the animation to the starting point, canceling any // * animation in progress. // */ // @Override // public void setPositionAtStart() { // setPosition(0.0); // } // // /** // * Sets the animation to the end point, canceling any animation in // * progress. // */ // @Override // public void setPositionAtEnd() { // setPosition(1.0); // } // // /** // * Sets the animation to a particular point, cancelling an // * animation in progress. Note that the animation will always // * reset on run. // */ // @Override // public void setPosition(double progress) { // cancel(); // onUpdate(interpolate(progress)); // } // // } // Path: src-demo/com/tractionsoftware/gwt/demo/opacity/client/OpacityDemo.java import com.google.gwt.core.client.EntryPoint; import com.google.gwt.dom.client.Document; import com.google.gwt.dom.client.Element; import com.google.gwt.event.dom.client.ClickEvent; import com.google.gwt.event.dom.client.ClickHandler; import com.google.gwt.user.client.ui.Button; import com.google.gwt.user.client.ui.Label; import com.google.gwt.user.client.ui.Panel; import com.google.gwt.user.client.ui.RootPanel; import com.google.gwt.user.client.ui.TextBox; import com.tractionsoftware.gwt.user.client.animation.OpacityAnimation; /* * Copyright 2010 Traction Software, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not * use this file except in compliance with the License. You may obtain a copy of * the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the * License for the specific language governing permissions and limitations under * the License. */ package com.tractionsoftware.gwt.demo.opacity.client; public class OpacityDemo implements EntryPoint { private TextBox startOpacity; private TextBox endOpacity; private TextBox duration; @Override public void onModuleLoad() { Panel controls = RootPanel.get("controls"); startOpacity = createTextBox("1.0"); endOpacity = createTextBox("0.1"); duration = createTextBox("5000"); addTextBox(controls, "Start Opacity", startOpacity); addTextBox(controls, "End Opacity", endOpacity); addTextBox(controls, "Duration", duration); Button start = new Button("Start"); start.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) {
OpacityAnimation animation = new OpacityAnimation(new Element[] {
tractionsoftware/gwt-traction
src/main/java/com/tractionsoftware/gwt/user/client/ui/impl/UTCTimeBoxImplHtml5.java
// Path: src/main/java/com/tractionsoftware/gwt/user/client/ui/InputWidget.java // public class InputWidget extends FocusWidget implements HasValue<String> { // // private String lastValue = null; // // public InputWidget(String type) { // super(DOM.createElement("input")); // getElement().setAttribute("type", type); // // // fire a change event on change or blur // addDomHandler(new ChangeHandler() { // @Override // public void onChange(ChangeEvent event) { // fireValueChangeHandler(getValue()); // } // }, ChangeEvent.getType()); // // addBlurHandler(new BlurHandler() { // @Override // public void onBlur(BlurEvent event) { // fireValueChangeHandler(getValue()); // } // }); // } // // @Override // public HandlerRegistration addValueChangeHandler(ValueChangeHandler<String> handler) { // return addHandler(handler, ValueChangeEvent.getType()); // } // // @Override // public String getValue() { // return getElement().getPropertyString("value"); // } // // @Override // public void setValue(String value) { // setValue(value, false); // } // // @Override // public void setValue(String value, boolean fireEvents) { // if (value == null) value = ""; // getElement().setPropertyString("value", value); // if (fireEvents) { // fireValueChangeHandler(value); // } // else { // // we still want to keep track of changes to the value // lastValue = value; // } // } // // private void fireValueChangeHandler(String value) { // ValueChangeEvent.fireIfNotEqual(this, lastValue, value); // lastValue = value; // } // // }
import com.google.gwt.event.logical.shared.ValueChangeEvent; import com.google.gwt.event.logical.shared.ValueChangeHandler; import com.google.gwt.event.shared.HandlerRegistration; import com.google.gwt.i18n.client.DateTimeFormat; import com.tractionsoftware.gwt.user.client.ui.InputWidget;
/* * Copyright 2010 Traction Software, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not * use this file except in compliance with the License. You may obtain a copy of * the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the * License for the specific language governing permissions and limitations under * the License. */ package com.tractionsoftware.gwt.user.client.ui.impl; /** * Uses an HTML5 input type=time control to implement the UTCTimeBox * * @author andy */ public class UTCTimeBoxImplHtml5 extends UTCTimeBoxImplShared { private static final DateTimeFormat timeInputFormat = DateTimeFormat.getFormat("HH:mm");
// Path: src/main/java/com/tractionsoftware/gwt/user/client/ui/InputWidget.java // public class InputWidget extends FocusWidget implements HasValue<String> { // // private String lastValue = null; // // public InputWidget(String type) { // super(DOM.createElement("input")); // getElement().setAttribute("type", type); // // // fire a change event on change or blur // addDomHandler(new ChangeHandler() { // @Override // public void onChange(ChangeEvent event) { // fireValueChangeHandler(getValue()); // } // }, ChangeEvent.getType()); // // addBlurHandler(new BlurHandler() { // @Override // public void onBlur(BlurEvent event) { // fireValueChangeHandler(getValue()); // } // }); // } // // @Override // public HandlerRegistration addValueChangeHandler(ValueChangeHandler<String> handler) { // return addHandler(handler, ValueChangeEvent.getType()); // } // // @Override // public String getValue() { // return getElement().getPropertyString("value"); // } // // @Override // public void setValue(String value) { // setValue(value, false); // } // // @Override // public void setValue(String value, boolean fireEvents) { // if (value == null) value = ""; // getElement().setPropertyString("value", value); // if (fireEvents) { // fireValueChangeHandler(value); // } // else { // // we still want to keep track of changes to the value // lastValue = value; // } // } // // private void fireValueChangeHandler(String value) { // ValueChangeEvent.fireIfNotEqual(this, lastValue, value); // lastValue = value; // } // // } // Path: src/main/java/com/tractionsoftware/gwt/user/client/ui/impl/UTCTimeBoxImplHtml5.java import com.google.gwt.event.logical.shared.ValueChangeEvent; import com.google.gwt.event.logical.shared.ValueChangeHandler; import com.google.gwt.event.shared.HandlerRegistration; import com.google.gwt.i18n.client.DateTimeFormat; import com.tractionsoftware.gwt.user.client.ui.InputWidget; /* * Copyright 2010 Traction Software, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not * use this file except in compliance with the License. You may obtain a copy of * the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the * License for the specific language governing permissions and limitations under * the License. */ package com.tractionsoftware.gwt.user.client.ui.impl; /** * Uses an HTML5 input type=time control to implement the UTCTimeBox * * @author andy */ public class UTCTimeBoxImplHtml5 extends UTCTimeBoxImplShared { private static final DateTimeFormat timeInputFormat = DateTimeFormat.getFormat("HH:mm");
private InputWidget widget;
tractionsoftware/gwt-traction
src/main/java/com/tractionsoftware/gwt/user/client/ui/AutoSizingTextBox.java
// Path: src/main/java/com/tractionsoftware/gwt/user/client/util/Geometry.java // public class Geometry { // // public static final void setInvisibleToMeasure(Element e) { // Style s = e.getStyle(); // s.setProperty("visibility", "hidden"); // s.setProperty("display", "block"); // } // // public static final void unsetInvisibleToMeasure(Element e) { // Style s = e.getStyle(); // s.setProperty("display", "none"); // s.setProperty("visibility", ""); // } // // public static final Rect getBoundsOfHidden(Element e) { // setInvisibleToMeasure(e); // Rect ret = getBounds(e); // unsetInvisibleToMeasure(e); // return ret; // } // // public static final Rect getBounds(Element e) { // return new Rect(getX(e), getY(e), getW(e), getH(e)); // } // // public static final int getX(Element e) { // return e.getAbsoluteLeft(); // } // // public static final int getY(Element e) { // return e.getAbsoluteTop(); // } // // /** // * Updated to factor in border and padding // */ // public static final int getW(Element e) { // int ret = e.getOffsetWidth(); // ret -= MiscUtils.getComputedStyleInt(e, "paddingLeft"); // ret -= MiscUtils.getComputedStyleInt(e, "paddingRight"); // ret -= MiscUtils.getComputedStyleInt(e, "borderLeftWidth"); // ret -= MiscUtils.getComputedStyleInt(e, "borderRightWidth"); // return Math.max(ret, 0); // } // // /** // * Updated to factor in border and padding // */ // public static final int getH(Element e) { // int ret = e.getOffsetHeight(); // ret -= MiscUtils.getComputedStyleInt(e, "paddingTop"); // ret -= MiscUtils.getComputedStyleInt(e, "paddingBottom"); // ret -= MiscUtils.getComputedStyleInt(e, "borderTopWidth"); // ret -= MiscUtils.getComputedStyleInt(e, "borderBottomWidth"); // return Math.max(ret, 0); // } // // /** // * Sets the bounds of a UIObject, moving and sizing to match the // * bounds specified. Currently used for the itemhover and useful // * for other absolutely positioned elements. // */ // public static final void setBounds(UIObject o, Rect bounds) { // setPosition(o, bounds); // setSize(o, bounds); // } // // /** // * Sets the position of a UIObject // */ // public static final void setPosition(UIObject o, Rect pos) { // Style style = o.getElement().getStyle(); // style.setPropertyPx("left", pos.x); // style.setPropertyPx("top", pos.y); // } // // /** // * Sets the size of a UIObject // */ // public static final void setSize(UIObject o, Rect size) { // o.setPixelSize(size.w, size.h); // // } // // /** // * Determines if a point is inside a box. // */ // public static final boolean isInside(int x, int y, Rect box) { // return (box.x < x && x < box.x + box.w && box.y < y && y < box.y + box.h); // } // // /** // * Determines if a mouse event is inside a box. // */ // public static final boolean isMouseInside(NativeEvent event, Element element) { // return isInside(event.getClientX() + Window.getScrollLeft(), event.getClientY() + Window.getScrollTop(), getBounds(element)); // } // // /** // * This takes into account scrolling and will be in absolute // * coordinates where the top left corner of the page is 0,0 but // * the viewport may be scrolled to something else. // */ // public static final Rect getViewportBounds() { // return new Rect(Window.getScrollLeft(), Window.getScrollTop(), Window.getClientWidth(), Window.getClientHeight()); // } // // }
import com.google.gwt.core.client.Scheduler; import com.google.gwt.core.client.Scheduler.ScheduledCommand; import com.google.gwt.event.dom.client.HasKeyDownHandlers; import com.google.gwt.event.dom.client.HasKeyUpHandlers; import com.google.gwt.event.logical.shared.HasValueChangeHandlers; import com.google.gwt.user.client.ui.Focusable; import com.google.gwt.user.client.ui.HasText; import com.google.gwt.user.client.ui.HasValue; import com.google.gwt.user.client.ui.InlineLabel; import com.google.gwt.user.client.ui.TextBox; import com.google.gwt.user.client.ui.Widget; import com.tractionsoftware.gwt.user.client.util.Geometry;
/* * Copyright 2010 Traction Software, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not * use this file except in compliance with the License. You may obtain a copy of * the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the * License for the specific language governing permissions and limitations under * the License. */ package com.tractionsoftware.gwt.user.client.ui; /** * This attaches to an input, listening for KeyDown/KeyUp, and * automatically resizing the text area. It does this using an * invisible span that matches the text of the input. */ public class AutoSizingTextBox<T extends Widget & HasTextSelection & HasValue<String> & HasValueChangeHandlers<String> & HasKeyUpHandlers & HasKeyDownHandlers & Focusable & HasText> extends AutoSizingBase<T, InlineLabel> { private static final class TextBoxForAutoSize extends TextBox implements HasTextSelection {} public AutoSizingTextBox() { this((T)new TextBoxForAutoSize()); } public AutoSizingTextBox(T box) { this(box, 30); } public AutoSizingTextBox(T box, int extraSize) { super(box, new InlineLabel()); setExtraSize(extraSize); } @Override protected void onLoad() { setMinFromCss("minWidth"); setMaxFromCss("maxWidth"); super.onLoad(); } /** * Returns the size of the shadow element. */ @Override public int getShadowSize() {
// Path: src/main/java/com/tractionsoftware/gwt/user/client/util/Geometry.java // public class Geometry { // // public static final void setInvisibleToMeasure(Element e) { // Style s = e.getStyle(); // s.setProperty("visibility", "hidden"); // s.setProperty("display", "block"); // } // // public static final void unsetInvisibleToMeasure(Element e) { // Style s = e.getStyle(); // s.setProperty("display", "none"); // s.setProperty("visibility", ""); // } // // public static final Rect getBoundsOfHidden(Element e) { // setInvisibleToMeasure(e); // Rect ret = getBounds(e); // unsetInvisibleToMeasure(e); // return ret; // } // // public static final Rect getBounds(Element e) { // return new Rect(getX(e), getY(e), getW(e), getH(e)); // } // // public static final int getX(Element e) { // return e.getAbsoluteLeft(); // } // // public static final int getY(Element e) { // return e.getAbsoluteTop(); // } // // /** // * Updated to factor in border and padding // */ // public static final int getW(Element e) { // int ret = e.getOffsetWidth(); // ret -= MiscUtils.getComputedStyleInt(e, "paddingLeft"); // ret -= MiscUtils.getComputedStyleInt(e, "paddingRight"); // ret -= MiscUtils.getComputedStyleInt(e, "borderLeftWidth"); // ret -= MiscUtils.getComputedStyleInt(e, "borderRightWidth"); // return Math.max(ret, 0); // } // // /** // * Updated to factor in border and padding // */ // public static final int getH(Element e) { // int ret = e.getOffsetHeight(); // ret -= MiscUtils.getComputedStyleInt(e, "paddingTop"); // ret -= MiscUtils.getComputedStyleInt(e, "paddingBottom"); // ret -= MiscUtils.getComputedStyleInt(e, "borderTopWidth"); // ret -= MiscUtils.getComputedStyleInt(e, "borderBottomWidth"); // return Math.max(ret, 0); // } // // /** // * Sets the bounds of a UIObject, moving and sizing to match the // * bounds specified. Currently used for the itemhover and useful // * for other absolutely positioned elements. // */ // public static final void setBounds(UIObject o, Rect bounds) { // setPosition(o, bounds); // setSize(o, bounds); // } // // /** // * Sets the position of a UIObject // */ // public static final void setPosition(UIObject o, Rect pos) { // Style style = o.getElement().getStyle(); // style.setPropertyPx("left", pos.x); // style.setPropertyPx("top", pos.y); // } // // /** // * Sets the size of a UIObject // */ // public static final void setSize(UIObject o, Rect size) { // o.setPixelSize(size.w, size.h); // // } // // /** // * Determines if a point is inside a box. // */ // public static final boolean isInside(int x, int y, Rect box) { // return (box.x < x && x < box.x + box.w && box.y < y && y < box.y + box.h); // } // // /** // * Determines if a mouse event is inside a box. // */ // public static final boolean isMouseInside(NativeEvent event, Element element) { // return isInside(event.getClientX() + Window.getScrollLeft(), event.getClientY() + Window.getScrollTop(), getBounds(element)); // } // // /** // * This takes into account scrolling and will be in absolute // * coordinates where the top left corner of the page is 0,0 but // * the viewport may be scrolled to something else. // */ // public static final Rect getViewportBounds() { // return new Rect(Window.getScrollLeft(), Window.getScrollTop(), Window.getClientWidth(), Window.getClientHeight()); // } // // } // Path: src/main/java/com/tractionsoftware/gwt/user/client/ui/AutoSizingTextBox.java import com.google.gwt.core.client.Scheduler; import com.google.gwt.core.client.Scheduler.ScheduledCommand; import com.google.gwt.event.dom.client.HasKeyDownHandlers; import com.google.gwt.event.dom.client.HasKeyUpHandlers; import com.google.gwt.event.logical.shared.HasValueChangeHandlers; import com.google.gwt.user.client.ui.Focusable; import com.google.gwt.user.client.ui.HasText; import com.google.gwt.user.client.ui.HasValue; import com.google.gwt.user.client.ui.InlineLabel; import com.google.gwt.user.client.ui.TextBox; import com.google.gwt.user.client.ui.Widget; import com.tractionsoftware.gwt.user.client.util.Geometry; /* * Copyright 2010 Traction Software, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not * use this file except in compliance with the License. You may obtain a copy of * the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the * License for the specific language governing permissions and limitations under * the License. */ package com.tractionsoftware.gwt.user.client.ui; /** * This attaches to an input, listening for KeyDown/KeyUp, and * automatically resizing the text area. It does this using an * invisible span that matches the text of the input. */ public class AutoSizingTextBox<T extends Widget & HasTextSelection & HasValue<String> & HasValueChangeHandlers<String> & HasKeyUpHandlers & HasKeyDownHandlers & Focusable & HasText> extends AutoSizingBase<T, InlineLabel> { private static final class TextBoxForAutoSize extends TextBox implements HasTextSelection {} public AutoSizingTextBox() { this((T)new TextBoxForAutoSize()); } public AutoSizingTextBox(T box) { this(box, 30); } public AutoSizingTextBox(T box, int extraSize) { super(box, new InlineLabel()); setExtraSize(extraSize); } @Override protected void onLoad() { setMinFromCss("minWidth"); setMaxFromCss("maxWidth"); super.onLoad(); } /** * Returns the size of the shadow element. */ @Override public int getShadowSize() {
return Geometry.getW(shadow.getElement());
xdtianyu/Kindle
app/src/main/java/org/xdty/kindle/di/modules/MainModule.java
// Path: app/src/main/java/org/xdty/kindle/contract/MainContract.java // public interface MainContract { // // interface View extends BaseView<Presenter> { // void refresh(List<Book> books); // } // // interface Presenter extends BasePresenter { // void loadBooks(); // // void getBookNodes(Book book); // // void getReviews(String itemId); // // void setMode(Mode mode); // } // } // // Path: app/src/main/java/org/xdty/kindle/presenter/MainPresenter.java // public class MainPresenter implements MainContract.Presenter { // // private static final String TAG = MainPresenter.class.getSimpleName(); // // @Inject // BookDataSource mBookDataSource; // // private MainContract.View mView; // // private Mode mMode = Mode.DAILY_DEALS; // // public MainPresenter(MainContract.View view) { // mView = view; // Application.getAppComponent().inject(this); // } // // @Override // public void start() { // loadBooks(); // } // // @Override // public void loadBooks() { // mBookDataSource.getBooks(mMode).subscribe(new Action1<List<Book>>() { // @Override // public void call(List<Book> books) { // mView.refresh(books); // } // }); // } // // @Override // public void getBookNodes(Book book) { // mBookDataSource.getBookNodes(book.getItemId()).subscribe(new Action1<List<Node>>() { // @Override // public void call(List<Node> nodes) { // Log.e(TAG, "nodes: " + nodes); // } // }); // } // // @Override // public void getReviews(String itemId) { // mBookDataSource.getReviews(itemId).subscribe(new Action1<List<Review>>() { // @Override // public void call(List<Review> reviews) { // Log.e(TAG, "reviews: " + reviews); // } // }); // } // // @Override // public void setMode(Mode mode) { // mMode = mode; // } // }
import org.xdty.kindle.contract.MainContract; import org.xdty.kindle.presenter.MainPresenter; import dagger.Module; import dagger.Provides;
package org.xdty.kindle.di.modules; @Module public class MainModule {
// Path: app/src/main/java/org/xdty/kindle/contract/MainContract.java // public interface MainContract { // // interface View extends BaseView<Presenter> { // void refresh(List<Book> books); // } // // interface Presenter extends BasePresenter { // void loadBooks(); // // void getBookNodes(Book book); // // void getReviews(String itemId); // // void setMode(Mode mode); // } // } // // Path: app/src/main/java/org/xdty/kindle/presenter/MainPresenter.java // public class MainPresenter implements MainContract.Presenter { // // private static final String TAG = MainPresenter.class.getSimpleName(); // // @Inject // BookDataSource mBookDataSource; // // private MainContract.View mView; // // private Mode mMode = Mode.DAILY_DEALS; // // public MainPresenter(MainContract.View view) { // mView = view; // Application.getAppComponent().inject(this); // } // // @Override // public void start() { // loadBooks(); // } // // @Override // public void loadBooks() { // mBookDataSource.getBooks(mMode).subscribe(new Action1<List<Book>>() { // @Override // public void call(List<Book> books) { // mView.refresh(books); // } // }); // } // // @Override // public void getBookNodes(Book book) { // mBookDataSource.getBookNodes(book.getItemId()).subscribe(new Action1<List<Node>>() { // @Override // public void call(List<Node> nodes) { // Log.e(TAG, "nodes: " + nodes); // } // }); // } // // @Override // public void getReviews(String itemId) { // mBookDataSource.getReviews(itemId).subscribe(new Action1<List<Review>>() { // @Override // public void call(List<Review> reviews) { // Log.e(TAG, "reviews: " + reviews); // } // }); // } // // @Override // public void setMode(Mode mode) { // mMode = mode; // } // } // Path: app/src/main/java/org/xdty/kindle/di/modules/MainModule.java import org.xdty.kindle.contract.MainContract; import org.xdty.kindle.presenter.MainPresenter; import dagger.Module; import dagger.Provides; package org.xdty.kindle.di.modules; @Module public class MainModule {
private MainContract.View mView;
xdtianyu/Kindle
app/src/main/java/org/xdty/kindle/di/modules/MainModule.java
// Path: app/src/main/java/org/xdty/kindle/contract/MainContract.java // public interface MainContract { // // interface View extends BaseView<Presenter> { // void refresh(List<Book> books); // } // // interface Presenter extends BasePresenter { // void loadBooks(); // // void getBookNodes(Book book); // // void getReviews(String itemId); // // void setMode(Mode mode); // } // } // // Path: app/src/main/java/org/xdty/kindle/presenter/MainPresenter.java // public class MainPresenter implements MainContract.Presenter { // // private static final String TAG = MainPresenter.class.getSimpleName(); // // @Inject // BookDataSource mBookDataSource; // // private MainContract.View mView; // // private Mode mMode = Mode.DAILY_DEALS; // // public MainPresenter(MainContract.View view) { // mView = view; // Application.getAppComponent().inject(this); // } // // @Override // public void start() { // loadBooks(); // } // // @Override // public void loadBooks() { // mBookDataSource.getBooks(mMode).subscribe(new Action1<List<Book>>() { // @Override // public void call(List<Book> books) { // mView.refresh(books); // } // }); // } // // @Override // public void getBookNodes(Book book) { // mBookDataSource.getBookNodes(book.getItemId()).subscribe(new Action1<List<Node>>() { // @Override // public void call(List<Node> nodes) { // Log.e(TAG, "nodes: " + nodes); // } // }); // } // // @Override // public void getReviews(String itemId) { // mBookDataSource.getReviews(itemId).subscribe(new Action1<List<Review>>() { // @Override // public void call(List<Review> reviews) { // Log.e(TAG, "reviews: " + reviews); // } // }); // } // // @Override // public void setMode(Mode mode) { // mMode = mode; // } // }
import org.xdty.kindle.contract.MainContract; import org.xdty.kindle.presenter.MainPresenter; import dagger.Module; import dagger.Provides;
package org.xdty.kindle.di.modules; @Module public class MainModule { private MainContract.View mView; public MainModule(MainContract.View view) { mView = view; } @Provides MainContract.View provideView() { return mView; } @Provides MainContract.Presenter providePresenter() {
// Path: app/src/main/java/org/xdty/kindle/contract/MainContract.java // public interface MainContract { // // interface View extends BaseView<Presenter> { // void refresh(List<Book> books); // } // // interface Presenter extends BasePresenter { // void loadBooks(); // // void getBookNodes(Book book); // // void getReviews(String itemId); // // void setMode(Mode mode); // } // } // // Path: app/src/main/java/org/xdty/kindle/presenter/MainPresenter.java // public class MainPresenter implements MainContract.Presenter { // // private static final String TAG = MainPresenter.class.getSimpleName(); // // @Inject // BookDataSource mBookDataSource; // // private MainContract.View mView; // // private Mode mMode = Mode.DAILY_DEALS; // // public MainPresenter(MainContract.View view) { // mView = view; // Application.getAppComponent().inject(this); // } // // @Override // public void start() { // loadBooks(); // } // // @Override // public void loadBooks() { // mBookDataSource.getBooks(mMode).subscribe(new Action1<List<Book>>() { // @Override // public void call(List<Book> books) { // mView.refresh(books); // } // }); // } // // @Override // public void getBookNodes(Book book) { // mBookDataSource.getBookNodes(book.getItemId()).subscribe(new Action1<List<Node>>() { // @Override // public void call(List<Node> nodes) { // Log.e(TAG, "nodes: " + nodes); // } // }); // } // // @Override // public void getReviews(String itemId) { // mBookDataSource.getReviews(itemId).subscribe(new Action1<List<Review>>() { // @Override // public void call(List<Review> reviews) { // Log.e(TAG, "reviews: " + reviews); // } // }); // } // // @Override // public void setMode(Mode mode) { // mMode = mode; // } // } // Path: app/src/main/java/org/xdty/kindle/di/modules/MainModule.java import org.xdty.kindle.contract.MainContract; import org.xdty.kindle.presenter.MainPresenter; import dagger.Module; import dagger.Provides; package org.xdty.kindle.di.modules; @Module public class MainModule { private MainContract.View mView; public MainModule(MainContract.View view) { mView = view; } @Provides MainContract.View provideView() { return mView; } @Provides MainContract.Presenter providePresenter() {
return new MainPresenter(mView);
xdtianyu/Kindle
app/src/main/java/org/xdty/kindle/data/BookRepository.java
// Path: app/src/main/java/org/xdty/kindle/application/Application.java // public class Application extends android.app.Application { // // private static AppComponent sAppComponent; // // @Override // public void onCreate() { // super.onCreate(); // sAppComponent = DaggerAppComponent.builder().appModule(new AppModule(this)).build(); // } // // public static AppComponent getAppComponent() { // return sAppComponent; // } // // } // // Path: app/src/main/java/org/xdty/kindle/module/Books.java // public class Books { // // private List<Book> books; // private String time; // private long timestamp; // // public List<Book> getBooks() { // return books; // } // // public void setBooks(List<Book> books) { // this.books = books; // } // // public String getTime() { // return time; // } // // public void setTime(String time) { // this.time = time; // } // // public long getTimestamp() { // return timestamp; // } // // public void setTimestamp(long timestamp) { // this.timestamp = timestamp; // } // } // // Path: app/src/main/java/org/xdty/kindle/module/database/Database.java // public interface Database { // // List<Book> getCnBooksSync(); // // List<Book> getEnBooksSync(); // // List<Node> getBookNodesSync(String itemId); // // Node getNodeParentSync(long nodeId); // // List<Review> getReviewsSync(String itemId); // // Book getBookSync(String itemId); // } // // Path: app/src/main/java/org/xdty/kindle/utils/Constants.java // public class Constants { // // public final static String BASE_URL = "https://static-10049225.file.myqcloud.com/"; // //public final static String BASE_URL = "http://oe1kgsvca.bkt.clouddn.com/kindle.json"; // // public final static String DB_NAME = "books.db"; // public final static int DB_VERSION = 1; // // public final static long CACHE_TIME = 30 * 60 * 1000; // // }
import org.xdty.kindle.application.Application; import org.xdty.kindle.module.Book; import org.xdty.kindle.module.Books; import org.xdty.kindle.module.Node; import org.xdty.kindle.module.Review; import org.xdty.kindle.module.database.Database; import org.xdty.kindle.utils.Constants; import java.io.IOException; import java.util.HashMap; import java.util.List; import java.util.Map; import javax.inject.Inject; import rx.Observable; import rx.Subscriber; import rx.android.schedulers.AndroidSchedulers; import rx.schedulers.Schedulers;
package org.xdty.kindle.data; public class BookRepository implements BookDataSource { @Inject BookService mBookService; @Inject
// Path: app/src/main/java/org/xdty/kindle/application/Application.java // public class Application extends android.app.Application { // // private static AppComponent sAppComponent; // // @Override // public void onCreate() { // super.onCreate(); // sAppComponent = DaggerAppComponent.builder().appModule(new AppModule(this)).build(); // } // // public static AppComponent getAppComponent() { // return sAppComponent; // } // // } // // Path: app/src/main/java/org/xdty/kindle/module/Books.java // public class Books { // // private List<Book> books; // private String time; // private long timestamp; // // public List<Book> getBooks() { // return books; // } // // public void setBooks(List<Book> books) { // this.books = books; // } // // public String getTime() { // return time; // } // // public void setTime(String time) { // this.time = time; // } // // public long getTimestamp() { // return timestamp; // } // // public void setTimestamp(long timestamp) { // this.timestamp = timestamp; // } // } // // Path: app/src/main/java/org/xdty/kindle/module/database/Database.java // public interface Database { // // List<Book> getCnBooksSync(); // // List<Book> getEnBooksSync(); // // List<Node> getBookNodesSync(String itemId); // // Node getNodeParentSync(long nodeId); // // List<Review> getReviewsSync(String itemId); // // Book getBookSync(String itemId); // } // // Path: app/src/main/java/org/xdty/kindle/utils/Constants.java // public class Constants { // // public final static String BASE_URL = "https://static-10049225.file.myqcloud.com/"; // //public final static String BASE_URL = "http://oe1kgsvca.bkt.clouddn.com/kindle.json"; // // public final static String DB_NAME = "books.db"; // public final static int DB_VERSION = 1; // // public final static long CACHE_TIME = 30 * 60 * 1000; // // } // Path: app/src/main/java/org/xdty/kindle/data/BookRepository.java import org.xdty.kindle.application.Application; import org.xdty.kindle.module.Book; import org.xdty.kindle.module.Books; import org.xdty.kindle.module.Node; import org.xdty.kindle.module.Review; import org.xdty.kindle.module.database.Database; import org.xdty.kindle.utils.Constants; import java.io.IOException; import java.util.HashMap; import java.util.List; import java.util.Map; import javax.inject.Inject; import rx.Observable; import rx.Subscriber; import rx.android.schedulers.AndroidSchedulers; import rx.schedulers.Schedulers; package org.xdty.kindle.data; public class BookRepository implements BookDataSource { @Inject BookService mBookService; @Inject
Database mDatabase;
xdtianyu/Kindle
app/src/main/java/org/xdty/kindle/data/BookRepository.java
// Path: app/src/main/java/org/xdty/kindle/application/Application.java // public class Application extends android.app.Application { // // private static AppComponent sAppComponent; // // @Override // public void onCreate() { // super.onCreate(); // sAppComponent = DaggerAppComponent.builder().appModule(new AppModule(this)).build(); // } // // public static AppComponent getAppComponent() { // return sAppComponent; // } // // } // // Path: app/src/main/java/org/xdty/kindle/module/Books.java // public class Books { // // private List<Book> books; // private String time; // private long timestamp; // // public List<Book> getBooks() { // return books; // } // // public void setBooks(List<Book> books) { // this.books = books; // } // // public String getTime() { // return time; // } // // public void setTime(String time) { // this.time = time; // } // // public long getTimestamp() { // return timestamp; // } // // public void setTimestamp(long timestamp) { // this.timestamp = timestamp; // } // } // // Path: app/src/main/java/org/xdty/kindle/module/database/Database.java // public interface Database { // // List<Book> getCnBooksSync(); // // List<Book> getEnBooksSync(); // // List<Node> getBookNodesSync(String itemId); // // Node getNodeParentSync(long nodeId); // // List<Review> getReviewsSync(String itemId); // // Book getBookSync(String itemId); // } // // Path: app/src/main/java/org/xdty/kindle/utils/Constants.java // public class Constants { // // public final static String BASE_URL = "https://static-10049225.file.myqcloud.com/"; // //public final static String BASE_URL = "http://oe1kgsvca.bkt.clouddn.com/kindle.json"; // // public final static String DB_NAME = "books.db"; // public final static int DB_VERSION = 1; // // public final static long CACHE_TIME = 30 * 60 * 1000; // // }
import org.xdty.kindle.application.Application; import org.xdty.kindle.module.Book; import org.xdty.kindle.module.Books; import org.xdty.kindle.module.Node; import org.xdty.kindle.module.Review; import org.xdty.kindle.module.database.Database; import org.xdty.kindle.utils.Constants; import java.io.IOException; import java.util.HashMap; import java.util.List; import java.util.Map; import javax.inject.Inject; import rx.Observable; import rx.Subscriber; import rx.android.schedulers.AndroidSchedulers; import rx.schedulers.Schedulers;
package org.xdty.kindle.data; public class BookRepository implements BookDataSource { @Inject BookService mBookService; @Inject Database mDatabase;
// Path: app/src/main/java/org/xdty/kindle/application/Application.java // public class Application extends android.app.Application { // // private static AppComponent sAppComponent; // // @Override // public void onCreate() { // super.onCreate(); // sAppComponent = DaggerAppComponent.builder().appModule(new AppModule(this)).build(); // } // // public static AppComponent getAppComponent() { // return sAppComponent; // } // // } // // Path: app/src/main/java/org/xdty/kindle/module/Books.java // public class Books { // // private List<Book> books; // private String time; // private long timestamp; // // public List<Book> getBooks() { // return books; // } // // public void setBooks(List<Book> books) { // this.books = books; // } // // public String getTime() { // return time; // } // // public void setTime(String time) { // this.time = time; // } // // public long getTimestamp() { // return timestamp; // } // // public void setTimestamp(long timestamp) { // this.timestamp = timestamp; // } // } // // Path: app/src/main/java/org/xdty/kindle/module/database/Database.java // public interface Database { // // List<Book> getCnBooksSync(); // // List<Book> getEnBooksSync(); // // List<Node> getBookNodesSync(String itemId); // // Node getNodeParentSync(long nodeId); // // List<Review> getReviewsSync(String itemId); // // Book getBookSync(String itemId); // } // // Path: app/src/main/java/org/xdty/kindle/utils/Constants.java // public class Constants { // // public final static String BASE_URL = "https://static-10049225.file.myqcloud.com/"; // //public final static String BASE_URL = "http://oe1kgsvca.bkt.clouddn.com/kindle.json"; // // public final static String DB_NAME = "books.db"; // public final static int DB_VERSION = 1; // // public final static long CACHE_TIME = 30 * 60 * 1000; // // } // Path: app/src/main/java/org/xdty/kindle/data/BookRepository.java import org.xdty.kindle.application.Application; import org.xdty.kindle.module.Book; import org.xdty.kindle.module.Books; import org.xdty.kindle.module.Node; import org.xdty.kindle.module.Review; import org.xdty.kindle.module.database.Database; import org.xdty.kindle.utils.Constants; import java.io.IOException; import java.util.HashMap; import java.util.List; import java.util.Map; import javax.inject.Inject; import rx.Observable; import rx.Subscriber; import rx.android.schedulers.AndroidSchedulers; import rx.schedulers.Schedulers; package org.xdty.kindle.data; public class BookRepository implements BookDataSource { @Inject BookService mBookService; @Inject Database mDatabase;
private Books mBooks;
xdtianyu/Kindle
app/src/main/java/org/xdty/kindle/data/BookRepository.java
// Path: app/src/main/java/org/xdty/kindle/application/Application.java // public class Application extends android.app.Application { // // private static AppComponent sAppComponent; // // @Override // public void onCreate() { // super.onCreate(); // sAppComponent = DaggerAppComponent.builder().appModule(new AppModule(this)).build(); // } // // public static AppComponent getAppComponent() { // return sAppComponent; // } // // } // // Path: app/src/main/java/org/xdty/kindle/module/Books.java // public class Books { // // private List<Book> books; // private String time; // private long timestamp; // // public List<Book> getBooks() { // return books; // } // // public void setBooks(List<Book> books) { // this.books = books; // } // // public String getTime() { // return time; // } // // public void setTime(String time) { // this.time = time; // } // // public long getTimestamp() { // return timestamp; // } // // public void setTimestamp(long timestamp) { // this.timestamp = timestamp; // } // } // // Path: app/src/main/java/org/xdty/kindle/module/database/Database.java // public interface Database { // // List<Book> getCnBooksSync(); // // List<Book> getEnBooksSync(); // // List<Node> getBookNodesSync(String itemId); // // Node getNodeParentSync(long nodeId); // // List<Review> getReviewsSync(String itemId); // // Book getBookSync(String itemId); // } // // Path: app/src/main/java/org/xdty/kindle/utils/Constants.java // public class Constants { // // public final static String BASE_URL = "https://static-10049225.file.myqcloud.com/"; // //public final static String BASE_URL = "http://oe1kgsvca.bkt.clouddn.com/kindle.json"; // // public final static String DB_NAME = "books.db"; // public final static int DB_VERSION = 1; // // public final static long CACHE_TIME = 30 * 60 * 1000; // // }
import org.xdty.kindle.application.Application; import org.xdty.kindle.module.Book; import org.xdty.kindle.module.Books; import org.xdty.kindle.module.Node; import org.xdty.kindle.module.Review; import org.xdty.kindle.module.database.Database; import org.xdty.kindle.utils.Constants; import java.io.IOException; import java.util.HashMap; import java.util.List; import java.util.Map; import javax.inject.Inject; import rx.Observable; import rx.Subscriber; import rx.android.schedulers.AndroidSchedulers; import rx.schedulers.Schedulers;
package org.xdty.kindle.data; public class BookRepository implements BookDataSource { @Inject BookService mBookService; @Inject Database mDatabase; private Books mBooks; private Map<String, Review> mReviewCache = new HashMap<>(); private Map<String, Book> mBookCache = new HashMap<>(); public BookRepository() {
// Path: app/src/main/java/org/xdty/kindle/application/Application.java // public class Application extends android.app.Application { // // private static AppComponent sAppComponent; // // @Override // public void onCreate() { // super.onCreate(); // sAppComponent = DaggerAppComponent.builder().appModule(new AppModule(this)).build(); // } // // public static AppComponent getAppComponent() { // return sAppComponent; // } // // } // // Path: app/src/main/java/org/xdty/kindle/module/Books.java // public class Books { // // private List<Book> books; // private String time; // private long timestamp; // // public List<Book> getBooks() { // return books; // } // // public void setBooks(List<Book> books) { // this.books = books; // } // // public String getTime() { // return time; // } // // public void setTime(String time) { // this.time = time; // } // // public long getTimestamp() { // return timestamp; // } // // public void setTimestamp(long timestamp) { // this.timestamp = timestamp; // } // } // // Path: app/src/main/java/org/xdty/kindle/module/database/Database.java // public interface Database { // // List<Book> getCnBooksSync(); // // List<Book> getEnBooksSync(); // // List<Node> getBookNodesSync(String itemId); // // Node getNodeParentSync(long nodeId); // // List<Review> getReviewsSync(String itemId); // // Book getBookSync(String itemId); // } // // Path: app/src/main/java/org/xdty/kindle/utils/Constants.java // public class Constants { // // public final static String BASE_URL = "https://static-10049225.file.myqcloud.com/"; // //public final static String BASE_URL = "http://oe1kgsvca.bkt.clouddn.com/kindle.json"; // // public final static String DB_NAME = "books.db"; // public final static int DB_VERSION = 1; // // public final static long CACHE_TIME = 30 * 60 * 1000; // // } // Path: app/src/main/java/org/xdty/kindle/data/BookRepository.java import org.xdty.kindle.application.Application; import org.xdty.kindle.module.Book; import org.xdty.kindle.module.Books; import org.xdty.kindle.module.Node; import org.xdty.kindle.module.Review; import org.xdty.kindle.module.database.Database; import org.xdty.kindle.utils.Constants; import java.io.IOException; import java.util.HashMap; import java.util.List; import java.util.Map; import javax.inject.Inject; import rx.Observable; import rx.Subscriber; import rx.android.schedulers.AndroidSchedulers; import rx.schedulers.Schedulers; package org.xdty.kindle.data; public class BookRepository implements BookDataSource { @Inject BookService mBookService; @Inject Database mDatabase; private Books mBooks; private Map<String, Review> mReviewCache = new HashMap<>(); private Map<String, Book> mBookCache = new HashMap<>(); public BookRepository() {
Application.getAppComponent().inject(this);
xdtianyu/Kindle
app/src/main/java/org/xdty/kindle/data/BookRepository.java
// Path: app/src/main/java/org/xdty/kindle/application/Application.java // public class Application extends android.app.Application { // // private static AppComponent sAppComponent; // // @Override // public void onCreate() { // super.onCreate(); // sAppComponent = DaggerAppComponent.builder().appModule(new AppModule(this)).build(); // } // // public static AppComponent getAppComponent() { // return sAppComponent; // } // // } // // Path: app/src/main/java/org/xdty/kindle/module/Books.java // public class Books { // // private List<Book> books; // private String time; // private long timestamp; // // public List<Book> getBooks() { // return books; // } // // public void setBooks(List<Book> books) { // this.books = books; // } // // public String getTime() { // return time; // } // // public void setTime(String time) { // this.time = time; // } // // public long getTimestamp() { // return timestamp; // } // // public void setTimestamp(long timestamp) { // this.timestamp = timestamp; // } // } // // Path: app/src/main/java/org/xdty/kindle/module/database/Database.java // public interface Database { // // List<Book> getCnBooksSync(); // // List<Book> getEnBooksSync(); // // List<Node> getBookNodesSync(String itemId); // // Node getNodeParentSync(long nodeId); // // List<Review> getReviewsSync(String itemId); // // Book getBookSync(String itemId); // } // // Path: app/src/main/java/org/xdty/kindle/utils/Constants.java // public class Constants { // // public final static String BASE_URL = "https://static-10049225.file.myqcloud.com/"; // //public final static String BASE_URL = "http://oe1kgsvca.bkt.clouddn.com/kindle.json"; // // public final static String DB_NAME = "books.db"; // public final static int DB_VERSION = 1; // // public final static long CACHE_TIME = 30 * 60 * 1000; // // }
import org.xdty.kindle.application.Application; import org.xdty.kindle.module.Book; import org.xdty.kindle.module.Books; import org.xdty.kindle.module.Node; import org.xdty.kindle.module.Review; import org.xdty.kindle.module.database.Database; import org.xdty.kindle.utils.Constants; import java.io.IOException; import java.util.HashMap; import java.util.List; import java.util.Map; import javax.inject.Inject; import rx.Observable; import rx.Subscriber; import rx.android.schedulers.AndroidSchedulers; import rx.schedulers.Schedulers;
package org.xdty.kindle.data; public class BookRepository implements BookDataSource { @Inject BookService mBookService; @Inject Database mDatabase; private Books mBooks; private Map<String, Review> mReviewCache = new HashMap<>(); private Map<String, Book> mBookCache = new HashMap<>(); public BookRepository() { Application.getAppComponent().inject(this); } @Override public Observable<List<Book>> getDailyBooks() { return Observable.create(new Observable.OnSubscribe<List<Book>>() { @Override public void call(Subscriber<? super List<Book>> subscriber) { try { if (mBooks == null || (System.currentTimeMillis() - mBooks.getTimestamp()
// Path: app/src/main/java/org/xdty/kindle/application/Application.java // public class Application extends android.app.Application { // // private static AppComponent sAppComponent; // // @Override // public void onCreate() { // super.onCreate(); // sAppComponent = DaggerAppComponent.builder().appModule(new AppModule(this)).build(); // } // // public static AppComponent getAppComponent() { // return sAppComponent; // } // // } // // Path: app/src/main/java/org/xdty/kindle/module/Books.java // public class Books { // // private List<Book> books; // private String time; // private long timestamp; // // public List<Book> getBooks() { // return books; // } // // public void setBooks(List<Book> books) { // this.books = books; // } // // public String getTime() { // return time; // } // // public void setTime(String time) { // this.time = time; // } // // public long getTimestamp() { // return timestamp; // } // // public void setTimestamp(long timestamp) { // this.timestamp = timestamp; // } // } // // Path: app/src/main/java/org/xdty/kindle/module/database/Database.java // public interface Database { // // List<Book> getCnBooksSync(); // // List<Book> getEnBooksSync(); // // List<Node> getBookNodesSync(String itemId); // // Node getNodeParentSync(long nodeId); // // List<Review> getReviewsSync(String itemId); // // Book getBookSync(String itemId); // } // // Path: app/src/main/java/org/xdty/kindle/utils/Constants.java // public class Constants { // // public final static String BASE_URL = "https://static-10049225.file.myqcloud.com/"; // //public final static String BASE_URL = "http://oe1kgsvca.bkt.clouddn.com/kindle.json"; // // public final static String DB_NAME = "books.db"; // public final static int DB_VERSION = 1; // // public final static long CACHE_TIME = 30 * 60 * 1000; // // } // Path: app/src/main/java/org/xdty/kindle/data/BookRepository.java import org.xdty.kindle.application.Application; import org.xdty.kindle.module.Book; import org.xdty.kindle.module.Books; import org.xdty.kindle.module.Node; import org.xdty.kindle.module.Review; import org.xdty.kindle.module.database.Database; import org.xdty.kindle.utils.Constants; import java.io.IOException; import java.util.HashMap; import java.util.List; import java.util.Map; import javax.inject.Inject; import rx.Observable; import rx.Subscriber; import rx.android.schedulers.AndroidSchedulers; import rx.schedulers.Schedulers; package org.xdty.kindle.data; public class BookRepository implements BookDataSource { @Inject BookService mBookService; @Inject Database mDatabase; private Books mBooks; private Map<String, Review> mReviewCache = new HashMap<>(); private Map<String, Book> mBookCache = new HashMap<>(); public BookRepository() { Application.getAppComponent().inject(this); } @Override public Observable<List<Book>> getDailyBooks() { return Observable.create(new Observable.OnSubscribe<List<Book>>() { @Override public void call(Subscriber<? super List<Book>> subscriber) { try { if (mBooks == null || (System.currentTimeMillis() - mBooks.getTimestamp()
> Constants.CACHE_TIME)) {
xdtianyu/Kindle
app/src/main/java/org/xdty/kindle/MainActivity.java
// Path: app/src/main/java/org/xdty/kindle/contract/MainContract.java // public interface MainContract { // // interface View extends BaseView<Presenter> { // void refresh(List<Book> books); // } // // interface Presenter extends BasePresenter { // void loadBooks(); // // void getBookNodes(Book book); // // void getReviews(String itemId); // // void setMode(Mode mode); // } // } // // Path: app/src/main/java/org/xdty/kindle/data/Mode.java // public enum Mode { // DAILY_DEALS, // FREE_CN, // FREE_EN // } // // Path: app/src/main/java/org/xdty/kindle/di/modules/MainModule.java // @Module // public class MainModule { // // private MainContract.View mView; // // public MainModule(MainContract.View view) { // mView = view; // } // // @Provides // MainContract.View provideView() { // return mView; // } // // @Provides // MainContract.Presenter providePresenter() { // return new MainPresenter(mView); // } // // } // // Path: app/src/main/java/org/xdty/kindle/view/BooksAdapter.java // public class BooksAdapter extends RecyclerView.Adapter<BooksAdapter.ViewHolder> { // // @Inject // RequestManager mGlideRequest; // private List<Book> mBooks = new ArrayList<>(); // private ItemClickListener mItemClickListener; // // public BooksAdapter() { // Application.getAppComponent().inject(this); // } // // @Override // public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { // // View view = LayoutInflater.from(parent.getContext()) // .inflate(R.layout.item_book, parent, false); // // return new ViewHolder(view); // } // // @Override // public void onBindViewHolder(ViewHolder holder, int position) { // holder.bind(mBooks.get(position)); // } // // @Override // public int getItemCount() { // return mBooks.size(); // } // // public void refresh(List<Book> books) { // mBooks.clear(); // mBooks.addAll(books); // notifyDataSetChanged(); // } // // public void setItemClickListener(ItemClickListener itemClickListener) { // mItemClickListener = itemClickListener; // } // // public interface ItemClickListener { // void onItemClick(Book book); // } // // class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener { // // private Book mBook; // // private ImageView thumbnail; // private TextView title; // private TextView author; // private TextView pages; // private TextView price; // // ViewHolder(View view) { // super(view); // // thumbnail = (ImageView) view.findViewById(R.id.thumbnail); // title = (TextView) view.findViewById(R.id.title); // author = (TextView) view.findViewById(R.id.author); // pages = (TextView) view.findViewById(R.id.pages); // price = (TextView) view.findViewById(R.id.price); // view.setOnClickListener(this); // } // // void bind(Book book) { // mBook = book; // title.setText(book.getTitle()); // author.setText(book.getAuthor()); // pages.setText(book.getPages()); // price.setText(getString(R.string.price, book.getPrice())); // // mGlideRequest.load(book.getLargeImageUrl()) // .crossFade() // .into(thumbnail); // } // // String getString(int resId, Object... formatArgs) { // return itemView.getContext().getString(resId, formatArgs); // } // // @Override // public void onClick(View view) { // if (mItemClickListener != null) { // mItemClickListener.onItemClick(mBook); // } // } // } // }
import android.content.Intent; import android.os.Bundle; import android.support.annotation.NonNull; import android.support.design.widget.NavigationView; import android.support.v4.view.GravityCompat; import android.support.v4.widget.DrawerLayout; import android.support.v7.app.ActionBarDrawerToggle; import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.RecyclerView; import android.support.v7.widget.Toolbar; import android.view.Menu; import android.view.MenuItem; import org.xdty.kindle.contract.MainContract; import org.xdty.kindle.data.Mode; import org.xdty.kindle.di.DaggerMainComponent; import org.xdty.kindle.di.modules.MainModule; import org.xdty.kindle.module.Book; import org.xdty.kindle.view.BooksAdapter; import java.util.List; import javax.inject.Inject;
package org.xdty.kindle; public class MainActivity extends AppCompatActivity implements MainContract.View, NavigationView.OnNavigationItemSelectedListener,
// Path: app/src/main/java/org/xdty/kindle/contract/MainContract.java // public interface MainContract { // // interface View extends BaseView<Presenter> { // void refresh(List<Book> books); // } // // interface Presenter extends BasePresenter { // void loadBooks(); // // void getBookNodes(Book book); // // void getReviews(String itemId); // // void setMode(Mode mode); // } // } // // Path: app/src/main/java/org/xdty/kindle/data/Mode.java // public enum Mode { // DAILY_DEALS, // FREE_CN, // FREE_EN // } // // Path: app/src/main/java/org/xdty/kindle/di/modules/MainModule.java // @Module // public class MainModule { // // private MainContract.View mView; // // public MainModule(MainContract.View view) { // mView = view; // } // // @Provides // MainContract.View provideView() { // return mView; // } // // @Provides // MainContract.Presenter providePresenter() { // return new MainPresenter(mView); // } // // } // // Path: app/src/main/java/org/xdty/kindle/view/BooksAdapter.java // public class BooksAdapter extends RecyclerView.Adapter<BooksAdapter.ViewHolder> { // // @Inject // RequestManager mGlideRequest; // private List<Book> mBooks = new ArrayList<>(); // private ItemClickListener mItemClickListener; // // public BooksAdapter() { // Application.getAppComponent().inject(this); // } // // @Override // public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { // // View view = LayoutInflater.from(parent.getContext()) // .inflate(R.layout.item_book, parent, false); // // return new ViewHolder(view); // } // // @Override // public void onBindViewHolder(ViewHolder holder, int position) { // holder.bind(mBooks.get(position)); // } // // @Override // public int getItemCount() { // return mBooks.size(); // } // // public void refresh(List<Book> books) { // mBooks.clear(); // mBooks.addAll(books); // notifyDataSetChanged(); // } // // public void setItemClickListener(ItemClickListener itemClickListener) { // mItemClickListener = itemClickListener; // } // // public interface ItemClickListener { // void onItemClick(Book book); // } // // class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener { // // private Book mBook; // // private ImageView thumbnail; // private TextView title; // private TextView author; // private TextView pages; // private TextView price; // // ViewHolder(View view) { // super(view); // // thumbnail = (ImageView) view.findViewById(R.id.thumbnail); // title = (TextView) view.findViewById(R.id.title); // author = (TextView) view.findViewById(R.id.author); // pages = (TextView) view.findViewById(R.id.pages); // price = (TextView) view.findViewById(R.id.price); // view.setOnClickListener(this); // } // // void bind(Book book) { // mBook = book; // title.setText(book.getTitle()); // author.setText(book.getAuthor()); // pages.setText(book.getPages()); // price.setText(getString(R.string.price, book.getPrice())); // // mGlideRequest.load(book.getLargeImageUrl()) // .crossFade() // .into(thumbnail); // } // // String getString(int resId, Object... formatArgs) { // return itemView.getContext().getString(resId, formatArgs); // } // // @Override // public void onClick(View view) { // if (mItemClickListener != null) { // mItemClickListener.onItemClick(mBook); // } // } // } // } // Path: app/src/main/java/org/xdty/kindle/MainActivity.java import android.content.Intent; import android.os.Bundle; import android.support.annotation.NonNull; import android.support.design.widget.NavigationView; import android.support.v4.view.GravityCompat; import android.support.v4.widget.DrawerLayout; import android.support.v7.app.ActionBarDrawerToggle; import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.RecyclerView; import android.support.v7.widget.Toolbar; import android.view.Menu; import android.view.MenuItem; import org.xdty.kindle.contract.MainContract; import org.xdty.kindle.data.Mode; import org.xdty.kindle.di.DaggerMainComponent; import org.xdty.kindle.di.modules.MainModule; import org.xdty.kindle.module.Book; import org.xdty.kindle.view.BooksAdapter; import java.util.List; import javax.inject.Inject; package org.xdty.kindle; public class MainActivity extends AppCompatActivity implements MainContract.View, NavigationView.OnNavigationItemSelectedListener,
BooksAdapter.ItemClickListener {
xdtianyu/Kindle
app/src/main/java/org/xdty/kindle/MainActivity.java
// Path: app/src/main/java/org/xdty/kindle/contract/MainContract.java // public interface MainContract { // // interface View extends BaseView<Presenter> { // void refresh(List<Book> books); // } // // interface Presenter extends BasePresenter { // void loadBooks(); // // void getBookNodes(Book book); // // void getReviews(String itemId); // // void setMode(Mode mode); // } // } // // Path: app/src/main/java/org/xdty/kindle/data/Mode.java // public enum Mode { // DAILY_DEALS, // FREE_CN, // FREE_EN // } // // Path: app/src/main/java/org/xdty/kindle/di/modules/MainModule.java // @Module // public class MainModule { // // private MainContract.View mView; // // public MainModule(MainContract.View view) { // mView = view; // } // // @Provides // MainContract.View provideView() { // return mView; // } // // @Provides // MainContract.Presenter providePresenter() { // return new MainPresenter(mView); // } // // } // // Path: app/src/main/java/org/xdty/kindle/view/BooksAdapter.java // public class BooksAdapter extends RecyclerView.Adapter<BooksAdapter.ViewHolder> { // // @Inject // RequestManager mGlideRequest; // private List<Book> mBooks = new ArrayList<>(); // private ItemClickListener mItemClickListener; // // public BooksAdapter() { // Application.getAppComponent().inject(this); // } // // @Override // public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { // // View view = LayoutInflater.from(parent.getContext()) // .inflate(R.layout.item_book, parent, false); // // return new ViewHolder(view); // } // // @Override // public void onBindViewHolder(ViewHolder holder, int position) { // holder.bind(mBooks.get(position)); // } // // @Override // public int getItemCount() { // return mBooks.size(); // } // // public void refresh(List<Book> books) { // mBooks.clear(); // mBooks.addAll(books); // notifyDataSetChanged(); // } // // public void setItemClickListener(ItemClickListener itemClickListener) { // mItemClickListener = itemClickListener; // } // // public interface ItemClickListener { // void onItemClick(Book book); // } // // class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener { // // private Book mBook; // // private ImageView thumbnail; // private TextView title; // private TextView author; // private TextView pages; // private TextView price; // // ViewHolder(View view) { // super(view); // // thumbnail = (ImageView) view.findViewById(R.id.thumbnail); // title = (TextView) view.findViewById(R.id.title); // author = (TextView) view.findViewById(R.id.author); // pages = (TextView) view.findViewById(R.id.pages); // price = (TextView) view.findViewById(R.id.price); // view.setOnClickListener(this); // } // // void bind(Book book) { // mBook = book; // title.setText(book.getTitle()); // author.setText(book.getAuthor()); // pages.setText(book.getPages()); // price.setText(getString(R.string.price, book.getPrice())); // // mGlideRequest.load(book.getLargeImageUrl()) // .crossFade() // .into(thumbnail); // } // // String getString(int resId, Object... formatArgs) { // return itemView.getContext().getString(resId, formatArgs); // } // // @Override // public void onClick(View view) { // if (mItemClickListener != null) { // mItemClickListener.onItemClick(mBook); // } // } // } // }
import android.content.Intent; import android.os.Bundle; import android.support.annotation.NonNull; import android.support.design.widget.NavigationView; import android.support.v4.view.GravityCompat; import android.support.v4.widget.DrawerLayout; import android.support.v7.app.ActionBarDrawerToggle; import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.RecyclerView; import android.support.v7.widget.Toolbar; import android.view.Menu; import android.view.MenuItem; import org.xdty.kindle.contract.MainContract; import org.xdty.kindle.data.Mode; import org.xdty.kindle.di.DaggerMainComponent; import org.xdty.kindle.di.modules.MainModule; import org.xdty.kindle.module.Book; import org.xdty.kindle.view.BooksAdapter; import java.util.List; import javax.inject.Inject;
package org.xdty.kindle; public class MainActivity extends AppCompatActivity implements MainContract.View, NavigationView.OnNavigationItemSelectedListener, BooksAdapter.ItemClickListener { private static final String TAG = MainActivity.class.getSimpleName(); @Inject MainContract.Presenter mPresenter; private RecyclerView mRecyclerView; private Toolbar mToolbar; private DrawerLayout mDrawer; private BooksAdapter mBooksAdapter; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); DaggerMainComponent.builder()
// Path: app/src/main/java/org/xdty/kindle/contract/MainContract.java // public interface MainContract { // // interface View extends BaseView<Presenter> { // void refresh(List<Book> books); // } // // interface Presenter extends BasePresenter { // void loadBooks(); // // void getBookNodes(Book book); // // void getReviews(String itemId); // // void setMode(Mode mode); // } // } // // Path: app/src/main/java/org/xdty/kindle/data/Mode.java // public enum Mode { // DAILY_DEALS, // FREE_CN, // FREE_EN // } // // Path: app/src/main/java/org/xdty/kindle/di/modules/MainModule.java // @Module // public class MainModule { // // private MainContract.View mView; // // public MainModule(MainContract.View view) { // mView = view; // } // // @Provides // MainContract.View provideView() { // return mView; // } // // @Provides // MainContract.Presenter providePresenter() { // return new MainPresenter(mView); // } // // } // // Path: app/src/main/java/org/xdty/kindle/view/BooksAdapter.java // public class BooksAdapter extends RecyclerView.Adapter<BooksAdapter.ViewHolder> { // // @Inject // RequestManager mGlideRequest; // private List<Book> mBooks = new ArrayList<>(); // private ItemClickListener mItemClickListener; // // public BooksAdapter() { // Application.getAppComponent().inject(this); // } // // @Override // public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { // // View view = LayoutInflater.from(parent.getContext()) // .inflate(R.layout.item_book, parent, false); // // return new ViewHolder(view); // } // // @Override // public void onBindViewHolder(ViewHolder holder, int position) { // holder.bind(mBooks.get(position)); // } // // @Override // public int getItemCount() { // return mBooks.size(); // } // // public void refresh(List<Book> books) { // mBooks.clear(); // mBooks.addAll(books); // notifyDataSetChanged(); // } // // public void setItemClickListener(ItemClickListener itemClickListener) { // mItemClickListener = itemClickListener; // } // // public interface ItemClickListener { // void onItemClick(Book book); // } // // class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener { // // private Book mBook; // // private ImageView thumbnail; // private TextView title; // private TextView author; // private TextView pages; // private TextView price; // // ViewHolder(View view) { // super(view); // // thumbnail = (ImageView) view.findViewById(R.id.thumbnail); // title = (TextView) view.findViewById(R.id.title); // author = (TextView) view.findViewById(R.id.author); // pages = (TextView) view.findViewById(R.id.pages); // price = (TextView) view.findViewById(R.id.price); // view.setOnClickListener(this); // } // // void bind(Book book) { // mBook = book; // title.setText(book.getTitle()); // author.setText(book.getAuthor()); // pages.setText(book.getPages()); // price.setText(getString(R.string.price, book.getPrice())); // // mGlideRequest.load(book.getLargeImageUrl()) // .crossFade() // .into(thumbnail); // } // // String getString(int resId, Object... formatArgs) { // return itemView.getContext().getString(resId, formatArgs); // } // // @Override // public void onClick(View view) { // if (mItemClickListener != null) { // mItemClickListener.onItemClick(mBook); // } // } // } // } // Path: app/src/main/java/org/xdty/kindle/MainActivity.java import android.content.Intent; import android.os.Bundle; import android.support.annotation.NonNull; import android.support.design.widget.NavigationView; import android.support.v4.view.GravityCompat; import android.support.v4.widget.DrawerLayout; import android.support.v7.app.ActionBarDrawerToggle; import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.RecyclerView; import android.support.v7.widget.Toolbar; import android.view.Menu; import android.view.MenuItem; import org.xdty.kindle.contract.MainContract; import org.xdty.kindle.data.Mode; import org.xdty.kindle.di.DaggerMainComponent; import org.xdty.kindle.di.modules.MainModule; import org.xdty.kindle.module.Book; import org.xdty.kindle.view.BooksAdapter; import java.util.List; import javax.inject.Inject; package org.xdty.kindle; public class MainActivity extends AppCompatActivity implements MainContract.View, NavigationView.OnNavigationItemSelectedListener, BooksAdapter.ItemClickListener { private static final String TAG = MainActivity.class.getSimpleName(); @Inject MainContract.Presenter mPresenter; private RecyclerView mRecyclerView; private Toolbar mToolbar; private DrawerLayout mDrawer; private BooksAdapter mBooksAdapter; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); DaggerMainComponent.builder()
.mainModule(new MainModule(this))
xdtianyu/Kindle
app/src/main/java/org/xdty/kindle/MainActivity.java
// Path: app/src/main/java/org/xdty/kindle/contract/MainContract.java // public interface MainContract { // // interface View extends BaseView<Presenter> { // void refresh(List<Book> books); // } // // interface Presenter extends BasePresenter { // void loadBooks(); // // void getBookNodes(Book book); // // void getReviews(String itemId); // // void setMode(Mode mode); // } // } // // Path: app/src/main/java/org/xdty/kindle/data/Mode.java // public enum Mode { // DAILY_DEALS, // FREE_CN, // FREE_EN // } // // Path: app/src/main/java/org/xdty/kindle/di/modules/MainModule.java // @Module // public class MainModule { // // private MainContract.View mView; // // public MainModule(MainContract.View view) { // mView = view; // } // // @Provides // MainContract.View provideView() { // return mView; // } // // @Provides // MainContract.Presenter providePresenter() { // return new MainPresenter(mView); // } // // } // // Path: app/src/main/java/org/xdty/kindle/view/BooksAdapter.java // public class BooksAdapter extends RecyclerView.Adapter<BooksAdapter.ViewHolder> { // // @Inject // RequestManager mGlideRequest; // private List<Book> mBooks = new ArrayList<>(); // private ItemClickListener mItemClickListener; // // public BooksAdapter() { // Application.getAppComponent().inject(this); // } // // @Override // public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { // // View view = LayoutInflater.from(parent.getContext()) // .inflate(R.layout.item_book, parent, false); // // return new ViewHolder(view); // } // // @Override // public void onBindViewHolder(ViewHolder holder, int position) { // holder.bind(mBooks.get(position)); // } // // @Override // public int getItemCount() { // return mBooks.size(); // } // // public void refresh(List<Book> books) { // mBooks.clear(); // mBooks.addAll(books); // notifyDataSetChanged(); // } // // public void setItemClickListener(ItemClickListener itemClickListener) { // mItemClickListener = itemClickListener; // } // // public interface ItemClickListener { // void onItemClick(Book book); // } // // class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener { // // private Book mBook; // // private ImageView thumbnail; // private TextView title; // private TextView author; // private TextView pages; // private TextView price; // // ViewHolder(View view) { // super(view); // // thumbnail = (ImageView) view.findViewById(R.id.thumbnail); // title = (TextView) view.findViewById(R.id.title); // author = (TextView) view.findViewById(R.id.author); // pages = (TextView) view.findViewById(R.id.pages); // price = (TextView) view.findViewById(R.id.price); // view.setOnClickListener(this); // } // // void bind(Book book) { // mBook = book; // title.setText(book.getTitle()); // author.setText(book.getAuthor()); // pages.setText(book.getPages()); // price.setText(getString(R.string.price, book.getPrice())); // // mGlideRequest.load(book.getLargeImageUrl()) // .crossFade() // .into(thumbnail); // } // // String getString(int resId, Object... formatArgs) { // return itemView.getContext().getString(resId, formatArgs); // } // // @Override // public void onClick(View view) { // if (mItemClickListener != null) { // mItemClickListener.onItemClick(mBook); // } // } // } // }
import android.content.Intent; import android.os.Bundle; import android.support.annotation.NonNull; import android.support.design.widget.NavigationView; import android.support.v4.view.GravityCompat; import android.support.v4.widget.DrawerLayout; import android.support.v7.app.ActionBarDrawerToggle; import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.RecyclerView; import android.support.v7.widget.Toolbar; import android.view.Menu; import android.view.MenuItem; import org.xdty.kindle.contract.MainContract; import org.xdty.kindle.data.Mode; import org.xdty.kindle.di.DaggerMainComponent; import org.xdty.kindle.di.modules.MainModule; import org.xdty.kindle.module.Book; import org.xdty.kindle.view.BooksAdapter; import java.util.List; import javax.inject.Inject;
@Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.main, menu); return true; } @Override public boolean onOptionsItemSelected(MenuItem item) { int id = item.getItemId(); //noinspection SimplifiableIfStatement if (id == R.id.action_settings) { return true; } return super.onOptionsItemSelected(item); } @Override public boolean onNavigationItemSelected(@NonNull MenuItem item) { int id = item.getItemId(); mDrawer.closeDrawer(GravityCompat.START); switch (id) { case R.id.nav_setting: // start setting activity return true; case R.id.nav_free_chinese:
// Path: app/src/main/java/org/xdty/kindle/contract/MainContract.java // public interface MainContract { // // interface View extends BaseView<Presenter> { // void refresh(List<Book> books); // } // // interface Presenter extends BasePresenter { // void loadBooks(); // // void getBookNodes(Book book); // // void getReviews(String itemId); // // void setMode(Mode mode); // } // } // // Path: app/src/main/java/org/xdty/kindle/data/Mode.java // public enum Mode { // DAILY_DEALS, // FREE_CN, // FREE_EN // } // // Path: app/src/main/java/org/xdty/kindle/di/modules/MainModule.java // @Module // public class MainModule { // // private MainContract.View mView; // // public MainModule(MainContract.View view) { // mView = view; // } // // @Provides // MainContract.View provideView() { // return mView; // } // // @Provides // MainContract.Presenter providePresenter() { // return new MainPresenter(mView); // } // // } // // Path: app/src/main/java/org/xdty/kindle/view/BooksAdapter.java // public class BooksAdapter extends RecyclerView.Adapter<BooksAdapter.ViewHolder> { // // @Inject // RequestManager mGlideRequest; // private List<Book> mBooks = new ArrayList<>(); // private ItemClickListener mItemClickListener; // // public BooksAdapter() { // Application.getAppComponent().inject(this); // } // // @Override // public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { // // View view = LayoutInflater.from(parent.getContext()) // .inflate(R.layout.item_book, parent, false); // // return new ViewHolder(view); // } // // @Override // public void onBindViewHolder(ViewHolder holder, int position) { // holder.bind(mBooks.get(position)); // } // // @Override // public int getItemCount() { // return mBooks.size(); // } // // public void refresh(List<Book> books) { // mBooks.clear(); // mBooks.addAll(books); // notifyDataSetChanged(); // } // // public void setItemClickListener(ItemClickListener itemClickListener) { // mItemClickListener = itemClickListener; // } // // public interface ItemClickListener { // void onItemClick(Book book); // } // // class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener { // // private Book mBook; // // private ImageView thumbnail; // private TextView title; // private TextView author; // private TextView pages; // private TextView price; // // ViewHolder(View view) { // super(view); // // thumbnail = (ImageView) view.findViewById(R.id.thumbnail); // title = (TextView) view.findViewById(R.id.title); // author = (TextView) view.findViewById(R.id.author); // pages = (TextView) view.findViewById(R.id.pages); // price = (TextView) view.findViewById(R.id.price); // view.setOnClickListener(this); // } // // void bind(Book book) { // mBook = book; // title.setText(book.getTitle()); // author.setText(book.getAuthor()); // pages.setText(book.getPages()); // price.setText(getString(R.string.price, book.getPrice())); // // mGlideRequest.load(book.getLargeImageUrl()) // .crossFade() // .into(thumbnail); // } // // String getString(int resId, Object... formatArgs) { // return itemView.getContext().getString(resId, formatArgs); // } // // @Override // public void onClick(View view) { // if (mItemClickListener != null) { // mItemClickListener.onItemClick(mBook); // } // } // } // } // Path: app/src/main/java/org/xdty/kindle/MainActivity.java import android.content.Intent; import android.os.Bundle; import android.support.annotation.NonNull; import android.support.design.widget.NavigationView; import android.support.v4.view.GravityCompat; import android.support.v4.widget.DrawerLayout; import android.support.v7.app.ActionBarDrawerToggle; import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.RecyclerView; import android.support.v7.widget.Toolbar; import android.view.Menu; import android.view.MenuItem; import org.xdty.kindle.contract.MainContract; import org.xdty.kindle.data.Mode; import org.xdty.kindle.di.DaggerMainComponent; import org.xdty.kindle.di.modules.MainModule; import org.xdty.kindle.module.Book; import org.xdty.kindle.view.BooksAdapter; import java.util.List; import javax.inject.Inject; @Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.main, menu); return true; } @Override public boolean onOptionsItemSelected(MenuItem item) { int id = item.getItemId(); //noinspection SimplifiableIfStatement if (id == R.id.action_settings) { return true; } return super.onOptionsItemSelected(item); } @Override public boolean onNavigationItemSelected(@NonNull MenuItem item) { int id = item.getItemId(); mDrawer.closeDrawer(GravityCompat.START); switch (id) { case R.id.nav_setting: // start setting activity return true; case R.id.nav_free_chinese:
mPresenter.setMode(Mode.FREE_CN);
xdtianyu/Kindle
app/src/main/java/org/xdty/kindle/di/modules/DetailModule.java
// Path: app/src/main/java/org/xdty/kindle/contract/DetailContract.java // public interface DetailContract { // // interface View extends BaseView<Presenter> { // void updateReview(String review); // // void openTab(String url); // } // // interface Presenter extends BasePresenter { // void start(Book itemId); // // void clickFab(); // } // } // // Path: app/src/main/java/org/xdty/kindle/presenter/DetailPresenter.java // public class DetailPresenter implements DetailContract.Presenter { // // @Inject // BookDataSource mBookDataSource; // private DetailContract.View mView; // private Book mBook; // private Review mReview; // // public DetailPresenter(DetailContract.View view) { // mView = view; // Application.getAppComponent().inject(this); // } // // @Override // public void start() { // // } // // @Override // public void clickFab() { // if (mBook != null) { // mView.openTab(mBook.getUrl()); // } // } // // @Override // public void start(Book book) { // // mBook = book; // // if (book.getEditorialReview() == null) { // mBookDataSource.getReview(book.getItemId()).subscribe(new Action1<Review>() { // @Override // public void call(Review review) { // mReview = review; // mView.updateReview(review.getEditorialReview()); // } // }); // } // } // }
import org.xdty.kindle.contract.DetailContract; import org.xdty.kindle.presenter.DetailPresenter; import dagger.Module; import dagger.Provides;
package org.xdty.kindle.di.modules; @Module public class DetailModule {
// Path: app/src/main/java/org/xdty/kindle/contract/DetailContract.java // public interface DetailContract { // // interface View extends BaseView<Presenter> { // void updateReview(String review); // // void openTab(String url); // } // // interface Presenter extends BasePresenter { // void start(Book itemId); // // void clickFab(); // } // } // // Path: app/src/main/java/org/xdty/kindle/presenter/DetailPresenter.java // public class DetailPresenter implements DetailContract.Presenter { // // @Inject // BookDataSource mBookDataSource; // private DetailContract.View mView; // private Book mBook; // private Review mReview; // // public DetailPresenter(DetailContract.View view) { // mView = view; // Application.getAppComponent().inject(this); // } // // @Override // public void start() { // // } // // @Override // public void clickFab() { // if (mBook != null) { // mView.openTab(mBook.getUrl()); // } // } // // @Override // public void start(Book book) { // // mBook = book; // // if (book.getEditorialReview() == null) { // mBookDataSource.getReview(book.getItemId()).subscribe(new Action1<Review>() { // @Override // public void call(Review review) { // mReview = review; // mView.updateReview(review.getEditorialReview()); // } // }); // } // } // } // Path: app/src/main/java/org/xdty/kindle/di/modules/DetailModule.java import org.xdty.kindle.contract.DetailContract; import org.xdty.kindle.presenter.DetailPresenter; import dagger.Module; import dagger.Provides; package org.xdty.kindle.di.modules; @Module public class DetailModule {
private DetailContract.View mView;
xdtianyu/Kindle
app/src/main/java/org/xdty/kindle/di/modules/DetailModule.java
// Path: app/src/main/java/org/xdty/kindle/contract/DetailContract.java // public interface DetailContract { // // interface View extends BaseView<Presenter> { // void updateReview(String review); // // void openTab(String url); // } // // interface Presenter extends BasePresenter { // void start(Book itemId); // // void clickFab(); // } // } // // Path: app/src/main/java/org/xdty/kindle/presenter/DetailPresenter.java // public class DetailPresenter implements DetailContract.Presenter { // // @Inject // BookDataSource mBookDataSource; // private DetailContract.View mView; // private Book mBook; // private Review mReview; // // public DetailPresenter(DetailContract.View view) { // mView = view; // Application.getAppComponent().inject(this); // } // // @Override // public void start() { // // } // // @Override // public void clickFab() { // if (mBook != null) { // mView.openTab(mBook.getUrl()); // } // } // // @Override // public void start(Book book) { // // mBook = book; // // if (book.getEditorialReview() == null) { // mBookDataSource.getReview(book.getItemId()).subscribe(new Action1<Review>() { // @Override // public void call(Review review) { // mReview = review; // mView.updateReview(review.getEditorialReview()); // } // }); // } // } // }
import org.xdty.kindle.contract.DetailContract; import org.xdty.kindle.presenter.DetailPresenter; import dagger.Module; import dagger.Provides;
package org.xdty.kindle.di.modules; @Module public class DetailModule { private DetailContract.View mView; public DetailModule(DetailContract.View view) { mView = view; } @Provides DetailContract.View provideView() { return mView; } @Provides DetailContract.Presenter providePresenter() {
// Path: app/src/main/java/org/xdty/kindle/contract/DetailContract.java // public interface DetailContract { // // interface View extends BaseView<Presenter> { // void updateReview(String review); // // void openTab(String url); // } // // interface Presenter extends BasePresenter { // void start(Book itemId); // // void clickFab(); // } // } // // Path: app/src/main/java/org/xdty/kindle/presenter/DetailPresenter.java // public class DetailPresenter implements DetailContract.Presenter { // // @Inject // BookDataSource mBookDataSource; // private DetailContract.View mView; // private Book mBook; // private Review mReview; // // public DetailPresenter(DetailContract.View view) { // mView = view; // Application.getAppComponent().inject(this); // } // // @Override // public void start() { // // } // // @Override // public void clickFab() { // if (mBook != null) { // mView.openTab(mBook.getUrl()); // } // } // // @Override // public void start(Book book) { // // mBook = book; // // if (book.getEditorialReview() == null) { // mBookDataSource.getReview(book.getItemId()).subscribe(new Action1<Review>() { // @Override // public void call(Review review) { // mReview = review; // mView.updateReview(review.getEditorialReview()); // } // }); // } // } // } // Path: app/src/main/java/org/xdty/kindle/di/modules/DetailModule.java import org.xdty.kindle.contract.DetailContract; import org.xdty.kindle.presenter.DetailPresenter; import dagger.Module; import dagger.Provides; package org.xdty.kindle.di.modules; @Module public class DetailModule { private DetailContract.View mView; public DetailModule(DetailContract.View view) { mView = view; } @Provides DetailContract.View provideView() { return mView; } @Provides DetailContract.Presenter providePresenter() {
return new DetailPresenter(mView);
xdtianyu/Kindle
app/src/main/java/org/xdty/kindle/presenter/MainPresenter.java
// Path: app/src/main/java/org/xdty/kindle/application/Application.java // public class Application extends android.app.Application { // // private static AppComponent sAppComponent; // // @Override // public void onCreate() { // super.onCreate(); // sAppComponent = DaggerAppComponent.builder().appModule(new AppModule(this)).build(); // } // // public static AppComponent getAppComponent() { // return sAppComponent; // } // // } // // Path: app/src/main/java/org/xdty/kindle/contract/MainContract.java // public interface MainContract { // // interface View extends BaseView<Presenter> { // void refresh(List<Book> books); // } // // interface Presenter extends BasePresenter { // void loadBooks(); // // void getBookNodes(Book book); // // void getReviews(String itemId); // // void setMode(Mode mode); // } // } // // Path: app/src/main/java/org/xdty/kindle/data/BookDataSource.java // public interface BookDataSource { // // Observable<List<Book>> getDailyBooks(); // // Observable<List<Book>> getFreeCnBooks(); // // Observable<List<Book>> getFreeEnBooks(); // // Observable<List<Book>> getBooks(Mode mode); // // Observable<List<Node>> getBookNodes(String itemId); // // Observable<List<Review>> getReviews(String itemId); // // Observable<Review> getReview(String itemId); // // Observable<Book> getBook(String itemId); // } // // Path: app/src/main/java/org/xdty/kindle/data/Mode.java // public enum Mode { // DAILY_DEALS, // FREE_CN, // FREE_EN // }
import android.util.Log; import org.xdty.kindle.application.Application; import org.xdty.kindle.contract.MainContract; import org.xdty.kindle.data.BookDataSource; import org.xdty.kindle.data.Mode; import org.xdty.kindle.module.Book; import org.xdty.kindle.module.Node; import org.xdty.kindle.module.Review; import java.util.List; import javax.inject.Inject; import rx.functions.Action1;
package org.xdty.kindle.presenter; public class MainPresenter implements MainContract.Presenter { private static final String TAG = MainPresenter.class.getSimpleName(); @Inject
// Path: app/src/main/java/org/xdty/kindle/application/Application.java // public class Application extends android.app.Application { // // private static AppComponent sAppComponent; // // @Override // public void onCreate() { // super.onCreate(); // sAppComponent = DaggerAppComponent.builder().appModule(new AppModule(this)).build(); // } // // public static AppComponent getAppComponent() { // return sAppComponent; // } // // } // // Path: app/src/main/java/org/xdty/kindle/contract/MainContract.java // public interface MainContract { // // interface View extends BaseView<Presenter> { // void refresh(List<Book> books); // } // // interface Presenter extends BasePresenter { // void loadBooks(); // // void getBookNodes(Book book); // // void getReviews(String itemId); // // void setMode(Mode mode); // } // } // // Path: app/src/main/java/org/xdty/kindle/data/BookDataSource.java // public interface BookDataSource { // // Observable<List<Book>> getDailyBooks(); // // Observable<List<Book>> getFreeCnBooks(); // // Observable<List<Book>> getFreeEnBooks(); // // Observable<List<Book>> getBooks(Mode mode); // // Observable<List<Node>> getBookNodes(String itemId); // // Observable<List<Review>> getReviews(String itemId); // // Observable<Review> getReview(String itemId); // // Observable<Book> getBook(String itemId); // } // // Path: app/src/main/java/org/xdty/kindle/data/Mode.java // public enum Mode { // DAILY_DEALS, // FREE_CN, // FREE_EN // } // Path: app/src/main/java/org/xdty/kindle/presenter/MainPresenter.java import android.util.Log; import org.xdty.kindle.application.Application; import org.xdty.kindle.contract.MainContract; import org.xdty.kindle.data.BookDataSource; import org.xdty.kindle.data.Mode; import org.xdty.kindle.module.Book; import org.xdty.kindle.module.Node; import org.xdty.kindle.module.Review; import java.util.List; import javax.inject.Inject; import rx.functions.Action1; package org.xdty.kindle.presenter; public class MainPresenter implements MainContract.Presenter { private static final String TAG = MainPresenter.class.getSimpleName(); @Inject
BookDataSource mBookDataSource;
xdtianyu/Kindle
app/src/main/java/org/xdty/kindle/presenter/MainPresenter.java
// Path: app/src/main/java/org/xdty/kindle/application/Application.java // public class Application extends android.app.Application { // // private static AppComponent sAppComponent; // // @Override // public void onCreate() { // super.onCreate(); // sAppComponent = DaggerAppComponent.builder().appModule(new AppModule(this)).build(); // } // // public static AppComponent getAppComponent() { // return sAppComponent; // } // // } // // Path: app/src/main/java/org/xdty/kindle/contract/MainContract.java // public interface MainContract { // // interface View extends BaseView<Presenter> { // void refresh(List<Book> books); // } // // interface Presenter extends BasePresenter { // void loadBooks(); // // void getBookNodes(Book book); // // void getReviews(String itemId); // // void setMode(Mode mode); // } // } // // Path: app/src/main/java/org/xdty/kindle/data/BookDataSource.java // public interface BookDataSource { // // Observable<List<Book>> getDailyBooks(); // // Observable<List<Book>> getFreeCnBooks(); // // Observable<List<Book>> getFreeEnBooks(); // // Observable<List<Book>> getBooks(Mode mode); // // Observable<List<Node>> getBookNodes(String itemId); // // Observable<List<Review>> getReviews(String itemId); // // Observable<Review> getReview(String itemId); // // Observable<Book> getBook(String itemId); // } // // Path: app/src/main/java/org/xdty/kindle/data/Mode.java // public enum Mode { // DAILY_DEALS, // FREE_CN, // FREE_EN // }
import android.util.Log; import org.xdty.kindle.application.Application; import org.xdty.kindle.contract.MainContract; import org.xdty.kindle.data.BookDataSource; import org.xdty.kindle.data.Mode; import org.xdty.kindle.module.Book; import org.xdty.kindle.module.Node; import org.xdty.kindle.module.Review; import java.util.List; import javax.inject.Inject; import rx.functions.Action1;
package org.xdty.kindle.presenter; public class MainPresenter implements MainContract.Presenter { private static final String TAG = MainPresenter.class.getSimpleName(); @Inject BookDataSource mBookDataSource; private MainContract.View mView;
// Path: app/src/main/java/org/xdty/kindle/application/Application.java // public class Application extends android.app.Application { // // private static AppComponent sAppComponent; // // @Override // public void onCreate() { // super.onCreate(); // sAppComponent = DaggerAppComponent.builder().appModule(new AppModule(this)).build(); // } // // public static AppComponent getAppComponent() { // return sAppComponent; // } // // } // // Path: app/src/main/java/org/xdty/kindle/contract/MainContract.java // public interface MainContract { // // interface View extends BaseView<Presenter> { // void refresh(List<Book> books); // } // // interface Presenter extends BasePresenter { // void loadBooks(); // // void getBookNodes(Book book); // // void getReviews(String itemId); // // void setMode(Mode mode); // } // } // // Path: app/src/main/java/org/xdty/kindle/data/BookDataSource.java // public interface BookDataSource { // // Observable<List<Book>> getDailyBooks(); // // Observable<List<Book>> getFreeCnBooks(); // // Observable<List<Book>> getFreeEnBooks(); // // Observable<List<Book>> getBooks(Mode mode); // // Observable<List<Node>> getBookNodes(String itemId); // // Observable<List<Review>> getReviews(String itemId); // // Observable<Review> getReview(String itemId); // // Observable<Book> getBook(String itemId); // } // // Path: app/src/main/java/org/xdty/kindle/data/Mode.java // public enum Mode { // DAILY_DEALS, // FREE_CN, // FREE_EN // } // Path: app/src/main/java/org/xdty/kindle/presenter/MainPresenter.java import android.util.Log; import org.xdty.kindle.application.Application; import org.xdty.kindle.contract.MainContract; import org.xdty.kindle.data.BookDataSource; import org.xdty.kindle.data.Mode; import org.xdty.kindle.module.Book; import org.xdty.kindle.module.Node; import org.xdty.kindle.module.Review; import java.util.List; import javax.inject.Inject; import rx.functions.Action1; package org.xdty.kindle.presenter; public class MainPresenter implements MainContract.Presenter { private static final String TAG = MainPresenter.class.getSimpleName(); @Inject BookDataSource mBookDataSource; private MainContract.View mView;
private Mode mMode = Mode.DAILY_DEALS;
xdtianyu/Kindle
app/src/main/java/org/xdty/kindle/presenter/MainPresenter.java
// Path: app/src/main/java/org/xdty/kindle/application/Application.java // public class Application extends android.app.Application { // // private static AppComponent sAppComponent; // // @Override // public void onCreate() { // super.onCreate(); // sAppComponent = DaggerAppComponent.builder().appModule(new AppModule(this)).build(); // } // // public static AppComponent getAppComponent() { // return sAppComponent; // } // // } // // Path: app/src/main/java/org/xdty/kindle/contract/MainContract.java // public interface MainContract { // // interface View extends BaseView<Presenter> { // void refresh(List<Book> books); // } // // interface Presenter extends BasePresenter { // void loadBooks(); // // void getBookNodes(Book book); // // void getReviews(String itemId); // // void setMode(Mode mode); // } // } // // Path: app/src/main/java/org/xdty/kindle/data/BookDataSource.java // public interface BookDataSource { // // Observable<List<Book>> getDailyBooks(); // // Observable<List<Book>> getFreeCnBooks(); // // Observable<List<Book>> getFreeEnBooks(); // // Observable<List<Book>> getBooks(Mode mode); // // Observable<List<Node>> getBookNodes(String itemId); // // Observable<List<Review>> getReviews(String itemId); // // Observable<Review> getReview(String itemId); // // Observable<Book> getBook(String itemId); // } // // Path: app/src/main/java/org/xdty/kindle/data/Mode.java // public enum Mode { // DAILY_DEALS, // FREE_CN, // FREE_EN // }
import android.util.Log; import org.xdty.kindle.application.Application; import org.xdty.kindle.contract.MainContract; import org.xdty.kindle.data.BookDataSource; import org.xdty.kindle.data.Mode; import org.xdty.kindle.module.Book; import org.xdty.kindle.module.Node; import org.xdty.kindle.module.Review; import java.util.List; import javax.inject.Inject; import rx.functions.Action1;
package org.xdty.kindle.presenter; public class MainPresenter implements MainContract.Presenter { private static final String TAG = MainPresenter.class.getSimpleName(); @Inject BookDataSource mBookDataSource; private MainContract.View mView; private Mode mMode = Mode.DAILY_DEALS; public MainPresenter(MainContract.View view) { mView = view;
// Path: app/src/main/java/org/xdty/kindle/application/Application.java // public class Application extends android.app.Application { // // private static AppComponent sAppComponent; // // @Override // public void onCreate() { // super.onCreate(); // sAppComponent = DaggerAppComponent.builder().appModule(new AppModule(this)).build(); // } // // public static AppComponent getAppComponent() { // return sAppComponent; // } // // } // // Path: app/src/main/java/org/xdty/kindle/contract/MainContract.java // public interface MainContract { // // interface View extends BaseView<Presenter> { // void refresh(List<Book> books); // } // // interface Presenter extends BasePresenter { // void loadBooks(); // // void getBookNodes(Book book); // // void getReviews(String itemId); // // void setMode(Mode mode); // } // } // // Path: app/src/main/java/org/xdty/kindle/data/BookDataSource.java // public interface BookDataSource { // // Observable<List<Book>> getDailyBooks(); // // Observable<List<Book>> getFreeCnBooks(); // // Observable<List<Book>> getFreeEnBooks(); // // Observable<List<Book>> getBooks(Mode mode); // // Observable<List<Node>> getBookNodes(String itemId); // // Observable<List<Review>> getReviews(String itemId); // // Observable<Review> getReview(String itemId); // // Observable<Book> getBook(String itemId); // } // // Path: app/src/main/java/org/xdty/kindle/data/Mode.java // public enum Mode { // DAILY_DEALS, // FREE_CN, // FREE_EN // } // Path: app/src/main/java/org/xdty/kindle/presenter/MainPresenter.java import android.util.Log; import org.xdty.kindle.application.Application; import org.xdty.kindle.contract.MainContract; import org.xdty.kindle.data.BookDataSource; import org.xdty.kindle.data.Mode; import org.xdty.kindle.module.Book; import org.xdty.kindle.module.Node; import org.xdty.kindle.module.Review; import java.util.List; import javax.inject.Inject; import rx.functions.Action1; package org.xdty.kindle.presenter; public class MainPresenter implements MainContract.Presenter { private static final String TAG = MainPresenter.class.getSimpleName(); @Inject BookDataSource mBookDataSource; private MainContract.View mView; private Mode mMode = Mode.DAILY_DEALS; public MainPresenter(MainContract.View view) { mView = view;
Application.getAppComponent().inject(this);
xdtianyu/Kindle
app/src/main/java/org/xdty/kindle/module/database/DatabaseImpl.java
// Path: app/src/main/java/org/xdty/kindle/application/Application.java // public class Application extends android.app.Application { // // private static AppComponent sAppComponent; // // @Override // public void onCreate() { // super.onCreate(); // sAppComponent = DaggerAppComponent.builder().appModule(new AppModule(this)).build(); // } // // public static AppComponent getAppComponent() { // return sAppComponent; // } // // }
import org.xdty.kindle.application.Application; import org.xdty.kindle.module.Book; import org.xdty.kindle.module.Node; import org.xdty.kindle.module.NodeMap; import org.xdty.kindle.module.NodeRelation; import org.xdty.kindle.module.Review; import java.util.List; import javax.inject.Inject; import io.requery.Persistable; import io.requery.sql.EntityDataStore;
package org.xdty.kindle.module.database; public class DatabaseImpl implements Database { private final static int PAGE_SIZE = 50; @Inject EntityDataStore<Persistable> mDataStore; private int mCurrentPage = 0; private DatabaseImpl() {
// Path: app/src/main/java/org/xdty/kindle/application/Application.java // public class Application extends android.app.Application { // // private static AppComponent sAppComponent; // // @Override // public void onCreate() { // super.onCreate(); // sAppComponent = DaggerAppComponent.builder().appModule(new AppModule(this)).build(); // } // // public static AppComponent getAppComponent() { // return sAppComponent; // } // // } // Path: app/src/main/java/org/xdty/kindle/module/database/DatabaseImpl.java import org.xdty.kindle.application.Application; import org.xdty.kindle.module.Book; import org.xdty.kindle.module.Node; import org.xdty.kindle.module.NodeMap; import org.xdty.kindle.module.NodeRelation; import org.xdty.kindle.module.Review; import java.util.List; import javax.inject.Inject; import io.requery.Persistable; import io.requery.sql.EntityDataStore; package org.xdty.kindle.module.database; public class DatabaseImpl implements Database { private final static int PAGE_SIZE = 50; @Inject EntityDataStore<Persistable> mDataStore; private int mCurrentPage = 0; private DatabaseImpl() {
Application.getAppComponent().inject(this);
xdtianyu/Kindle
app/src/main/java/org/xdty/kindle/application/Application.java
// Path: app/src/main/java/org/xdty/kindle/di/AppComponent.java // @Singleton // @Component(modules = AppModule.class) // public interface AppComponent { // // void inject(BookRepository bookRepository); // // void inject(DatabaseImpl database); // // void inject(BooksAdapter booksAdapter); // // void inject(MainPresenter mainPresenter); // // void inject(DetailPresenter detailPresenter); // } // // Path: app/src/main/java/org/xdty/kindle/di/modules/AppModule.java // @Module // public class AppModule { // private static final String TAG = AppModule.class.getSimpleName(); // // private Application app; // private OkHttpClient mOkHttpClient; // // public AppModule(Application application) { // app = application; // // HttpLoggingInterceptor loggingInterceptor = new HttpLoggingInterceptor(); // loggingInterceptor.setLevel(HttpLoggingInterceptor.Level.BASIC); // // Interceptor interceptor = new Interceptor() { // @Override // public Response intercept(Chain chain) throws IOException { // Request request = chain.request(); // HttpUrl url = request.url() // .newBuilder() // .addQueryParameter("timestamp", // Long.toString(System.currentTimeMillis() / 1000 / 60)) // .build(); // request = request.newBuilder().url(url).build(); // return chain.proceed(request); // } // }; // // mOkHttpClient = new OkHttpClient.Builder() // .addInterceptor(loggingInterceptor) // .addInterceptor(interceptor) // .build(); // } // // @Singleton // @Provides // public Application provideApplication() { // return app; // } // // @Singleton // @Provides // public BookDataSource provideBookDataSource() { // return new BookRepository(); // } // // @Singleton // @Provides // public OkHttpClient provideOkHttpClient() { // return mOkHttpClient; // } // // @Singleton // @Provides // public BookService provideBookService() { // Retrofit retrofit = new Retrofit.Builder() // .baseUrl(Constants.BASE_URL) // .client(mOkHttpClient) // .addConverterFactory(GsonConverterFactory.create(new GsonBuilder() // .setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES) // .create())) // .build(); // return retrofit.create(BookService.class); // } // // @Singleton // @Provides // public Database provideDatabase() { // return DatabaseImpl.getInstance(); // } // // @Singleton // @Provides // public EntityDataStore<Persistable> provideDatabaseSource() { // Observable.<Void>just(null).observeOn(Schedulers.io()).subscribe(new Action1<Void>() { // @Override // public void call(Void aVoid) { // raw2data(app, DB_NAME, R.raw.books); // } // }); // // DatabaseSource source = new DatabaseSource(app, Models.DEFAULT, DB_NAME, DB_VERSION); // source.setLoggingEnabled(BuildConfig.DEBUG); // Configuration configuration = source.getConfiguration(); // // return new EntityDataStore<>(configuration); // } // // @Singleton // @Provides // public RequestManager provideGlide() { // OkHttpUrlLoader.Factory factory = new OkHttpUrlLoader.Factory(mOkHttpClient); // Glide.get(app).register(GlideUrl.class, InputStream.class, factory); // return Glide.with(app); // } // // private void raw2data(Context context, String filename, int raw) { // // try { // InputStream inputStream = context.getResources().openRawResource(raw); // // File cacheFile = context.getDatabasePath(filename); // // if (cacheFile.exists()) { // if (cacheFile.length() == inputStream.available()) { // return; // } else if (!cacheFile.delete()) { // Log.d(TAG, "cache file delete failed."); // } else { // Log.d(TAG, "update cached database."); // } // } // // File parent = cacheFile.getParentFile(); // if (!parent.exists() && !parent.mkdirs()) { // Log.d(TAG, "database directory create failed."); // } // // FileOutputStream fileOutputStream = new FileOutputStream(cacheFile); // // int bufferSize = 1024; // byte[] buffer = new byte[bufferSize]; // int length; // while ((length = inputStream.read(buffer)) > 0) { // fileOutputStream.write(buffer, 0, length); // } // fileOutputStream.close(); // inputStream.close(); // } catch (IOException e) { // e.printStackTrace(); // } // } // // }
import org.xdty.kindle.di.AppComponent; import org.xdty.kindle.di.DaggerAppComponent; import org.xdty.kindle.di.modules.AppModule;
package org.xdty.kindle.application; public class Application extends android.app.Application { private static AppComponent sAppComponent; @Override public void onCreate() { super.onCreate();
// Path: app/src/main/java/org/xdty/kindle/di/AppComponent.java // @Singleton // @Component(modules = AppModule.class) // public interface AppComponent { // // void inject(BookRepository bookRepository); // // void inject(DatabaseImpl database); // // void inject(BooksAdapter booksAdapter); // // void inject(MainPresenter mainPresenter); // // void inject(DetailPresenter detailPresenter); // } // // Path: app/src/main/java/org/xdty/kindle/di/modules/AppModule.java // @Module // public class AppModule { // private static final String TAG = AppModule.class.getSimpleName(); // // private Application app; // private OkHttpClient mOkHttpClient; // // public AppModule(Application application) { // app = application; // // HttpLoggingInterceptor loggingInterceptor = new HttpLoggingInterceptor(); // loggingInterceptor.setLevel(HttpLoggingInterceptor.Level.BASIC); // // Interceptor interceptor = new Interceptor() { // @Override // public Response intercept(Chain chain) throws IOException { // Request request = chain.request(); // HttpUrl url = request.url() // .newBuilder() // .addQueryParameter("timestamp", // Long.toString(System.currentTimeMillis() / 1000 / 60)) // .build(); // request = request.newBuilder().url(url).build(); // return chain.proceed(request); // } // }; // // mOkHttpClient = new OkHttpClient.Builder() // .addInterceptor(loggingInterceptor) // .addInterceptor(interceptor) // .build(); // } // // @Singleton // @Provides // public Application provideApplication() { // return app; // } // // @Singleton // @Provides // public BookDataSource provideBookDataSource() { // return new BookRepository(); // } // // @Singleton // @Provides // public OkHttpClient provideOkHttpClient() { // return mOkHttpClient; // } // // @Singleton // @Provides // public BookService provideBookService() { // Retrofit retrofit = new Retrofit.Builder() // .baseUrl(Constants.BASE_URL) // .client(mOkHttpClient) // .addConverterFactory(GsonConverterFactory.create(new GsonBuilder() // .setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES) // .create())) // .build(); // return retrofit.create(BookService.class); // } // // @Singleton // @Provides // public Database provideDatabase() { // return DatabaseImpl.getInstance(); // } // // @Singleton // @Provides // public EntityDataStore<Persistable> provideDatabaseSource() { // Observable.<Void>just(null).observeOn(Schedulers.io()).subscribe(new Action1<Void>() { // @Override // public void call(Void aVoid) { // raw2data(app, DB_NAME, R.raw.books); // } // }); // // DatabaseSource source = new DatabaseSource(app, Models.DEFAULT, DB_NAME, DB_VERSION); // source.setLoggingEnabled(BuildConfig.DEBUG); // Configuration configuration = source.getConfiguration(); // // return new EntityDataStore<>(configuration); // } // // @Singleton // @Provides // public RequestManager provideGlide() { // OkHttpUrlLoader.Factory factory = new OkHttpUrlLoader.Factory(mOkHttpClient); // Glide.get(app).register(GlideUrl.class, InputStream.class, factory); // return Glide.with(app); // } // // private void raw2data(Context context, String filename, int raw) { // // try { // InputStream inputStream = context.getResources().openRawResource(raw); // // File cacheFile = context.getDatabasePath(filename); // // if (cacheFile.exists()) { // if (cacheFile.length() == inputStream.available()) { // return; // } else if (!cacheFile.delete()) { // Log.d(TAG, "cache file delete failed."); // } else { // Log.d(TAG, "update cached database."); // } // } // // File parent = cacheFile.getParentFile(); // if (!parent.exists() && !parent.mkdirs()) { // Log.d(TAG, "database directory create failed."); // } // // FileOutputStream fileOutputStream = new FileOutputStream(cacheFile); // // int bufferSize = 1024; // byte[] buffer = new byte[bufferSize]; // int length; // while ((length = inputStream.read(buffer)) > 0) { // fileOutputStream.write(buffer, 0, length); // } // fileOutputStream.close(); // inputStream.close(); // } catch (IOException e) { // e.printStackTrace(); // } // } // // } // Path: app/src/main/java/org/xdty/kindle/application/Application.java import org.xdty.kindle.di.AppComponent; import org.xdty.kindle.di.DaggerAppComponent; import org.xdty.kindle.di.modules.AppModule; package org.xdty.kindle.application; public class Application extends android.app.Application { private static AppComponent sAppComponent; @Override public void onCreate() { super.onCreate();
sAppComponent = DaggerAppComponent.builder().appModule(new AppModule(this)).build();
xdtianyu/Kindle
app/src/main/java/org/xdty/kindle/data/BookService.java
// Path: app/src/main/java/org/xdty/kindle/module/Books.java // public class Books { // // private List<Book> books; // private String time; // private long timestamp; // // public List<Book> getBooks() { // return books; // } // // public void setBooks(List<Book> books) { // this.books = books; // } // // public String getTime() { // return time; // } // // public void setTime(String time) { // this.time = time; // } // // public long getTimestamp() { // return timestamp; // } // // public void setTimestamp(long timestamp) { // this.timestamp = timestamp; // } // }
import org.xdty.kindle.module.Books; import retrofit2.Call; import retrofit2.http.GET;
package org.xdty.kindle.data; public interface BookService { @GET("kindle.json")
// Path: app/src/main/java/org/xdty/kindle/module/Books.java // public class Books { // // private List<Book> books; // private String time; // private long timestamp; // // public List<Book> getBooks() { // return books; // } // // public void setBooks(List<Book> books) { // this.books = books; // } // // public String getTime() { // return time; // } // // public void setTime(String time) { // this.time = time; // } // // public long getTimestamp() { // return timestamp; // } // // public void setTimestamp(long timestamp) { // this.timestamp = timestamp; // } // } // Path: app/src/main/java/org/xdty/kindle/data/BookService.java import org.xdty.kindle.module.Books; import retrofit2.Call; import retrofit2.http.GET; package org.xdty.kindle.data; public interface BookService { @GET("kindle.json")
Call<Books> getBooks();
xdtianyu/Kindle
app/src/main/java/org/xdty/kindle/presenter/DetailPresenter.java
// Path: app/src/main/java/org/xdty/kindle/application/Application.java // public class Application extends android.app.Application { // // private static AppComponent sAppComponent; // // @Override // public void onCreate() { // super.onCreate(); // sAppComponent = DaggerAppComponent.builder().appModule(new AppModule(this)).build(); // } // // public static AppComponent getAppComponent() { // return sAppComponent; // } // // } // // Path: app/src/main/java/org/xdty/kindle/contract/DetailContract.java // public interface DetailContract { // // interface View extends BaseView<Presenter> { // void updateReview(String review); // // void openTab(String url); // } // // interface Presenter extends BasePresenter { // void start(Book itemId); // // void clickFab(); // } // } // // Path: app/src/main/java/org/xdty/kindle/data/BookDataSource.java // public interface BookDataSource { // // Observable<List<Book>> getDailyBooks(); // // Observable<List<Book>> getFreeCnBooks(); // // Observable<List<Book>> getFreeEnBooks(); // // Observable<List<Book>> getBooks(Mode mode); // // Observable<List<Node>> getBookNodes(String itemId); // // Observable<List<Review>> getReviews(String itemId); // // Observable<Review> getReview(String itemId); // // Observable<Book> getBook(String itemId); // }
import org.xdty.kindle.application.Application; import org.xdty.kindle.contract.DetailContract; import org.xdty.kindle.data.BookDataSource; import org.xdty.kindle.module.Book; import org.xdty.kindle.module.Review; import javax.inject.Inject; import rx.functions.Action1;
package org.xdty.kindle.presenter; public class DetailPresenter implements DetailContract.Presenter { @Inject
// Path: app/src/main/java/org/xdty/kindle/application/Application.java // public class Application extends android.app.Application { // // private static AppComponent sAppComponent; // // @Override // public void onCreate() { // super.onCreate(); // sAppComponent = DaggerAppComponent.builder().appModule(new AppModule(this)).build(); // } // // public static AppComponent getAppComponent() { // return sAppComponent; // } // // } // // Path: app/src/main/java/org/xdty/kindle/contract/DetailContract.java // public interface DetailContract { // // interface View extends BaseView<Presenter> { // void updateReview(String review); // // void openTab(String url); // } // // interface Presenter extends BasePresenter { // void start(Book itemId); // // void clickFab(); // } // } // // Path: app/src/main/java/org/xdty/kindle/data/BookDataSource.java // public interface BookDataSource { // // Observable<List<Book>> getDailyBooks(); // // Observable<List<Book>> getFreeCnBooks(); // // Observable<List<Book>> getFreeEnBooks(); // // Observable<List<Book>> getBooks(Mode mode); // // Observable<List<Node>> getBookNodes(String itemId); // // Observable<List<Review>> getReviews(String itemId); // // Observable<Review> getReview(String itemId); // // Observable<Book> getBook(String itemId); // } // Path: app/src/main/java/org/xdty/kindle/presenter/DetailPresenter.java import org.xdty.kindle.application.Application; import org.xdty.kindle.contract.DetailContract; import org.xdty.kindle.data.BookDataSource; import org.xdty.kindle.module.Book; import org.xdty.kindle.module.Review; import javax.inject.Inject; import rx.functions.Action1; package org.xdty.kindle.presenter; public class DetailPresenter implements DetailContract.Presenter { @Inject
BookDataSource mBookDataSource;
xdtianyu/Kindle
app/src/main/java/org/xdty/kindle/presenter/DetailPresenter.java
// Path: app/src/main/java/org/xdty/kindle/application/Application.java // public class Application extends android.app.Application { // // private static AppComponent sAppComponent; // // @Override // public void onCreate() { // super.onCreate(); // sAppComponent = DaggerAppComponent.builder().appModule(new AppModule(this)).build(); // } // // public static AppComponent getAppComponent() { // return sAppComponent; // } // // } // // Path: app/src/main/java/org/xdty/kindle/contract/DetailContract.java // public interface DetailContract { // // interface View extends BaseView<Presenter> { // void updateReview(String review); // // void openTab(String url); // } // // interface Presenter extends BasePresenter { // void start(Book itemId); // // void clickFab(); // } // } // // Path: app/src/main/java/org/xdty/kindle/data/BookDataSource.java // public interface BookDataSource { // // Observable<List<Book>> getDailyBooks(); // // Observable<List<Book>> getFreeCnBooks(); // // Observable<List<Book>> getFreeEnBooks(); // // Observable<List<Book>> getBooks(Mode mode); // // Observable<List<Node>> getBookNodes(String itemId); // // Observable<List<Review>> getReviews(String itemId); // // Observable<Review> getReview(String itemId); // // Observable<Book> getBook(String itemId); // }
import org.xdty.kindle.application.Application; import org.xdty.kindle.contract.DetailContract; import org.xdty.kindle.data.BookDataSource; import org.xdty.kindle.module.Book; import org.xdty.kindle.module.Review; import javax.inject.Inject; import rx.functions.Action1;
package org.xdty.kindle.presenter; public class DetailPresenter implements DetailContract.Presenter { @Inject BookDataSource mBookDataSource; private DetailContract.View mView; private Book mBook; private Review mReview; public DetailPresenter(DetailContract.View view) { mView = view;
// Path: app/src/main/java/org/xdty/kindle/application/Application.java // public class Application extends android.app.Application { // // private static AppComponent sAppComponent; // // @Override // public void onCreate() { // super.onCreate(); // sAppComponent = DaggerAppComponent.builder().appModule(new AppModule(this)).build(); // } // // public static AppComponent getAppComponent() { // return sAppComponent; // } // // } // // Path: app/src/main/java/org/xdty/kindle/contract/DetailContract.java // public interface DetailContract { // // interface View extends BaseView<Presenter> { // void updateReview(String review); // // void openTab(String url); // } // // interface Presenter extends BasePresenter { // void start(Book itemId); // // void clickFab(); // } // } // // Path: app/src/main/java/org/xdty/kindle/data/BookDataSource.java // public interface BookDataSource { // // Observable<List<Book>> getDailyBooks(); // // Observable<List<Book>> getFreeCnBooks(); // // Observable<List<Book>> getFreeEnBooks(); // // Observable<List<Book>> getBooks(Mode mode); // // Observable<List<Node>> getBookNodes(String itemId); // // Observable<List<Review>> getReviews(String itemId); // // Observable<Review> getReview(String itemId); // // Observable<Book> getBook(String itemId); // } // Path: app/src/main/java/org/xdty/kindle/presenter/DetailPresenter.java import org.xdty.kindle.application.Application; import org.xdty.kindle.contract.DetailContract; import org.xdty.kindle.data.BookDataSource; import org.xdty.kindle.module.Book; import org.xdty.kindle.module.Review; import javax.inject.Inject; import rx.functions.Action1; package org.xdty.kindle.presenter; public class DetailPresenter implements DetailContract.Presenter { @Inject BookDataSource mBookDataSource; private DetailContract.View mView; private Book mBook; private Review mReview; public DetailPresenter(DetailContract.View view) { mView = view;
Application.getAppComponent().inject(this);
xdtianyu/Kindle
app/src/main/java/org/xdty/kindle/contract/MainContract.java
// Path: app/src/main/java/org/xdty/kindle/data/Mode.java // public enum Mode { // DAILY_DEALS, // FREE_CN, // FREE_EN // }
import org.xdty.kindle.data.Mode; import org.xdty.kindle.module.Book; import java.util.List;
package org.xdty.kindle.contract; public interface MainContract { interface View extends BaseView<Presenter> { void refresh(List<Book> books); } interface Presenter extends BasePresenter { void loadBooks(); void getBookNodes(Book book); void getReviews(String itemId);
// Path: app/src/main/java/org/xdty/kindle/data/Mode.java // public enum Mode { // DAILY_DEALS, // FREE_CN, // FREE_EN // } // Path: app/src/main/java/org/xdty/kindle/contract/MainContract.java import org.xdty.kindle.data.Mode; import org.xdty.kindle.module.Book; import java.util.List; package org.xdty.kindle.contract; public interface MainContract { interface View extends BaseView<Presenter> { void refresh(List<Book> books); } interface Presenter extends BasePresenter { void loadBooks(); void getBookNodes(Book book); void getReviews(String itemId);
void setMode(Mode mode);
xdtianyu/Kindle
app/src/main/java/org/xdty/kindle/view/BooksAdapter.java
// Path: app/src/main/java/org/xdty/kindle/application/Application.java // public class Application extends android.app.Application { // // private static AppComponent sAppComponent; // // @Override // public void onCreate() { // super.onCreate(); // sAppComponent = DaggerAppComponent.builder().appModule(new AppModule(this)).build(); // } // // public static AppComponent getAppComponent() { // return sAppComponent; // } // // }
import android.support.v7.widget.RecyclerView; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ImageView; import android.widget.TextView; import com.bumptech.glide.RequestManager; import org.xdty.kindle.R; import org.xdty.kindle.application.Application; import org.xdty.kindle.module.Book; import java.util.ArrayList; import java.util.List; import javax.inject.Inject;
package org.xdty.kindle.view; public class BooksAdapter extends RecyclerView.Adapter<BooksAdapter.ViewHolder> { @Inject RequestManager mGlideRequest; private List<Book> mBooks = new ArrayList<>(); private ItemClickListener mItemClickListener; public BooksAdapter() {
// Path: app/src/main/java/org/xdty/kindle/application/Application.java // public class Application extends android.app.Application { // // private static AppComponent sAppComponent; // // @Override // public void onCreate() { // super.onCreate(); // sAppComponent = DaggerAppComponent.builder().appModule(new AppModule(this)).build(); // } // // public static AppComponent getAppComponent() { // return sAppComponent; // } // // } // Path: app/src/main/java/org/xdty/kindle/view/BooksAdapter.java import android.support.v7.widget.RecyclerView; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ImageView; import android.widget.TextView; import com.bumptech.glide.RequestManager; import org.xdty.kindle.R; import org.xdty.kindle.application.Application; import org.xdty.kindle.module.Book; import java.util.ArrayList; import java.util.List; import javax.inject.Inject; package org.xdty.kindle.view; public class BooksAdapter extends RecyclerView.Adapter<BooksAdapter.ViewHolder> { @Inject RequestManager mGlideRequest; private List<Book> mBooks = new ArrayList<>(); private ItemClickListener mItemClickListener; public BooksAdapter() {
Application.getAppComponent().inject(this);
xdtianyu/Kindle
app/src/main/java/org/xdty/kindle/DetailActivity.java
// Path: app/src/main/java/org/xdty/kindle/contract/DetailContract.java // public interface DetailContract { // // interface View extends BaseView<Presenter> { // void updateReview(String review); // // void openTab(String url); // } // // interface Presenter extends BasePresenter { // void start(Book itemId); // // void clickFab(); // } // } // // Path: app/src/main/java/org/xdty/kindle/di/modules/DetailModule.java // @Module // public class DetailModule { // // private DetailContract.View mView; // // public DetailModule(DetailContract.View view) { // mView = view; // } // // @Provides // DetailContract.View provideView() { // return mView; // } // // @Provides // DetailContract.Presenter providePresenter() { // return new DetailPresenter(mView); // } // // }
import android.net.Uri; import android.os.Build; import android.os.Bundle; import android.support.customtabs.CustomTabsIntent; import android.support.design.widget.FloatingActionButton; import android.support.v4.content.ContextCompat; import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.Toolbar; import android.text.Html; import android.view.View; import android.widget.TextView; import org.xdty.kindle.contract.DetailContract; import org.xdty.kindle.di.DaggerDetailComponent; import org.xdty.kindle.di.modules.DetailModule; import org.xdty.kindle.module.Book; import javax.inject.Inject; import static org.xdty.kindle.R.id.review;
package org.xdty.kindle; public class DetailActivity extends AppCompatActivity implements DetailContract.View { public final static String ARG_BOOK = "book"; private static final String TAG = DetailActivity.class.getSimpleName(); @Inject DetailContract.Presenter mPresenter; private TextView mReviewText; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState);
// Path: app/src/main/java/org/xdty/kindle/contract/DetailContract.java // public interface DetailContract { // // interface View extends BaseView<Presenter> { // void updateReview(String review); // // void openTab(String url); // } // // interface Presenter extends BasePresenter { // void start(Book itemId); // // void clickFab(); // } // } // // Path: app/src/main/java/org/xdty/kindle/di/modules/DetailModule.java // @Module // public class DetailModule { // // private DetailContract.View mView; // // public DetailModule(DetailContract.View view) { // mView = view; // } // // @Provides // DetailContract.View provideView() { // return mView; // } // // @Provides // DetailContract.Presenter providePresenter() { // return new DetailPresenter(mView); // } // // } // Path: app/src/main/java/org/xdty/kindle/DetailActivity.java import android.net.Uri; import android.os.Build; import android.os.Bundle; import android.support.customtabs.CustomTabsIntent; import android.support.design.widget.FloatingActionButton; import android.support.v4.content.ContextCompat; import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.Toolbar; import android.text.Html; import android.view.View; import android.widget.TextView; import org.xdty.kindle.contract.DetailContract; import org.xdty.kindle.di.DaggerDetailComponent; import org.xdty.kindle.di.modules.DetailModule; import org.xdty.kindle.module.Book; import javax.inject.Inject; import static org.xdty.kindle.R.id.review; package org.xdty.kindle; public class DetailActivity extends AppCompatActivity implements DetailContract.View { public final static String ARG_BOOK = "book"; private static final String TAG = DetailActivity.class.getSimpleName(); @Inject DetailContract.Presenter mPresenter; private TextView mReviewText; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState);
DaggerDetailComponent.builder().detailModule(new DetailModule(this))
OvercastNetwork/Tracker
src/main/java/tc/oc/tracker/event/EntityDamageEvent.java
// Path: src/main/java/tc/oc/tracker/Damage.java // public interface Damage { // /** // * Gets the amount of damage that was inflicted. // * // * Note that this is the raw damage in half-hearts before dampeners (armor, // * potion effects) are applied. // * // * Contract specifies that the result is 0 or greater. // * // * @return Amount of damage inflicted // */ // int getDamage(); // // /** // * Gets the location where the damage occurred. // * // * Contract specifies that the result is never null. // * // * @return Location of damage // */ // @Nonnull Location getLocation(); // // /** // * Gets the time that the damage occurred. // * // * Contract specifies that the result is never null. // * // * @return Time of damage // */ // @Nonnull Instant getTime(); // // /** // * Gets additional information regarding this damage. // * // * @return {@link DamageInfo} subclass describing the damage in more detail // */ // @Nonnull DamageInfo getInfo(); // } // // Path: src/main/java/tc/oc/tracker/DamageInfo.java // public interface DamageInfo { // /** // * Gets the living entity most responsible for this damage. // * // * @return Resolved damager or null if none exists // */ // @Nullable LivingEntity getResolvedDamager(); // } // // Path: src/main/java/tc/oc/tracker/Lifetime.java // public interface Lifetime { // @Nullable Instant getStart(); // // void setStart(@Nonnull Instant start); // // @Nullable Instant getEnd(); // // void setEnd(@Nonnull Instant end); // // @Nonnull List<Damage> getDamage(); // // @Nonnull ListIterator<Damage> getDamageFirst(); // // @Nonnull ListIterator<Damage> getDamageLast(); // // @Nullable Damage getFirstDamage(); // // @Nullable Damage getLastDamage(); // // /** // * Gets the last damage instance where the info object is an instance of // * the specified class. Uses {@link Class#isInstance(Object)} to check info // * objects. // * // * @param damageInfoClass DamageInfo class to check for // * @return Last damage that matched or null if none matched // * // * @throws NullPointerException if damageInfoClass is null // */ // @Nullable Damage getLastDamage(@Nonnull Class<? extends DamageInfo> damageInfoClass); // // void addDamage(@Nonnull Damage damage); // } // // Path: src/main/java/tc/oc/tracker/base/SimpleDamage.java // public class SimpleDamage implements Damage { // public SimpleDamage(int damage, @Nonnull Location location, @Nonnull Instant time, @Nonnull DamageInfo info) { // Preconditions.checkArgument(damage >= 0, "damage must be greater than or equal to zero"); // Preconditions.checkNotNull(location, "location"); // Preconditions.checkNotNull(time, "time"); // Preconditions.checkNotNull(info, "info"); // // this.damage = damage; // this.location = location; // this.time = time; // this.info = info; // } // // public int getDamage() { // return this.damage; // } // // public @Nonnull Location getLocation() { // return this.location; // } // // public @Nonnull Instant getTime() { // return this.time; // } // // public @Nonnull DamageInfo getInfo() { // return this.info; // } // // private final int damage; // private final @Nonnull Location location; // private final @Nonnull Instant time; // private final @Nonnull DamageInfo info; // }
import javax.annotation.Nonnull; import org.bukkit.Location; import org.bukkit.entity.LivingEntity; import org.bukkit.event.Cancellable; import org.bukkit.event.Event; import org.bukkit.event.HandlerList; import org.joda.time.Instant; import tc.oc.tracker.Damage; import tc.oc.tracker.DamageInfo; import tc.oc.tracker.Lifetime; import tc.oc.tracker.base.SimpleDamage; import com.google.common.base.Preconditions;
package tc.oc.tracker.event; /** * Called when an entity undergoes some type of damage. */ public class EntityDamageEvent extends Event implements Cancellable { private final @Nonnull LivingEntity entity;
// Path: src/main/java/tc/oc/tracker/Damage.java // public interface Damage { // /** // * Gets the amount of damage that was inflicted. // * // * Note that this is the raw damage in half-hearts before dampeners (armor, // * potion effects) are applied. // * // * Contract specifies that the result is 0 or greater. // * // * @return Amount of damage inflicted // */ // int getDamage(); // // /** // * Gets the location where the damage occurred. // * // * Contract specifies that the result is never null. // * // * @return Location of damage // */ // @Nonnull Location getLocation(); // // /** // * Gets the time that the damage occurred. // * // * Contract specifies that the result is never null. // * // * @return Time of damage // */ // @Nonnull Instant getTime(); // // /** // * Gets additional information regarding this damage. // * // * @return {@link DamageInfo} subclass describing the damage in more detail // */ // @Nonnull DamageInfo getInfo(); // } // // Path: src/main/java/tc/oc/tracker/DamageInfo.java // public interface DamageInfo { // /** // * Gets the living entity most responsible for this damage. // * // * @return Resolved damager or null if none exists // */ // @Nullable LivingEntity getResolvedDamager(); // } // // Path: src/main/java/tc/oc/tracker/Lifetime.java // public interface Lifetime { // @Nullable Instant getStart(); // // void setStart(@Nonnull Instant start); // // @Nullable Instant getEnd(); // // void setEnd(@Nonnull Instant end); // // @Nonnull List<Damage> getDamage(); // // @Nonnull ListIterator<Damage> getDamageFirst(); // // @Nonnull ListIterator<Damage> getDamageLast(); // // @Nullable Damage getFirstDamage(); // // @Nullable Damage getLastDamage(); // // /** // * Gets the last damage instance where the info object is an instance of // * the specified class. Uses {@link Class#isInstance(Object)} to check info // * objects. // * // * @param damageInfoClass DamageInfo class to check for // * @return Last damage that matched or null if none matched // * // * @throws NullPointerException if damageInfoClass is null // */ // @Nullable Damage getLastDamage(@Nonnull Class<? extends DamageInfo> damageInfoClass); // // void addDamage(@Nonnull Damage damage); // } // // Path: src/main/java/tc/oc/tracker/base/SimpleDamage.java // public class SimpleDamage implements Damage { // public SimpleDamage(int damage, @Nonnull Location location, @Nonnull Instant time, @Nonnull DamageInfo info) { // Preconditions.checkArgument(damage >= 0, "damage must be greater than or equal to zero"); // Preconditions.checkNotNull(location, "location"); // Preconditions.checkNotNull(time, "time"); // Preconditions.checkNotNull(info, "info"); // // this.damage = damage; // this.location = location; // this.time = time; // this.info = info; // } // // public int getDamage() { // return this.damage; // } // // public @Nonnull Location getLocation() { // return this.location; // } // // public @Nonnull Instant getTime() { // return this.time; // } // // public @Nonnull DamageInfo getInfo() { // return this.info; // } // // private final int damage; // private final @Nonnull Location location; // private final @Nonnull Instant time; // private final @Nonnull DamageInfo info; // } // Path: src/main/java/tc/oc/tracker/event/EntityDamageEvent.java import javax.annotation.Nonnull; import org.bukkit.Location; import org.bukkit.entity.LivingEntity; import org.bukkit.event.Cancellable; import org.bukkit.event.Event; import org.bukkit.event.HandlerList; import org.joda.time.Instant; import tc.oc.tracker.Damage; import tc.oc.tracker.DamageInfo; import tc.oc.tracker.Lifetime; import tc.oc.tracker.base.SimpleDamage; import com.google.common.base.Preconditions; package tc.oc.tracker.event; /** * Called when an entity undergoes some type of damage. */ public class EntityDamageEvent extends Event implements Cancellable { private final @Nonnull LivingEntity entity;
private final @Nonnull Lifetime lifetime;
OvercastNetwork/Tracker
src/main/java/tc/oc/tracker/event/EntityDamageEvent.java
// Path: src/main/java/tc/oc/tracker/Damage.java // public interface Damage { // /** // * Gets the amount of damage that was inflicted. // * // * Note that this is the raw damage in half-hearts before dampeners (armor, // * potion effects) are applied. // * // * Contract specifies that the result is 0 or greater. // * // * @return Amount of damage inflicted // */ // int getDamage(); // // /** // * Gets the location where the damage occurred. // * // * Contract specifies that the result is never null. // * // * @return Location of damage // */ // @Nonnull Location getLocation(); // // /** // * Gets the time that the damage occurred. // * // * Contract specifies that the result is never null. // * // * @return Time of damage // */ // @Nonnull Instant getTime(); // // /** // * Gets additional information regarding this damage. // * // * @return {@link DamageInfo} subclass describing the damage in more detail // */ // @Nonnull DamageInfo getInfo(); // } // // Path: src/main/java/tc/oc/tracker/DamageInfo.java // public interface DamageInfo { // /** // * Gets the living entity most responsible for this damage. // * // * @return Resolved damager or null if none exists // */ // @Nullable LivingEntity getResolvedDamager(); // } // // Path: src/main/java/tc/oc/tracker/Lifetime.java // public interface Lifetime { // @Nullable Instant getStart(); // // void setStart(@Nonnull Instant start); // // @Nullable Instant getEnd(); // // void setEnd(@Nonnull Instant end); // // @Nonnull List<Damage> getDamage(); // // @Nonnull ListIterator<Damage> getDamageFirst(); // // @Nonnull ListIterator<Damage> getDamageLast(); // // @Nullable Damage getFirstDamage(); // // @Nullable Damage getLastDamage(); // // /** // * Gets the last damage instance where the info object is an instance of // * the specified class. Uses {@link Class#isInstance(Object)} to check info // * objects. // * // * @param damageInfoClass DamageInfo class to check for // * @return Last damage that matched or null if none matched // * // * @throws NullPointerException if damageInfoClass is null // */ // @Nullable Damage getLastDamage(@Nonnull Class<? extends DamageInfo> damageInfoClass); // // void addDamage(@Nonnull Damage damage); // } // // Path: src/main/java/tc/oc/tracker/base/SimpleDamage.java // public class SimpleDamage implements Damage { // public SimpleDamage(int damage, @Nonnull Location location, @Nonnull Instant time, @Nonnull DamageInfo info) { // Preconditions.checkArgument(damage >= 0, "damage must be greater than or equal to zero"); // Preconditions.checkNotNull(location, "location"); // Preconditions.checkNotNull(time, "time"); // Preconditions.checkNotNull(info, "info"); // // this.damage = damage; // this.location = location; // this.time = time; // this.info = info; // } // // public int getDamage() { // return this.damage; // } // // public @Nonnull Location getLocation() { // return this.location; // } // // public @Nonnull Instant getTime() { // return this.time; // } // // public @Nonnull DamageInfo getInfo() { // return this.info; // } // // private final int damage; // private final @Nonnull Location location; // private final @Nonnull Instant time; // private final @Nonnull DamageInfo info; // }
import javax.annotation.Nonnull; import org.bukkit.Location; import org.bukkit.entity.LivingEntity; import org.bukkit.event.Cancellable; import org.bukkit.event.Event; import org.bukkit.event.HandlerList; import org.joda.time.Instant; import tc.oc.tracker.Damage; import tc.oc.tracker.DamageInfo; import tc.oc.tracker.Lifetime; import tc.oc.tracker.base.SimpleDamage; import com.google.common.base.Preconditions;
package tc.oc.tracker.event; /** * Called when an entity undergoes some type of damage. */ public class EntityDamageEvent extends Event implements Cancellable { private final @Nonnull LivingEntity entity; private final @Nonnull Lifetime lifetime; private int damage; private final @Nonnull Location location; private final @Nonnull Instant time;
// Path: src/main/java/tc/oc/tracker/Damage.java // public interface Damage { // /** // * Gets the amount of damage that was inflicted. // * // * Note that this is the raw damage in half-hearts before dampeners (armor, // * potion effects) are applied. // * // * Contract specifies that the result is 0 or greater. // * // * @return Amount of damage inflicted // */ // int getDamage(); // // /** // * Gets the location where the damage occurred. // * // * Contract specifies that the result is never null. // * // * @return Location of damage // */ // @Nonnull Location getLocation(); // // /** // * Gets the time that the damage occurred. // * // * Contract specifies that the result is never null. // * // * @return Time of damage // */ // @Nonnull Instant getTime(); // // /** // * Gets additional information regarding this damage. // * // * @return {@link DamageInfo} subclass describing the damage in more detail // */ // @Nonnull DamageInfo getInfo(); // } // // Path: src/main/java/tc/oc/tracker/DamageInfo.java // public interface DamageInfo { // /** // * Gets the living entity most responsible for this damage. // * // * @return Resolved damager or null if none exists // */ // @Nullable LivingEntity getResolvedDamager(); // } // // Path: src/main/java/tc/oc/tracker/Lifetime.java // public interface Lifetime { // @Nullable Instant getStart(); // // void setStart(@Nonnull Instant start); // // @Nullable Instant getEnd(); // // void setEnd(@Nonnull Instant end); // // @Nonnull List<Damage> getDamage(); // // @Nonnull ListIterator<Damage> getDamageFirst(); // // @Nonnull ListIterator<Damage> getDamageLast(); // // @Nullable Damage getFirstDamage(); // // @Nullable Damage getLastDamage(); // // /** // * Gets the last damage instance where the info object is an instance of // * the specified class. Uses {@link Class#isInstance(Object)} to check info // * objects. // * // * @param damageInfoClass DamageInfo class to check for // * @return Last damage that matched or null if none matched // * // * @throws NullPointerException if damageInfoClass is null // */ // @Nullable Damage getLastDamage(@Nonnull Class<? extends DamageInfo> damageInfoClass); // // void addDamage(@Nonnull Damage damage); // } // // Path: src/main/java/tc/oc/tracker/base/SimpleDamage.java // public class SimpleDamage implements Damage { // public SimpleDamage(int damage, @Nonnull Location location, @Nonnull Instant time, @Nonnull DamageInfo info) { // Preconditions.checkArgument(damage >= 0, "damage must be greater than or equal to zero"); // Preconditions.checkNotNull(location, "location"); // Preconditions.checkNotNull(time, "time"); // Preconditions.checkNotNull(info, "info"); // // this.damage = damage; // this.location = location; // this.time = time; // this.info = info; // } // // public int getDamage() { // return this.damage; // } // // public @Nonnull Location getLocation() { // return this.location; // } // // public @Nonnull Instant getTime() { // return this.time; // } // // public @Nonnull DamageInfo getInfo() { // return this.info; // } // // private final int damage; // private final @Nonnull Location location; // private final @Nonnull Instant time; // private final @Nonnull DamageInfo info; // } // Path: src/main/java/tc/oc/tracker/event/EntityDamageEvent.java import javax.annotation.Nonnull; import org.bukkit.Location; import org.bukkit.entity.LivingEntity; import org.bukkit.event.Cancellable; import org.bukkit.event.Event; import org.bukkit.event.HandlerList; import org.joda.time.Instant; import tc.oc.tracker.Damage; import tc.oc.tracker.DamageInfo; import tc.oc.tracker.Lifetime; import tc.oc.tracker.base.SimpleDamage; import com.google.common.base.Preconditions; package tc.oc.tracker.event; /** * Called when an entity undergoes some type of damage. */ public class EntityDamageEvent extends Event implements Cancellable { private final @Nonnull LivingEntity entity; private final @Nonnull Lifetime lifetime; private int damage; private final @Nonnull Location location; private final @Nonnull Instant time;
private final @Nonnull DamageInfo info;
OvercastNetwork/Tracker
src/main/java/tc/oc/tracker/event/EntityDamageEvent.java
// Path: src/main/java/tc/oc/tracker/Damage.java // public interface Damage { // /** // * Gets the amount of damage that was inflicted. // * // * Note that this is the raw damage in half-hearts before dampeners (armor, // * potion effects) are applied. // * // * Contract specifies that the result is 0 or greater. // * // * @return Amount of damage inflicted // */ // int getDamage(); // // /** // * Gets the location where the damage occurred. // * // * Contract specifies that the result is never null. // * // * @return Location of damage // */ // @Nonnull Location getLocation(); // // /** // * Gets the time that the damage occurred. // * // * Contract specifies that the result is never null. // * // * @return Time of damage // */ // @Nonnull Instant getTime(); // // /** // * Gets additional information regarding this damage. // * // * @return {@link DamageInfo} subclass describing the damage in more detail // */ // @Nonnull DamageInfo getInfo(); // } // // Path: src/main/java/tc/oc/tracker/DamageInfo.java // public interface DamageInfo { // /** // * Gets the living entity most responsible for this damage. // * // * @return Resolved damager or null if none exists // */ // @Nullable LivingEntity getResolvedDamager(); // } // // Path: src/main/java/tc/oc/tracker/Lifetime.java // public interface Lifetime { // @Nullable Instant getStart(); // // void setStart(@Nonnull Instant start); // // @Nullable Instant getEnd(); // // void setEnd(@Nonnull Instant end); // // @Nonnull List<Damage> getDamage(); // // @Nonnull ListIterator<Damage> getDamageFirst(); // // @Nonnull ListIterator<Damage> getDamageLast(); // // @Nullable Damage getFirstDamage(); // // @Nullable Damage getLastDamage(); // // /** // * Gets the last damage instance where the info object is an instance of // * the specified class. Uses {@link Class#isInstance(Object)} to check info // * objects. // * // * @param damageInfoClass DamageInfo class to check for // * @return Last damage that matched or null if none matched // * // * @throws NullPointerException if damageInfoClass is null // */ // @Nullable Damage getLastDamage(@Nonnull Class<? extends DamageInfo> damageInfoClass); // // void addDamage(@Nonnull Damage damage); // } // // Path: src/main/java/tc/oc/tracker/base/SimpleDamage.java // public class SimpleDamage implements Damage { // public SimpleDamage(int damage, @Nonnull Location location, @Nonnull Instant time, @Nonnull DamageInfo info) { // Preconditions.checkArgument(damage >= 0, "damage must be greater than or equal to zero"); // Preconditions.checkNotNull(location, "location"); // Preconditions.checkNotNull(time, "time"); // Preconditions.checkNotNull(info, "info"); // // this.damage = damage; // this.location = location; // this.time = time; // this.info = info; // } // // public int getDamage() { // return this.damage; // } // // public @Nonnull Location getLocation() { // return this.location; // } // // public @Nonnull Instant getTime() { // return this.time; // } // // public @Nonnull DamageInfo getInfo() { // return this.info; // } // // private final int damage; // private final @Nonnull Location location; // private final @Nonnull Instant time; // private final @Nonnull DamageInfo info; // }
import javax.annotation.Nonnull; import org.bukkit.Location; import org.bukkit.entity.LivingEntity; import org.bukkit.event.Cancellable; import org.bukkit.event.Event; import org.bukkit.event.HandlerList; import org.joda.time.Instant; import tc.oc.tracker.Damage; import tc.oc.tracker.DamageInfo; import tc.oc.tracker.Lifetime; import tc.oc.tracker.base.SimpleDamage; import com.google.common.base.Preconditions;
public @Nonnull LivingEntity getEntity() { return this.entity; } public @Nonnull Lifetime getLifetime() { return this.lifetime; } public int getDamage() { return this.damage; } public void setDamage(int damage) { Preconditions.checkArgument(damage >= 0, "damage must be greater than or equal to zero"); this.damage = damage; } public @Nonnull Location getLocation() { return this.location; } public @Nonnull Instant getTime() { return this.time; } public @Nonnull DamageInfo getInfo() { return this.info; }
// Path: src/main/java/tc/oc/tracker/Damage.java // public interface Damage { // /** // * Gets the amount of damage that was inflicted. // * // * Note that this is the raw damage in half-hearts before dampeners (armor, // * potion effects) are applied. // * // * Contract specifies that the result is 0 or greater. // * // * @return Amount of damage inflicted // */ // int getDamage(); // // /** // * Gets the location where the damage occurred. // * // * Contract specifies that the result is never null. // * // * @return Location of damage // */ // @Nonnull Location getLocation(); // // /** // * Gets the time that the damage occurred. // * // * Contract specifies that the result is never null. // * // * @return Time of damage // */ // @Nonnull Instant getTime(); // // /** // * Gets additional information regarding this damage. // * // * @return {@link DamageInfo} subclass describing the damage in more detail // */ // @Nonnull DamageInfo getInfo(); // } // // Path: src/main/java/tc/oc/tracker/DamageInfo.java // public interface DamageInfo { // /** // * Gets the living entity most responsible for this damage. // * // * @return Resolved damager or null if none exists // */ // @Nullable LivingEntity getResolvedDamager(); // } // // Path: src/main/java/tc/oc/tracker/Lifetime.java // public interface Lifetime { // @Nullable Instant getStart(); // // void setStart(@Nonnull Instant start); // // @Nullable Instant getEnd(); // // void setEnd(@Nonnull Instant end); // // @Nonnull List<Damage> getDamage(); // // @Nonnull ListIterator<Damage> getDamageFirst(); // // @Nonnull ListIterator<Damage> getDamageLast(); // // @Nullable Damage getFirstDamage(); // // @Nullable Damage getLastDamage(); // // /** // * Gets the last damage instance where the info object is an instance of // * the specified class. Uses {@link Class#isInstance(Object)} to check info // * objects. // * // * @param damageInfoClass DamageInfo class to check for // * @return Last damage that matched or null if none matched // * // * @throws NullPointerException if damageInfoClass is null // */ // @Nullable Damage getLastDamage(@Nonnull Class<? extends DamageInfo> damageInfoClass); // // void addDamage(@Nonnull Damage damage); // } // // Path: src/main/java/tc/oc/tracker/base/SimpleDamage.java // public class SimpleDamage implements Damage { // public SimpleDamage(int damage, @Nonnull Location location, @Nonnull Instant time, @Nonnull DamageInfo info) { // Preconditions.checkArgument(damage >= 0, "damage must be greater than or equal to zero"); // Preconditions.checkNotNull(location, "location"); // Preconditions.checkNotNull(time, "time"); // Preconditions.checkNotNull(info, "info"); // // this.damage = damage; // this.location = location; // this.time = time; // this.info = info; // } // // public int getDamage() { // return this.damage; // } // // public @Nonnull Location getLocation() { // return this.location; // } // // public @Nonnull Instant getTime() { // return this.time; // } // // public @Nonnull DamageInfo getInfo() { // return this.info; // } // // private final int damage; // private final @Nonnull Location location; // private final @Nonnull Instant time; // private final @Nonnull DamageInfo info; // } // Path: src/main/java/tc/oc/tracker/event/EntityDamageEvent.java import javax.annotation.Nonnull; import org.bukkit.Location; import org.bukkit.entity.LivingEntity; import org.bukkit.event.Cancellable; import org.bukkit.event.Event; import org.bukkit.event.HandlerList; import org.joda.time.Instant; import tc.oc.tracker.Damage; import tc.oc.tracker.DamageInfo; import tc.oc.tracker.Lifetime; import tc.oc.tracker.base.SimpleDamage; import com.google.common.base.Preconditions; public @Nonnull LivingEntity getEntity() { return this.entity; } public @Nonnull Lifetime getLifetime() { return this.lifetime; } public int getDamage() { return this.damage; } public void setDamage(int damage) { Preconditions.checkArgument(damage >= 0, "damage must be greater than or equal to zero"); this.damage = damage; } public @Nonnull Location getLocation() { return this.location; } public @Nonnull Instant getTime() { return this.time; } public @Nonnull DamageInfo getInfo() { return this.info; }
public @Nonnull Damage toDamageObject() {
OvercastNetwork/Tracker
src/main/java/tc/oc/tracker/event/EntityDamageEvent.java
// Path: src/main/java/tc/oc/tracker/Damage.java // public interface Damage { // /** // * Gets the amount of damage that was inflicted. // * // * Note that this is the raw damage in half-hearts before dampeners (armor, // * potion effects) are applied. // * // * Contract specifies that the result is 0 or greater. // * // * @return Amount of damage inflicted // */ // int getDamage(); // // /** // * Gets the location where the damage occurred. // * // * Contract specifies that the result is never null. // * // * @return Location of damage // */ // @Nonnull Location getLocation(); // // /** // * Gets the time that the damage occurred. // * // * Contract specifies that the result is never null. // * // * @return Time of damage // */ // @Nonnull Instant getTime(); // // /** // * Gets additional information regarding this damage. // * // * @return {@link DamageInfo} subclass describing the damage in more detail // */ // @Nonnull DamageInfo getInfo(); // } // // Path: src/main/java/tc/oc/tracker/DamageInfo.java // public interface DamageInfo { // /** // * Gets the living entity most responsible for this damage. // * // * @return Resolved damager or null if none exists // */ // @Nullable LivingEntity getResolvedDamager(); // } // // Path: src/main/java/tc/oc/tracker/Lifetime.java // public interface Lifetime { // @Nullable Instant getStart(); // // void setStart(@Nonnull Instant start); // // @Nullable Instant getEnd(); // // void setEnd(@Nonnull Instant end); // // @Nonnull List<Damage> getDamage(); // // @Nonnull ListIterator<Damage> getDamageFirst(); // // @Nonnull ListIterator<Damage> getDamageLast(); // // @Nullable Damage getFirstDamage(); // // @Nullable Damage getLastDamage(); // // /** // * Gets the last damage instance where the info object is an instance of // * the specified class. Uses {@link Class#isInstance(Object)} to check info // * objects. // * // * @param damageInfoClass DamageInfo class to check for // * @return Last damage that matched or null if none matched // * // * @throws NullPointerException if damageInfoClass is null // */ // @Nullable Damage getLastDamage(@Nonnull Class<? extends DamageInfo> damageInfoClass); // // void addDamage(@Nonnull Damage damage); // } // // Path: src/main/java/tc/oc/tracker/base/SimpleDamage.java // public class SimpleDamage implements Damage { // public SimpleDamage(int damage, @Nonnull Location location, @Nonnull Instant time, @Nonnull DamageInfo info) { // Preconditions.checkArgument(damage >= 0, "damage must be greater than or equal to zero"); // Preconditions.checkNotNull(location, "location"); // Preconditions.checkNotNull(time, "time"); // Preconditions.checkNotNull(info, "info"); // // this.damage = damage; // this.location = location; // this.time = time; // this.info = info; // } // // public int getDamage() { // return this.damage; // } // // public @Nonnull Location getLocation() { // return this.location; // } // // public @Nonnull Instant getTime() { // return this.time; // } // // public @Nonnull DamageInfo getInfo() { // return this.info; // } // // private final int damage; // private final @Nonnull Location location; // private final @Nonnull Instant time; // private final @Nonnull DamageInfo info; // }
import javax.annotation.Nonnull; import org.bukkit.Location; import org.bukkit.entity.LivingEntity; import org.bukkit.event.Cancellable; import org.bukkit.event.Event; import org.bukkit.event.HandlerList; import org.joda.time.Instant; import tc.oc.tracker.Damage; import tc.oc.tracker.DamageInfo; import tc.oc.tracker.Lifetime; import tc.oc.tracker.base.SimpleDamage; import com.google.common.base.Preconditions;
return this.entity; } public @Nonnull Lifetime getLifetime() { return this.lifetime; } public int getDamage() { return this.damage; } public void setDamage(int damage) { Preconditions.checkArgument(damage >= 0, "damage must be greater than or equal to zero"); this.damage = damage; } public @Nonnull Location getLocation() { return this.location; } public @Nonnull Instant getTime() { return this.time; } public @Nonnull DamageInfo getInfo() { return this.info; } public @Nonnull Damage toDamageObject() {
// Path: src/main/java/tc/oc/tracker/Damage.java // public interface Damage { // /** // * Gets the amount of damage that was inflicted. // * // * Note that this is the raw damage in half-hearts before dampeners (armor, // * potion effects) are applied. // * // * Contract specifies that the result is 0 or greater. // * // * @return Amount of damage inflicted // */ // int getDamage(); // // /** // * Gets the location where the damage occurred. // * // * Contract specifies that the result is never null. // * // * @return Location of damage // */ // @Nonnull Location getLocation(); // // /** // * Gets the time that the damage occurred. // * // * Contract specifies that the result is never null. // * // * @return Time of damage // */ // @Nonnull Instant getTime(); // // /** // * Gets additional information regarding this damage. // * // * @return {@link DamageInfo} subclass describing the damage in more detail // */ // @Nonnull DamageInfo getInfo(); // } // // Path: src/main/java/tc/oc/tracker/DamageInfo.java // public interface DamageInfo { // /** // * Gets the living entity most responsible for this damage. // * // * @return Resolved damager or null if none exists // */ // @Nullable LivingEntity getResolvedDamager(); // } // // Path: src/main/java/tc/oc/tracker/Lifetime.java // public interface Lifetime { // @Nullable Instant getStart(); // // void setStart(@Nonnull Instant start); // // @Nullable Instant getEnd(); // // void setEnd(@Nonnull Instant end); // // @Nonnull List<Damage> getDamage(); // // @Nonnull ListIterator<Damage> getDamageFirst(); // // @Nonnull ListIterator<Damage> getDamageLast(); // // @Nullable Damage getFirstDamage(); // // @Nullable Damage getLastDamage(); // // /** // * Gets the last damage instance where the info object is an instance of // * the specified class. Uses {@link Class#isInstance(Object)} to check info // * objects. // * // * @param damageInfoClass DamageInfo class to check for // * @return Last damage that matched or null if none matched // * // * @throws NullPointerException if damageInfoClass is null // */ // @Nullable Damage getLastDamage(@Nonnull Class<? extends DamageInfo> damageInfoClass); // // void addDamage(@Nonnull Damage damage); // } // // Path: src/main/java/tc/oc/tracker/base/SimpleDamage.java // public class SimpleDamage implements Damage { // public SimpleDamage(int damage, @Nonnull Location location, @Nonnull Instant time, @Nonnull DamageInfo info) { // Preconditions.checkArgument(damage >= 0, "damage must be greater than or equal to zero"); // Preconditions.checkNotNull(location, "location"); // Preconditions.checkNotNull(time, "time"); // Preconditions.checkNotNull(info, "info"); // // this.damage = damage; // this.location = location; // this.time = time; // this.info = info; // } // // public int getDamage() { // return this.damage; // } // // public @Nonnull Location getLocation() { // return this.location; // } // // public @Nonnull Instant getTime() { // return this.time; // } // // public @Nonnull DamageInfo getInfo() { // return this.info; // } // // private final int damage; // private final @Nonnull Location location; // private final @Nonnull Instant time; // private final @Nonnull DamageInfo info; // } // Path: src/main/java/tc/oc/tracker/event/EntityDamageEvent.java import javax.annotation.Nonnull; import org.bukkit.Location; import org.bukkit.entity.LivingEntity; import org.bukkit.event.Cancellable; import org.bukkit.event.Event; import org.bukkit.event.HandlerList; import org.joda.time.Instant; import tc.oc.tracker.Damage; import tc.oc.tracker.DamageInfo; import tc.oc.tracker.Lifetime; import tc.oc.tracker.base.SimpleDamage; import com.google.common.base.Preconditions; return this.entity; } public @Nonnull Lifetime getLifetime() { return this.lifetime; } public int getDamage() { return this.damage; } public void setDamage(int damage) { Preconditions.checkArgument(damage >= 0, "damage must be greater than or equal to zero"); this.damage = damage; } public @Nonnull Location getLocation() { return this.location; } public @Nonnull Instant getTime() { return this.time; } public @Nonnull DamageInfo getInfo() { return this.info; } public @Nonnull Damage toDamageObject() {
return new SimpleDamage(this.damage, this.location, this.time, this.info);
OvercastNetwork/Tracker
src/main/java/tc/oc/tracker/Lifetimes.java
// Path: src/main/java/tc/oc/tracker/base/SimpleLifetimeManager.java // public class SimpleLifetimeManager implements LifetimeManager { // public @Nonnull Lifetime getLifetime(@Nonnull LivingEntity entity) { // Preconditions.checkNotNull(entity, "entity"); // // Lifetime lifetime = this.lifetimes.get(entity); // if(lifetime == null) { // lifetime = new SimpleLifetime(); // this.lifetimes.put(entity, lifetime); // } // // return lifetime; // } // // public @Nonnull Lifetime setLifetime(@Nonnull LivingEntity entity, @Nonnull Lifetime lifetime) { // Preconditions.checkNotNull(entity, "entity"); // Preconditions.checkNotNull(lifetime, "lifetime"); // // Lifetime old = this.lifetimes.put(entity, lifetime); // if(old != null) { // return old; // } else { // return new SimpleLifetime(); // } // } // // public @Nonnull Lifetime newLifetime(@Nonnull LivingEntity entity) { // Preconditions.checkNotNull(entity, "entity"); // // Lifetime lifetime = new SimpleLifetime(); // this.lifetimes.put(entity, lifetime); // // return lifetime; // } // // public @Nonnull Lifetime endLifetime(@Nonnull LivingEntity entity) { // Preconditions.checkNotNull(entity, "entity"); // // Lifetime old = this.lifetimes.remove(entity); // if(old != null) { // return old; // } else { // return new SimpleLifetime(); // } // } // // private final Map<LivingEntity, Lifetime> lifetimes = new WeakHashMap<LivingEntity, Lifetime>(); // }
import javax.annotation.Nonnull; import javax.annotation.Nullable; import org.bukkit.entity.LivingEntity; import tc.oc.tracker.base.SimpleLifetimeManager;
package tc.oc.tracker; public final class Lifetimes { private Lifetimes() { } public static @Nonnull LifetimeManager getManager() { if(manager == null) {
// Path: src/main/java/tc/oc/tracker/base/SimpleLifetimeManager.java // public class SimpleLifetimeManager implements LifetimeManager { // public @Nonnull Lifetime getLifetime(@Nonnull LivingEntity entity) { // Preconditions.checkNotNull(entity, "entity"); // // Lifetime lifetime = this.lifetimes.get(entity); // if(lifetime == null) { // lifetime = new SimpleLifetime(); // this.lifetimes.put(entity, lifetime); // } // // return lifetime; // } // // public @Nonnull Lifetime setLifetime(@Nonnull LivingEntity entity, @Nonnull Lifetime lifetime) { // Preconditions.checkNotNull(entity, "entity"); // Preconditions.checkNotNull(lifetime, "lifetime"); // // Lifetime old = this.lifetimes.put(entity, lifetime); // if(old != null) { // return old; // } else { // return new SimpleLifetime(); // } // } // // public @Nonnull Lifetime newLifetime(@Nonnull LivingEntity entity) { // Preconditions.checkNotNull(entity, "entity"); // // Lifetime lifetime = new SimpleLifetime(); // this.lifetimes.put(entity, lifetime); // // return lifetime; // } // // public @Nonnull Lifetime endLifetime(@Nonnull LivingEntity entity) { // Preconditions.checkNotNull(entity, "entity"); // // Lifetime old = this.lifetimes.remove(entity); // if(old != null) { // return old; // } else { // return new SimpleLifetime(); // } // } // // private final Map<LivingEntity, Lifetime> lifetimes = new WeakHashMap<LivingEntity, Lifetime>(); // } // Path: src/main/java/tc/oc/tracker/Lifetimes.java import javax.annotation.Nonnull; import javax.annotation.Nullable; import org.bukkit.entity.LivingEntity; import tc.oc.tracker.base.SimpleLifetimeManager; package tc.oc.tracker; public final class Lifetimes { private Lifetimes() { } public static @Nonnull LifetimeManager getManager() { if(manager == null) {
manager = new SimpleLifetimeManager();
OvercastNetwork/Tracker
src/main/java/tc/oc/tracker/damage/resolvers/LavaDamageResolver.java
// Path: src/main/java/tc/oc/tracker/DamageInfo.java // public interface DamageInfo { // /** // * Gets the living entity most responsible for this damage. // * // * @return Resolved damager or null if none exists // */ // @Nullable LivingEntity getResolvedDamager(); // } // // Path: src/main/java/tc/oc/tracker/DamageResolver.java // public interface DamageResolver { // @Nullable DamageInfo resolve(@Nonnull LivingEntity entity, @Nonnull Lifetime lifetime, @Nonnull EntityDamageEvent damageEvent); // } // // Path: src/main/java/tc/oc/tracker/Lifetime.java // public interface Lifetime { // @Nullable Instant getStart(); // // void setStart(@Nonnull Instant start); // // @Nullable Instant getEnd(); // // void setEnd(@Nonnull Instant end); // // @Nonnull List<Damage> getDamage(); // // @Nonnull ListIterator<Damage> getDamageFirst(); // // @Nonnull ListIterator<Damage> getDamageLast(); // // @Nullable Damage getFirstDamage(); // // @Nullable Damage getLastDamage(); // // /** // * Gets the last damage instance where the info object is an instance of // * the specified class. Uses {@link Class#isInstance(Object)} to check info // * objects. // * // * @param damageInfoClass DamageInfo class to check for // * @return Last damage that matched or null if none matched // * // * @throws NullPointerException if damageInfoClass is null // */ // @Nullable Damage getLastDamage(@Nonnull Class<? extends DamageInfo> damageInfoClass); // // void addDamage(@Nonnull Damage damage); // } // // Path: src/main/java/tc/oc/tracker/damage/base/SimpleLavaDamageInfo.java // public class SimpleLavaDamageInfo extends AbstractDamageInfo implements LavaDamageInfo { // public SimpleLavaDamageInfo(@Nullable LivingEntity resolvedDamager) { // super(resolvedDamager); // } // }
import javax.annotation.Nonnull; import javax.annotation.Nullable; import org.bukkit.entity.LivingEntity; import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import tc.oc.tracker.DamageInfo; import tc.oc.tracker.DamageResolver; import tc.oc.tracker.Lifetime; import tc.oc.tracker.damage.base.SimpleLavaDamageInfo;
package tc.oc.tracker.damage.resolvers; public class LavaDamageResolver implements DamageResolver { public @Nullable DamageInfo resolve(@Nonnull LivingEntity entity, @Nonnull Lifetime lifetime, @Nonnull EntityDamageEvent damageEvent) { if(damageEvent.getCause() == DamageCause.LAVA) {
// Path: src/main/java/tc/oc/tracker/DamageInfo.java // public interface DamageInfo { // /** // * Gets the living entity most responsible for this damage. // * // * @return Resolved damager or null if none exists // */ // @Nullable LivingEntity getResolvedDamager(); // } // // Path: src/main/java/tc/oc/tracker/DamageResolver.java // public interface DamageResolver { // @Nullable DamageInfo resolve(@Nonnull LivingEntity entity, @Nonnull Lifetime lifetime, @Nonnull EntityDamageEvent damageEvent); // } // // Path: src/main/java/tc/oc/tracker/Lifetime.java // public interface Lifetime { // @Nullable Instant getStart(); // // void setStart(@Nonnull Instant start); // // @Nullable Instant getEnd(); // // void setEnd(@Nonnull Instant end); // // @Nonnull List<Damage> getDamage(); // // @Nonnull ListIterator<Damage> getDamageFirst(); // // @Nonnull ListIterator<Damage> getDamageLast(); // // @Nullable Damage getFirstDamage(); // // @Nullable Damage getLastDamage(); // // /** // * Gets the last damage instance where the info object is an instance of // * the specified class. Uses {@link Class#isInstance(Object)} to check info // * objects. // * // * @param damageInfoClass DamageInfo class to check for // * @return Last damage that matched or null if none matched // * // * @throws NullPointerException if damageInfoClass is null // */ // @Nullable Damage getLastDamage(@Nonnull Class<? extends DamageInfo> damageInfoClass); // // void addDamage(@Nonnull Damage damage); // } // // Path: src/main/java/tc/oc/tracker/damage/base/SimpleLavaDamageInfo.java // public class SimpleLavaDamageInfo extends AbstractDamageInfo implements LavaDamageInfo { // public SimpleLavaDamageInfo(@Nullable LivingEntity resolvedDamager) { // super(resolvedDamager); // } // } // Path: src/main/java/tc/oc/tracker/damage/resolvers/LavaDamageResolver.java import javax.annotation.Nonnull; import javax.annotation.Nullable; import org.bukkit.entity.LivingEntity; import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import tc.oc.tracker.DamageInfo; import tc.oc.tracker.DamageResolver; import tc.oc.tracker.Lifetime; import tc.oc.tracker.damage.base.SimpleLavaDamageInfo; package tc.oc.tracker.damage.resolvers; public class LavaDamageResolver implements DamageResolver { public @Nullable DamageInfo resolve(@Nonnull LivingEntity entity, @Nonnull Lifetime lifetime, @Nonnull EntityDamageEvent damageEvent) { if(damageEvent.getCause() == DamageCause.LAVA) {
return new SimpleLavaDamageInfo(null);
OvercastNetwork/Tracker
src/main/java/tc/oc/tracker/damage/resolvers/OwnedMobDamageResolver.java
// Path: src/main/java/tc/oc/tracker/DamageInfo.java // public interface DamageInfo { // /** // * Gets the living entity most responsible for this damage. // * // * @return Resolved damager or null if none exists // */ // @Nullable LivingEntity getResolvedDamager(); // } // // Path: src/main/java/tc/oc/tracker/DamageResolver.java // public interface DamageResolver { // @Nullable DamageInfo resolve(@Nonnull LivingEntity entity, @Nonnull Lifetime lifetime, @Nonnull EntityDamageEvent damageEvent); // } // // Path: src/main/java/tc/oc/tracker/Lifetime.java // public interface Lifetime { // @Nullable Instant getStart(); // // void setStart(@Nonnull Instant start); // // @Nullable Instant getEnd(); // // void setEnd(@Nonnull Instant end); // // @Nonnull List<Damage> getDamage(); // // @Nonnull ListIterator<Damage> getDamageFirst(); // // @Nonnull ListIterator<Damage> getDamageLast(); // // @Nullable Damage getFirstDamage(); // // @Nullable Damage getLastDamage(); // // /** // * Gets the last damage instance where the info object is an instance of // * the specified class. Uses {@link Class#isInstance(Object)} to check info // * objects. // * // * @param damageInfoClass DamageInfo class to check for // * @return Last damage that matched or null if none matched // * // * @throws NullPointerException if damageInfoClass is null // */ // @Nullable Damage getLastDamage(@Nonnull Class<? extends DamageInfo> damageInfoClass); // // void addDamage(@Nonnull Damage damage); // } // // Path: src/main/java/tc/oc/tracker/damage/OwnedMobDamageInfo.java // public class OwnedMobDamageInfo extends AbstractDamageInfo { // public OwnedMobDamageInfo(@Nullable LivingEntity resolvedDamager, @Nullable Player mobOwner, @Nullable Projectile projectile) { // super(resolvedDamager); // // this.mobOwner = mobOwner; // this.projectile = projectile; // } // // public @Nullable Player getMobOwner() { // return this.mobOwner; // } // // public @Nullable Projectile getProjectile() { // return this.projectile; // } // // protected final @Nullable Player mobOwner; // protected final @Nullable Projectile projectile; // // @Override // public @Nonnull String toString() { // return "OwnedMobDamageInfo{damager=" + this.resolvedDamager + ",mobOwner=" + this.mobOwner + ",projectile=" + this.projectile + "}"; // } // } // // Path: src/main/java/tc/oc/tracker/trackers/OwnedMobTracker.java // public interface OwnedMobTracker extends Tracker { // boolean hasOwner(@Nonnull LivingEntity entity); // // @Nullable Player getOwner(@Nonnull LivingEntity entity); // // @Nullable Player setOwner(@Nonnull LivingEntity entity, @Nullable Player player); // }
import javax.annotation.Nonnull; import javax.annotation.Nullable; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.entity.Projectile; import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageEvent; import tc.oc.tracker.DamageInfo; import tc.oc.tracker.DamageResolver; import tc.oc.tracker.Lifetime; import tc.oc.tracker.damage.OwnedMobDamageInfo; import tc.oc.tracker.trackers.OwnedMobTracker;
package tc.oc.tracker.damage.resolvers; public class OwnedMobDamageResolver implements DamageResolver { private final OwnedMobTracker ownedMobTracker; public OwnedMobDamageResolver(OwnedMobTracker ownedMobTracker) { this.ownedMobTracker = ownedMobTracker; }
// Path: src/main/java/tc/oc/tracker/DamageInfo.java // public interface DamageInfo { // /** // * Gets the living entity most responsible for this damage. // * // * @return Resolved damager or null if none exists // */ // @Nullable LivingEntity getResolvedDamager(); // } // // Path: src/main/java/tc/oc/tracker/DamageResolver.java // public interface DamageResolver { // @Nullable DamageInfo resolve(@Nonnull LivingEntity entity, @Nonnull Lifetime lifetime, @Nonnull EntityDamageEvent damageEvent); // } // // Path: src/main/java/tc/oc/tracker/Lifetime.java // public interface Lifetime { // @Nullable Instant getStart(); // // void setStart(@Nonnull Instant start); // // @Nullable Instant getEnd(); // // void setEnd(@Nonnull Instant end); // // @Nonnull List<Damage> getDamage(); // // @Nonnull ListIterator<Damage> getDamageFirst(); // // @Nonnull ListIterator<Damage> getDamageLast(); // // @Nullable Damage getFirstDamage(); // // @Nullable Damage getLastDamage(); // // /** // * Gets the last damage instance where the info object is an instance of // * the specified class. Uses {@link Class#isInstance(Object)} to check info // * objects. // * // * @param damageInfoClass DamageInfo class to check for // * @return Last damage that matched or null if none matched // * // * @throws NullPointerException if damageInfoClass is null // */ // @Nullable Damage getLastDamage(@Nonnull Class<? extends DamageInfo> damageInfoClass); // // void addDamage(@Nonnull Damage damage); // } // // Path: src/main/java/tc/oc/tracker/damage/OwnedMobDamageInfo.java // public class OwnedMobDamageInfo extends AbstractDamageInfo { // public OwnedMobDamageInfo(@Nullable LivingEntity resolvedDamager, @Nullable Player mobOwner, @Nullable Projectile projectile) { // super(resolvedDamager); // // this.mobOwner = mobOwner; // this.projectile = projectile; // } // // public @Nullable Player getMobOwner() { // return this.mobOwner; // } // // public @Nullable Projectile getProjectile() { // return this.projectile; // } // // protected final @Nullable Player mobOwner; // protected final @Nullable Projectile projectile; // // @Override // public @Nonnull String toString() { // return "OwnedMobDamageInfo{damager=" + this.resolvedDamager + ",mobOwner=" + this.mobOwner + ",projectile=" + this.projectile + "}"; // } // } // // Path: src/main/java/tc/oc/tracker/trackers/OwnedMobTracker.java // public interface OwnedMobTracker extends Tracker { // boolean hasOwner(@Nonnull LivingEntity entity); // // @Nullable Player getOwner(@Nonnull LivingEntity entity); // // @Nullable Player setOwner(@Nonnull LivingEntity entity, @Nullable Player player); // } // Path: src/main/java/tc/oc/tracker/damage/resolvers/OwnedMobDamageResolver.java import javax.annotation.Nonnull; import javax.annotation.Nullable; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.entity.Projectile; import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageEvent; import tc.oc.tracker.DamageInfo; import tc.oc.tracker.DamageResolver; import tc.oc.tracker.Lifetime; import tc.oc.tracker.damage.OwnedMobDamageInfo; import tc.oc.tracker.trackers.OwnedMobTracker; package tc.oc.tracker.damage.resolvers; public class OwnedMobDamageResolver implements DamageResolver { private final OwnedMobTracker ownedMobTracker; public OwnedMobDamageResolver(OwnedMobTracker ownedMobTracker) { this.ownedMobTracker = ownedMobTracker; }
public @Nullable DamageInfo resolve(@Nonnull LivingEntity entity, @Nonnull Lifetime lifetime, @Nonnull EntityDamageEvent damageEvent) {
OvercastNetwork/Tracker
src/main/java/tc/oc/tracker/damage/resolvers/OwnedMobDamageResolver.java
// Path: src/main/java/tc/oc/tracker/DamageInfo.java // public interface DamageInfo { // /** // * Gets the living entity most responsible for this damage. // * // * @return Resolved damager or null if none exists // */ // @Nullable LivingEntity getResolvedDamager(); // } // // Path: src/main/java/tc/oc/tracker/DamageResolver.java // public interface DamageResolver { // @Nullable DamageInfo resolve(@Nonnull LivingEntity entity, @Nonnull Lifetime lifetime, @Nonnull EntityDamageEvent damageEvent); // } // // Path: src/main/java/tc/oc/tracker/Lifetime.java // public interface Lifetime { // @Nullable Instant getStart(); // // void setStart(@Nonnull Instant start); // // @Nullable Instant getEnd(); // // void setEnd(@Nonnull Instant end); // // @Nonnull List<Damage> getDamage(); // // @Nonnull ListIterator<Damage> getDamageFirst(); // // @Nonnull ListIterator<Damage> getDamageLast(); // // @Nullable Damage getFirstDamage(); // // @Nullable Damage getLastDamage(); // // /** // * Gets the last damage instance where the info object is an instance of // * the specified class. Uses {@link Class#isInstance(Object)} to check info // * objects. // * // * @param damageInfoClass DamageInfo class to check for // * @return Last damage that matched or null if none matched // * // * @throws NullPointerException if damageInfoClass is null // */ // @Nullable Damage getLastDamage(@Nonnull Class<? extends DamageInfo> damageInfoClass); // // void addDamage(@Nonnull Damage damage); // } // // Path: src/main/java/tc/oc/tracker/damage/OwnedMobDamageInfo.java // public class OwnedMobDamageInfo extends AbstractDamageInfo { // public OwnedMobDamageInfo(@Nullable LivingEntity resolvedDamager, @Nullable Player mobOwner, @Nullable Projectile projectile) { // super(resolvedDamager); // // this.mobOwner = mobOwner; // this.projectile = projectile; // } // // public @Nullable Player getMobOwner() { // return this.mobOwner; // } // // public @Nullable Projectile getProjectile() { // return this.projectile; // } // // protected final @Nullable Player mobOwner; // protected final @Nullable Projectile projectile; // // @Override // public @Nonnull String toString() { // return "OwnedMobDamageInfo{damager=" + this.resolvedDamager + ",mobOwner=" + this.mobOwner + ",projectile=" + this.projectile + "}"; // } // } // // Path: src/main/java/tc/oc/tracker/trackers/OwnedMobTracker.java // public interface OwnedMobTracker extends Tracker { // boolean hasOwner(@Nonnull LivingEntity entity); // // @Nullable Player getOwner(@Nonnull LivingEntity entity); // // @Nullable Player setOwner(@Nonnull LivingEntity entity, @Nullable Player player); // }
import javax.annotation.Nonnull; import javax.annotation.Nullable; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.entity.Projectile; import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageEvent; import tc.oc.tracker.DamageInfo; import tc.oc.tracker.DamageResolver; import tc.oc.tracker.Lifetime; import tc.oc.tracker.damage.OwnedMobDamageInfo; import tc.oc.tracker.trackers.OwnedMobTracker;
package tc.oc.tracker.damage.resolvers; public class OwnedMobDamageResolver implements DamageResolver { private final OwnedMobTracker ownedMobTracker; public OwnedMobDamageResolver(OwnedMobTracker ownedMobTracker) { this.ownedMobTracker = ownedMobTracker; }
// Path: src/main/java/tc/oc/tracker/DamageInfo.java // public interface DamageInfo { // /** // * Gets the living entity most responsible for this damage. // * // * @return Resolved damager or null if none exists // */ // @Nullable LivingEntity getResolvedDamager(); // } // // Path: src/main/java/tc/oc/tracker/DamageResolver.java // public interface DamageResolver { // @Nullable DamageInfo resolve(@Nonnull LivingEntity entity, @Nonnull Lifetime lifetime, @Nonnull EntityDamageEvent damageEvent); // } // // Path: src/main/java/tc/oc/tracker/Lifetime.java // public interface Lifetime { // @Nullable Instant getStart(); // // void setStart(@Nonnull Instant start); // // @Nullable Instant getEnd(); // // void setEnd(@Nonnull Instant end); // // @Nonnull List<Damage> getDamage(); // // @Nonnull ListIterator<Damage> getDamageFirst(); // // @Nonnull ListIterator<Damage> getDamageLast(); // // @Nullable Damage getFirstDamage(); // // @Nullable Damage getLastDamage(); // // /** // * Gets the last damage instance where the info object is an instance of // * the specified class. Uses {@link Class#isInstance(Object)} to check info // * objects. // * // * @param damageInfoClass DamageInfo class to check for // * @return Last damage that matched or null if none matched // * // * @throws NullPointerException if damageInfoClass is null // */ // @Nullable Damage getLastDamage(@Nonnull Class<? extends DamageInfo> damageInfoClass); // // void addDamage(@Nonnull Damage damage); // } // // Path: src/main/java/tc/oc/tracker/damage/OwnedMobDamageInfo.java // public class OwnedMobDamageInfo extends AbstractDamageInfo { // public OwnedMobDamageInfo(@Nullable LivingEntity resolvedDamager, @Nullable Player mobOwner, @Nullable Projectile projectile) { // super(resolvedDamager); // // this.mobOwner = mobOwner; // this.projectile = projectile; // } // // public @Nullable Player getMobOwner() { // return this.mobOwner; // } // // public @Nullable Projectile getProjectile() { // return this.projectile; // } // // protected final @Nullable Player mobOwner; // protected final @Nullable Projectile projectile; // // @Override // public @Nonnull String toString() { // return "OwnedMobDamageInfo{damager=" + this.resolvedDamager + ",mobOwner=" + this.mobOwner + ",projectile=" + this.projectile + "}"; // } // } // // Path: src/main/java/tc/oc/tracker/trackers/OwnedMobTracker.java // public interface OwnedMobTracker extends Tracker { // boolean hasOwner(@Nonnull LivingEntity entity); // // @Nullable Player getOwner(@Nonnull LivingEntity entity); // // @Nullable Player setOwner(@Nonnull LivingEntity entity, @Nullable Player player); // } // Path: src/main/java/tc/oc/tracker/damage/resolvers/OwnedMobDamageResolver.java import javax.annotation.Nonnull; import javax.annotation.Nullable; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.entity.Projectile; import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageEvent; import tc.oc.tracker.DamageInfo; import tc.oc.tracker.DamageResolver; import tc.oc.tracker.Lifetime; import tc.oc.tracker.damage.OwnedMobDamageInfo; import tc.oc.tracker.trackers.OwnedMobTracker; package tc.oc.tracker.damage.resolvers; public class OwnedMobDamageResolver implements DamageResolver { private final OwnedMobTracker ownedMobTracker; public OwnedMobDamageResolver(OwnedMobTracker ownedMobTracker) { this.ownedMobTracker = ownedMobTracker; }
public @Nullable DamageInfo resolve(@Nonnull LivingEntity entity, @Nonnull Lifetime lifetime, @Nonnull EntityDamageEvent damageEvent) {
OvercastNetwork/Tracker
src/main/java/tc/oc/tracker/damage/resolvers/OwnedMobDamageResolver.java
// Path: src/main/java/tc/oc/tracker/DamageInfo.java // public interface DamageInfo { // /** // * Gets the living entity most responsible for this damage. // * // * @return Resolved damager or null if none exists // */ // @Nullable LivingEntity getResolvedDamager(); // } // // Path: src/main/java/tc/oc/tracker/DamageResolver.java // public interface DamageResolver { // @Nullable DamageInfo resolve(@Nonnull LivingEntity entity, @Nonnull Lifetime lifetime, @Nonnull EntityDamageEvent damageEvent); // } // // Path: src/main/java/tc/oc/tracker/Lifetime.java // public interface Lifetime { // @Nullable Instant getStart(); // // void setStart(@Nonnull Instant start); // // @Nullable Instant getEnd(); // // void setEnd(@Nonnull Instant end); // // @Nonnull List<Damage> getDamage(); // // @Nonnull ListIterator<Damage> getDamageFirst(); // // @Nonnull ListIterator<Damage> getDamageLast(); // // @Nullable Damage getFirstDamage(); // // @Nullable Damage getLastDamage(); // // /** // * Gets the last damage instance where the info object is an instance of // * the specified class. Uses {@link Class#isInstance(Object)} to check info // * objects. // * // * @param damageInfoClass DamageInfo class to check for // * @return Last damage that matched or null if none matched // * // * @throws NullPointerException if damageInfoClass is null // */ // @Nullable Damage getLastDamage(@Nonnull Class<? extends DamageInfo> damageInfoClass); // // void addDamage(@Nonnull Damage damage); // } // // Path: src/main/java/tc/oc/tracker/damage/OwnedMobDamageInfo.java // public class OwnedMobDamageInfo extends AbstractDamageInfo { // public OwnedMobDamageInfo(@Nullable LivingEntity resolvedDamager, @Nullable Player mobOwner, @Nullable Projectile projectile) { // super(resolvedDamager); // // this.mobOwner = mobOwner; // this.projectile = projectile; // } // // public @Nullable Player getMobOwner() { // return this.mobOwner; // } // // public @Nullable Projectile getProjectile() { // return this.projectile; // } // // protected final @Nullable Player mobOwner; // protected final @Nullable Projectile projectile; // // @Override // public @Nonnull String toString() { // return "OwnedMobDamageInfo{damager=" + this.resolvedDamager + ",mobOwner=" + this.mobOwner + ",projectile=" + this.projectile + "}"; // } // } // // Path: src/main/java/tc/oc/tracker/trackers/OwnedMobTracker.java // public interface OwnedMobTracker extends Tracker { // boolean hasOwner(@Nonnull LivingEntity entity); // // @Nullable Player getOwner(@Nonnull LivingEntity entity); // // @Nullable Player setOwner(@Nonnull LivingEntity entity, @Nullable Player player); // }
import javax.annotation.Nonnull; import javax.annotation.Nullable; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.entity.Projectile; import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageEvent; import tc.oc.tracker.DamageInfo; import tc.oc.tracker.DamageResolver; import tc.oc.tracker.Lifetime; import tc.oc.tracker.damage.OwnedMobDamageInfo; import tc.oc.tracker.trackers.OwnedMobTracker;
package tc.oc.tracker.damage.resolvers; public class OwnedMobDamageResolver implements DamageResolver { private final OwnedMobTracker ownedMobTracker; public OwnedMobDamageResolver(OwnedMobTracker ownedMobTracker) { this.ownedMobTracker = ownedMobTracker; } public @Nullable DamageInfo resolve(@Nonnull LivingEntity entity, @Nonnull Lifetime lifetime, @Nonnull EntityDamageEvent damageEvent) { if(damageEvent instanceof EntityDamageByEntityEvent) { EntityDamageByEntityEvent event = (EntityDamageByEntityEvent) damageEvent; if(event.getDamager() instanceof Projectile) { if(((Projectile) event.getDamager()).getShooter() == null) return null; if(!(((Projectile) event.getDamager()).getShooter() instanceof Player) && ((Projectile) event.getDamager()).getShooter() instanceof LivingEntity) { LivingEntity mob = (LivingEntity) ((Projectile) event.getDamager()).getShooter(); Player mobOwner = this.ownedMobTracker.getOwner(mob);
// Path: src/main/java/tc/oc/tracker/DamageInfo.java // public interface DamageInfo { // /** // * Gets the living entity most responsible for this damage. // * // * @return Resolved damager or null if none exists // */ // @Nullable LivingEntity getResolvedDamager(); // } // // Path: src/main/java/tc/oc/tracker/DamageResolver.java // public interface DamageResolver { // @Nullable DamageInfo resolve(@Nonnull LivingEntity entity, @Nonnull Lifetime lifetime, @Nonnull EntityDamageEvent damageEvent); // } // // Path: src/main/java/tc/oc/tracker/Lifetime.java // public interface Lifetime { // @Nullable Instant getStart(); // // void setStart(@Nonnull Instant start); // // @Nullable Instant getEnd(); // // void setEnd(@Nonnull Instant end); // // @Nonnull List<Damage> getDamage(); // // @Nonnull ListIterator<Damage> getDamageFirst(); // // @Nonnull ListIterator<Damage> getDamageLast(); // // @Nullable Damage getFirstDamage(); // // @Nullable Damage getLastDamage(); // // /** // * Gets the last damage instance where the info object is an instance of // * the specified class. Uses {@link Class#isInstance(Object)} to check info // * objects. // * // * @param damageInfoClass DamageInfo class to check for // * @return Last damage that matched or null if none matched // * // * @throws NullPointerException if damageInfoClass is null // */ // @Nullable Damage getLastDamage(@Nonnull Class<? extends DamageInfo> damageInfoClass); // // void addDamage(@Nonnull Damage damage); // } // // Path: src/main/java/tc/oc/tracker/damage/OwnedMobDamageInfo.java // public class OwnedMobDamageInfo extends AbstractDamageInfo { // public OwnedMobDamageInfo(@Nullable LivingEntity resolvedDamager, @Nullable Player mobOwner, @Nullable Projectile projectile) { // super(resolvedDamager); // // this.mobOwner = mobOwner; // this.projectile = projectile; // } // // public @Nullable Player getMobOwner() { // return this.mobOwner; // } // // public @Nullable Projectile getProjectile() { // return this.projectile; // } // // protected final @Nullable Player mobOwner; // protected final @Nullable Projectile projectile; // // @Override // public @Nonnull String toString() { // return "OwnedMobDamageInfo{damager=" + this.resolvedDamager + ",mobOwner=" + this.mobOwner + ",projectile=" + this.projectile + "}"; // } // } // // Path: src/main/java/tc/oc/tracker/trackers/OwnedMobTracker.java // public interface OwnedMobTracker extends Tracker { // boolean hasOwner(@Nonnull LivingEntity entity); // // @Nullable Player getOwner(@Nonnull LivingEntity entity); // // @Nullable Player setOwner(@Nonnull LivingEntity entity, @Nullable Player player); // } // Path: src/main/java/tc/oc/tracker/damage/resolvers/OwnedMobDamageResolver.java import javax.annotation.Nonnull; import javax.annotation.Nullable; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.entity.Projectile; import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageEvent; import tc.oc.tracker.DamageInfo; import tc.oc.tracker.DamageResolver; import tc.oc.tracker.Lifetime; import tc.oc.tracker.damage.OwnedMobDamageInfo; import tc.oc.tracker.trackers.OwnedMobTracker; package tc.oc.tracker.damage.resolvers; public class OwnedMobDamageResolver implements DamageResolver { private final OwnedMobTracker ownedMobTracker; public OwnedMobDamageResolver(OwnedMobTracker ownedMobTracker) { this.ownedMobTracker = ownedMobTracker; } public @Nullable DamageInfo resolve(@Nonnull LivingEntity entity, @Nonnull Lifetime lifetime, @Nonnull EntityDamageEvent damageEvent) { if(damageEvent instanceof EntityDamageByEntityEvent) { EntityDamageByEntityEvent event = (EntityDamageByEntityEvent) damageEvent; if(event.getDamager() instanceof Projectile) { if(((Projectile) event.getDamager()).getShooter() == null) return null; if(!(((Projectile) event.getDamager()).getShooter() instanceof Player) && ((Projectile) event.getDamager()).getShooter() instanceof LivingEntity) { LivingEntity mob = (LivingEntity) ((Projectile) event.getDamager()).getShooter(); Player mobOwner = this.ownedMobTracker.getOwner(mob);
if(mobOwner != null) return new OwnedMobDamageInfo(mob, mobOwner, (Projectile) event.getDamager());
OvercastNetwork/Tracker
src/main/java/tc/oc/tracker/damage/resolvers/ProjectileDamageResolver.java
// Path: src/main/java/tc/oc/tracker/DamageInfo.java // public interface DamageInfo { // /** // * Gets the living entity most responsible for this damage. // * // * @return Resolved damager or null if none exists // */ // @Nullable LivingEntity getResolvedDamager(); // } // // Path: src/main/java/tc/oc/tracker/DamageResolver.java // public interface DamageResolver { // @Nullable DamageInfo resolve(@Nonnull LivingEntity entity, @Nonnull Lifetime lifetime, @Nonnull EntityDamageEvent damageEvent); // } // // Path: src/main/java/tc/oc/tracker/Lifetime.java // public interface Lifetime { // @Nullable Instant getStart(); // // void setStart(@Nonnull Instant start); // // @Nullable Instant getEnd(); // // void setEnd(@Nonnull Instant end); // // @Nonnull List<Damage> getDamage(); // // @Nonnull ListIterator<Damage> getDamageFirst(); // // @Nonnull ListIterator<Damage> getDamageLast(); // // @Nullable Damage getFirstDamage(); // // @Nullable Damage getLastDamage(); // // /** // * Gets the last damage instance where the info object is an instance of // * the specified class. Uses {@link Class#isInstance(Object)} to check info // * objects. // * // * @param damageInfoClass DamageInfo class to check for // * @return Last damage that matched or null if none matched // * // * @throws NullPointerException if damageInfoClass is null // */ // @Nullable Damage getLastDamage(@Nonnull Class<? extends DamageInfo> damageInfoClass); // // void addDamage(@Nonnull Damage damage); // } // // Path: src/main/java/tc/oc/tracker/damage/ProjectileDamageInfo.java // public class ProjectileDamageInfo extends AbstractDamageInfo { // public ProjectileDamageInfo(@Nonnull Projectile projectile, @Nullable LivingEntity resolvedDamager, @Nullable Double projectileDistance) { // super(resolvedDamager); // // Preconditions.checkNotNull(projectile, "projectile"); // // this.projectile = projectile; // this.projectileDistance = projectileDistance; // } // // public @Nonnull Projectile getProjectile() { // return this.projectile; // } // // public @Nullable Double getDistance() { // return this.projectileDistance; // } // // protected final @Nonnull Projectile projectile; // protected final @Nullable Double projectileDistance; // // @Override // public @Nonnull String toString() { // return "ProjectileDamageInfo{shooter=" + this.resolvedDamager + ",projectile=" + this.projectile + ",distance=" + this.projectileDistance + "}"; // } // } // // Path: src/main/java/tc/oc/tracker/trackers/ProjectileDistanceTracker.java // public interface ProjectileDistanceTracker extends Tracker { // boolean hasLaunchLocation(@Nonnull Projectile entity); // // @Nullable Location getLaunchLocation(@Nonnull Projectile projectile); // // @Nullable Location setLaunchLocation(@Nonnull Projectile projectile, @Nullable Location location); // }
import javax.annotation.Nonnull; import javax.annotation.Nullable; import org.bukkit.Location; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Projectile; import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageEvent; import tc.oc.tracker.DamageInfo; import tc.oc.tracker.DamageResolver; import tc.oc.tracker.Lifetime; import tc.oc.tracker.damage.ProjectileDamageInfo; import tc.oc.tracker.trackers.ProjectileDistanceTracker;
package tc.oc.tracker.damage.resolvers; public class ProjectileDamageResolver implements DamageResolver { private final ProjectileDistanceTracker projectileDistanceTracker; public ProjectileDamageResolver(ProjectileDistanceTracker projectileDistanceTracker) { this.projectileDistanceTracker = projectileDistanceTracker; }
// Path: src/main/java/tc/oc/tracker/DamageInfo.java // public interface DamageInfo { // /** // * Gets the living entity most responsible for this damage. // * // * @return Resolved damager or null if none exists // */ // @Nullable LivingEntity getResolvedDamager(); // } // // Path: src/main/java/tc/oc/tracker/DamageResolver.java // public interface DamageResolver { // @Nullable DamageInfo resolve(@Nonnull LivingEntity entity, @Nonnull Lifetime lifetime, @Nonnull EntityDamageEvent damageEvent); // } // // Path: src/main/java/tc/oc/tracker/Lifetime.java // public interface Lifetime { // @Nullable Instant getStart(); // // void setStart(@Nonnull Instant start); // // @Nullable Instant getEnd(); // // void setEnd(@Nonnull Instant end); // // @Nonnull List<Damage> getDamage(); // // @Nonnull ListIterator<Damage> getDamageFirst(); // // @Nonnull ListIterator<Damage> getDamageLast(); // // @Nullable Damage getFirstDamage(); // // @Nullable Damage getLastDamage(); // // /** // * Gets the last damage instance where the info object is an instance of // * the specified class. Uses {@link Class#isInstance(Object)} to check info // * objects. // * // * @param damageInfoClass DamageInfo class to check for // * @return Last damage that matched or null if none matched // * // * @throws NullPointerException if damageInfoClass is null // */ // @Nullable Damage getLastDamage(@Nonnull Class<? extends DamageInfo> damageInfoClass); // // void addDamage(@Nonnull Damage damage); // } // // Path: src/main/java/tc/oc/tracker/damage/ProjectileDamageInfo.java // public class ProjectileDamageInfo extends AbstractDamageInfo { // public ProjectileDamageInfo(@Nonnull Projectile projectile, @Nullable LivingEntity resolvedDamager, @Nullable Double projectileDistance) { // super(resolvedDamager); // // Preconditions.checkNotNull(projectile, "projectile"); // // this.projectile = projectile; // this.projectileDistance = projectileDistance; // } // // public @Nonnull Projectile getProjectile() { // return this.projectile; // } // // public @Nullable Double getDistance() { // return this.projectileDistance; // } // // protected final @Nonnull Projectile projectile; // protected final @Nullable Double projectileDistance; // // @Override // public @Nonnull String toString() { // return "ProjectileDamageInfo{shooter=" + this.resolvedDamager + ",projectile=" + this.projectile + ",distance=" + this.projectileDistance + "}"; // } // } // // Path: src/main/java/tc/oc/tracker/trackers/ProjectileDistanceTracker.java // public interface ProjectileDistanceTracker extends Tracker { // boolean hasLaunchLocation(@Nonnull Projectile entity); // // @Nullable Location getLaunchLocation(@Nonnull Projectile projectile); // // @Nullable Location setLaunchLocation(@Nonnull Projectile projectile, @Nullable Location location); // } // Path: src/main/java/tc/oc/tracker/damage/resolvers/ProjectileDamageResolver.java import javax.annotation.Nonnull; import javax.annotation.Nullable; import org.bukkit.Location; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Projectile; import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageEvent; import tc.oc.tracker.DamageInfo; import tc.oc.tracker.DamageResolver; import tc.oc.tracker.Lifetime; import tc.oc.tracker.damage.ProjectileDamageInfo; import tc.oc.tracker.trackers.ProjectileDistanceTracker; package tc.oc.tracker.damage.resolvers; public class ProjectileDamageResolver implements DamageResolver { private final ProjectileDistanceTracker projectileDistanceTracker; public ProjectileDamageResolver(ProjectileDistanceTracker projectileDistanceTracker) { this.projectileDistanceTracker = projectileDistanceTracker; }
public @Nullable DamageInfo resolve(@Nonnull LivingEntity entity, @Nonnull Lifetime lifetime, @Nonnull EntityDamageEvent damageEvent) {
OvercastNetwork/Tracker
src/main/java/tc/oc/tracker/damage/resolvers/ProjectileDamageResolver.java
// Path: src/main/java/tc/oc/tracker/DamageInfo.java // public interface DamageInfo { // /** // * Gets the living entity most responsible for this damage. // * // * @return Resolved damager or null if none exists // */ // @Nullable LivingEntity getResolvedDamager(); // } // // Path: src/main/java/tc/oc/tracker/DamageResolver.java // public interface DamageResolver { // @Nullable DamageInfo resolve(@Nonnull LivingEntity entity, @Nonnull Lifetime lifetime, @Nonnull EntityDamageEvent damageEvent); // } // // Path: src/main/java/tc/oc/tracker/Lifetime.java // public interface Lifetime { // @Nullable Instant getStart(); // // void setStart(@Nonnull Instant start); // // @Nullable Instant getEnd(); // // void setEnd(@Nonnull Instant end); // // @Nonnull List<Damage> getDamage(); // // @Nonnull ListIterator<Damage> getDamageFirst(); // // @Nonnull ListIterator<Damage> getDamageLast(); // // @Nullable Damage getFirstDamage(); // // @Nullable Damage getLastDamage(); // // /** // * Gets the last damage instance where the info object is an instance of // * the specified class. Uses {@link Class#isInstance(Object)} to check info // * objects. // * // * @param damageInfoClass DamageInfo class to check for // * @return Last damage that matched or null if none matched // * // * @throws NullPointerException if damageInfoClass is null // */ // @Nullable Damage getLastDamage(@Nonnull Class<? extends DamageInfo> damageInfoClass); // // void addDamage(@Nonnull Damage damage); // } // // Path: src/main/java/tc/oc/tracker/damage/ProjectileDamageInfo.java // public class ProjectileDamageInfo extends AbstractDamageInfo { // public ProjectileDamageInfo(@Nonnull Projectile projectile, @Nullable LivingEntity resolvedDamager, @Nullable Double projectileDistance) { // super(resolvedDamager); // // Preconditions.checkNotNull(projectile, "projectile"); // // this.projectile = projectile; // this.projectileDistance = projectileDistance; // } // // public @Nonnull Projectile getProjectile() { // return this.projectile; // } // // public @Nullable Double getDistance() { // return this.projectileDistance; // } // // protected final @Nonnull Projectile projectile; // protected final @Nullable Double projectileDistance; // // @Override // public @Nonnull String toString() { // return "ProjectileDamageInfo{shooter=" + this.resolvedDamager + ",projectile=" + this.projectile + ",distance=" + this.projectileDistance + "}"; // } // } // // Path: src/main/java/tc/oc/tracker/trackers/ProjectileDistanceTracker.java // public interface ProjectileDistanceTracker extends Tracker { // boolean hasLaunchLocation(@Nonnull Projectile entity); // // @Nullable Location getLaunchLocation(@Nonnull Projectile projectile); // // @Nullable Location setLaunchLocation(@Nonnull Projectile projectile, @Nullable Location location); // }
import javax.annotation.Nonnull; import javax.annotation.Nullable; import org.bukkit.Location; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Projectile; import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageEvent; import tc.oc.tracker.DamageInfo; import tc.oc.tracker.DamageResolver; import tc.oc.tracker.Lifetime; import tc.oc.tracker.damage.ProjectileDamageInfo; import tc.oc.tracker.trackers.ProjectileDistanceTracker;
package tc.oc.tracker.damage.resolvers; public class ProjectileDamageResolver implements DamageResolver { private final ProjectileDistanceTracker projectileDistanceTracker; public ProjectileDamageResolver(ProjectileDistanceTracker projectileDistanceTracker) { this.projectileDistanceTracker = projectileDistanceTracker; }
// Path: src/main/java/tc/oc/tracker/DamageInfo.java // public interface DamageInfo { // /** // * Gets the living entity most responsible for this damage. // * // * @return Resolved damager or null if none exists // */ // @Nullable LivingEntity getResolvedDamager(); // } // // Path: src/main/java/tc/oc/tracker/DamageResolver.java // public interface DamageResolver { // @Nullable DamageInfo resolve(@Nonnull LivingEntity entity, @Nonnull Lifetime lifetime, @Nonnull EntityDamageEvent damageEvent); // } // // Path: src/main/java/tc/oc/tracker/Lifetime.java // public interface Lifetime { // @Nullable Instant getStart(); // // void setStart(@Nonnull Instant start); // // @Nullable Instant getEnd(); // // void setEnd(@Nonnull Instant end); // // @Nonnull List<Damage> getDamage(); // // @Nonnull ListIterator<Damage> getDamageFirst(); // // @Nonnull ListIterator<Damage> getDamageLast(); // // @Nullable Damage getFirstDamage(); // // @Nullable Damage getLastDamage(); // // /** // * Gets the last damage instance where the info object is an instance of // * the specified class. Uses {@link Class#isInstance(Object)} to check info // * objects. // * // * @param damageInfoClass DamageInfo class to check for // * @return Last damage that matched or null if none matched // * // * @throws NullPointerException if damageInfoClass is null // */ // @Nullable Damage getLastDamage(@Nonnull Class<? extends DamageInfo> damageInfoClass); // // void addDamage(@Nonnull Damage damage); // } // // Path: src/main/java/tc/oc/tracker/damage/ProjectileDamageInfo.java // public class ProjectileDamageInfo extends AbstractDamageInfo { // public ProjectileDamageInfo(@Nonnull Projectile projectile, @Nullable LivingEntity resolvedDamager, @Nullable Double projectileDistance) { // super(resolvedDamager); // // Preconditions.checkNotNull(projectile, "projectile"); // // this.projectile = projectile; // this.projectileDistance = projectileDistance; // } // // public @Nonnull Projectile getProjectile() { // return this.projectile; // } // // public @Nullable Double getDistance() { // return this.projectileDistance; // } // // protected final @Nonnull Projectile projectile; // protected final @Nullable Double projectileDistance; // // @Override // public @Nonnull String toString() { // return "ProjectileDamageInfo{shooter=" + this.resolvedDamager + ",projectile=" + this.projectile + ",distance=" + this.projectileDistance + "}"; // } // } // // Path: src/main/java/tc/oc/tracker/trackers/ProjectileDistanceTracker.java // public interface ProjectileDistanceTracker extends Tracker { // boolean hasLaunchLocation(@Nonnull Projectile entity); // // @Nullable Location getLaunchLocation(@Nonnull Projectile projectile); // // @Nullable Location setLaunchLocation(@Nonnull Projectile projectile, @Nullable Location location); // } // Path: src/main/java/tc/oc/tracker/damage/resolvers/ProjectileDamageResolver.java import javax.annotation.Nonnull; import javax.annotation.Nullable; import org.bukkit.Location; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Projectile; import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageEvent; import tc.oc.tracker.DamageInfo; import tc.oc.tracker.DamageResolver; import tc.oc.tracker.Lifetime; import tc.oc.tracker.damage.ProjectileDamageInfo; import tc.oc.tracker.trackers.ProjectileDistanceTracker; package tc.oc.tracker.damage.resolvers; public class ProjectileDamageResolver implements DamageResolver { private final ProjectileDistanceTracker projectileDistanceTracker; public ProjectileDamageResolver(ProjectileDistanceTracker projectileDistanceTracker) { this.projectileDistanceTracker = projectileDistanceTracker; }
public @Nullable DamageInfo resolve(@Nonnull LivingEntity entity, @Nonnull Lifetime lifetime, @Nonnull EntityDamageEvent damageEvent) {
OvercastNetwork/Tracker
src/main/java/tc/oc/tracker/damage/resolvers/ProjectileDamageResolver.java
// Path: src/main/java/tc/oc/tracker/DamageInfo.java // public interface DamageInfo { // /** // * Gets the living entity most responsible for this damage. // * // * @return Resolved damager or null if none exists // */ // @Nullable LivingEntity getResolvedDamager(); // } // // Path: src/main/java/tc/oc/tracker/DamageResolver.java // public interface DamageResolver { // @Nullable DamageInfo resolve(@Nonnull LivingEntity entity, @Nonnull Lifetime lifetime, @Nonnull EntityDamageEvent damageEvent); // } // // Path: src/main/java/tc/oc/tracker/Lifetime.java // public interface Lifetime { // @Nullable Instant getStart(); // // void setStart(@Nonnull Instant start); // // @Nullable Instant getEnd(); // // void setEnd(@Nonnull Instant end); // // @Nonnull List<Damage> getDamage(); // // @Nonnull ListIterator<Damage> getDamageFirst(); // // @Nonnull ListIterator<Damage> getDamageLast(); // // @Nullable Damage getFirstDamage(); // // @Nullable Damage getLastDamage(); // // /** // * Gets the last damage instance where the info object is an instance of // * the specified class. Uses {@link Class#isInstance(Object)} to check info // * objects. // * // * @param damageInfoClass DamageInfo class to check for // * @return Last damage that matched or null if none matched // * // * @throws NullPointerException if damageInfoClass is null // */ // @Nullable Damage getLastDamage(@Nonnull Class<? extends DamageInfo> damageInfoClass); // // void addDamage(@Nonnull Damage damage); // } // // Path: src/main/java/tc/oc/tracker/damage/ProjectileDamageInfo.java // public class ProjectileDamageInfo extends AbstractDamageInfo { // public ProjectileDamageInfo(@Nonnull Projectile projectile, @Nullable LivingEntity resolvedDamager, @Nullable Double projectileDistance) { // super(resolvedDamager); // // Preconditions.checkNotNull(projectile, "projectile"); // // this.projectile = projectile; // this.projectileDistance = projectileDistance; // } // // public @Nonnull Projectile getProjectile() { // return this.projectile; // } // // public @Nullable Double getDistance() { // return this.projectileDistance; // } // // protected final @Nonnull Projectile projectile; // protected final @Nullable Double projectileDistance; // // @Override // public @Nonnull String toString() { // return "ProjectileDamageInfo{shooter=" + this.resolvedDamager + ",projectile=" + this.projectile + ",distance=" + this.projectileDistance + "}"; // } // } // // Path: src/main/java/tc/oc/tracker/trackers/ProjectileDistanceTracker.java // public interface ProjectileDistanceTracker extends Tracker { // boolean hasLaunchLocation(@Nonnull Projectile entity); // // @Nullable Location getLaunchLocation(@Nonnull Projectile projectile); // // @Nullable Location setLaunchLocation(@Nonnull Projectile projectile, @Nullable Location location); // }
import javax.annotation.Nonnull; import javax.annotation.Nullable; import org.bukkit.Location; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Projectile; import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageEvent; import tc.oc.tracker.DamageInfo; import tc.oc.tracker.DamageResolver; import tc.oc.tracker.Lifetime; import tc.oc.tracker.damage.ProjectileDamageInfo; import tc.oc.tracker.trackers.ProjectileDistanceTracker;
package tc.oc.tracker.damage.resolvers; public class ProjectileDamageResolver implements DamageResolver { private final ProjectileDistanceTracker projectileDistanceTracker; public ProjectileDamageResolver(ProjectileDistanceTracker projectileDistanceTracker) { this.projectileDistanceTracker = projectileDistanceTracker; } public @Nullable DamageInfo resolve(@Nonnull LivingEntity entity, @Nonnull Lifetime lifetime, @Nonnull EntityDamageEvent damageEvent) { if(damageEvent instanceof EntityDamageByEntityEvent) { EntityDamageByEntityEvent event = (EntityDamageByEntityEvent) damageEvent; if(event.getDamager() instanceof Projectile) { Projectile projectile = (Projectile) event.getDamager(); Location launchLocation = this.projectileDistanceTracker.getLaunchLocation(projectile); Double projectileDistance = null; if(launchLocation != null) projectileDistance = event.getEntity().getLocation().distance(launchLocation); if(projectile.getShooter() instanceof LivingEntity) {
// Path: src/main/java/tc/oc/tracker/DamageInfo.java // public interface DamageInfo { // /** // * Gets the living entity most responsible for this damage. // * // * @return Resolved damager or null if none exists // */ // @Nullable LivingEntity getResolvedDamager(); // } // // Path: src/main/java/tc/oc/tracker/DamageResolver.java // public interface DamageResolver { // @Nullable DamageInfo resolve(@Nonnull LivingEntity entity, @Nonnull Lifetime lifetime, @Nonnull EntityDamageEvent damageEvent); // } // // Path: src/main/java/tc/oc/tracker/Lifetime.java // public interface Lifetime { // @Nullable Instant getStart(); // // void setStart(@Nonnull Instant start); // // @Nullable Instant getEnd(); // // void setEnd(@Nonnull Instant end); // // @Nonnull List<Damage> getDamage(); // // @Nonnull ListIterator<Damage> getDamageFirst(); // // @Nonnull ListIterator<Damage> getDamageLast(); // // @Nullable Damage getFirstDamage(); // // @Nullable Damage getLastDamage(); // // /** // * Gets the last damage instance where the info object is an instance of // * the specified class. Uses {@link Class#isInstance(Object)} to check info // * objects. // * // * @param damageInfoClass DamageInfo class to check for // * @return Last damage that matched or null if none matched // * // * @throws NullPointerException if damageInfoClass is null // */ // @Nullable Damage getLastDamage(@Nonnull Class<? extends DamageInfo> damageInfoClass); // // void addDamage(@Nonnull Damage damage); // } // // Path: src/main/java/tc/oc/tracker/damage/ProjectileDamageInfo.java // public class ProjectileDamageInfo extends AbstractDamageInfo { // public ProjectileDamageInfo(@Nonnull Projectile projectile, @Nullable LivingEntity resolvedDamager, @Nullable Double projectileDistance) { // super(resolvedDamager); // // Preconditions.checkNotNull(projectile, "projectile"); // // this.projectile = projectile; // this.projectileDistance = projectileDistance; // } // // public @Nonnull Projectile getProjectile() { // return this.projectile; // } // // public @Nullable Double getDistance() { // return this.projectileDistance; // } // // protected final @Nonnull Projectile projectile; // protected final @Nullable Double projectileDistance; // // @Override // public @Nonnull String toString() { // return "ProjectileDamageInfo{shooter=" + this.resolvedDamager + ",projectile=" + this.projectile + ",distance=" + this.projectileDistance + "}"; // } // } // // Path: src/main/java/tc/oc/tracker/trackers/ProjectileDistanceTracker.java // public interface ProjectileDistanceTracker extends Tracker { // boolean hasLaunchLocation(@Nonnull Projectile entity); // // @Nullable Location getLaunchLocation(@Nonnull Projectile projectile); // // @Nullable Location setLaunchLocation(@Nonnull Projectile projectile, @Nullable Location location); // } // Path: src/main/java/tc/oc/tracker/damage/resolvers/ProjectileDamageResolver.java import javax.annotation.Nonnull; import javax.annotation.Nullable; import org.bukkit.Location; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Projectile; import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageEvent; import tc.oc.tracker.DamageInfo; import tc.oc.tracker.DamageResolver; import tc.oc.tracker.Lifetime; import tc.oc.tracker.damage.ProjectileDamageInfo; import tc.oc.tracker.trackers.ProjectileDistanceTracker; package tc.oc.tracker.damage.resolvers; public class ProjectileDamageResolver implements DamageResolver { private final ProjectileDistanceTracker projectileDistanceTracker; public ProjectileDamageResolver(ProjectileDistanceTracker projectileDistanceTracker) { this.projectileDistanceTracker = projectileDistanceTracker; } public @Nullable DamageInfo resolve(@Nonnull LivingEntity entity, @Nonnull Lifetime lifetime, @Nonnull EntityDamageEvent damageEvent) { if(damageEvent instanceof EntityDamageByEntityEvent) { EntityDamageByEntityEvent event = (EntityDamageByEntityEvent) damageEvent; if(event.getDamager() instanceof Projectile) { Projectile projectile = (Projectile) event.getDamager(); Location launchLocation = this.projectileDistanceTracker.getLaunchLocation(projectile); Double projectileDistance = null; if(launchLocation != null) projectileDistance = event.getEntity().getLocation().distance(launchLocation); if(projectile.getShooter() instanceof LivingEntity) {
return new ProjectileDamageInfo(projectile, (LivingEntity) projectile.getShooter(), projectileDistance);
OvercastNetwork/Tracker
src/main/java/tc/oc/tracker/base/SimpleLifetime.java
// Path: src/main/java/tc/oc/tracker/Damage.java // public interface Damage { // /** // * Gets the amount of damage that was inflicted. // * // * Note that this is the raw damage in half-hearts before dampeners (armor, // * potion effects) are applied. // * // * Contract specifies that the result is 0 or greater. // * // * @return Amount of damage inflicted // */ // int getDamage(); // // /** // * Gets the location where the damage occurred. // * // * Contract specifies that the result is never null. // * // * @return Location of damage // */ // @Nonnull Location getLocation(); // // /** // * Gets the time that the damage occurred. // * // * Contract specifies that the result is never null. // * // * @return Time of damage // */ // @Nonnull Instant getTime(); // // /** // * Gets additional information regarding this damage. // * // * @return {@link DamageInfo} subclass describing the damage in more detail // */ // @Nonnull DamageInfo getInfo(); // } // // Path: src/main/java/tc/oc/tracker/DamageInfo.java // public interface DamageInfo { // /** // * Gets the living entity most responsible for this damage. // * // * @return Resolved damager or null if none exists // */ // @Nullable LivingEntity getResolvedDamager(); // } // // Path: src/main/java/tc/oc/tracker/Lifetime.java // public interface Lifetime { // @Nullable Instant getStart(); // // void setStart(@Nonnull Instant start); // // @Nullable Instant getEnd(); // // void setEnd(@Nonnull Instant end); // // @Nonnull List<Damage> getDamage(); // // @Nonnull ListIterator<Damage> getDamageFirst(); // // @Nonnull ListIterator<Damage> getDamageLast(); // // @Nullable Damage getFirstDamage(); // // @Nullable Damage getLastDamage(); // // /** // * Gets the last damage instance where the info object is an instance of // * the specified class. Uses {@link Class#isInstance(Object)} to check info // * objects. // * // * @param damageInfoClass DamageInfo class to check for // * @return Last damage that matched or null if none matched // * // * @throws NullPointerException if damageInfoClass is null // */ // @Nullable Damage getLastDamage(@Nonnull Class<? extends DamageInfo> damageInfoClass); // // void addDamage(@Nonnull Damage damage); // }
import java.util.Collections; import java.util.List; import java.util.ListIterator; import javax.annotation.Nonnull; import javax.annotation.Nullable; import org.joda.time.Instant; import tc.oc.tracker.Damage; import tc.oc.tracker.DamageInfo; import tc.oc.tracker.Lifetime; import com.google.common.base.Preconditions; import com.google.common.collect.Lists;
package tc.oc.tracker.base; public class SimpleLifetime implements Lifetime { private Instant start; private Instant end;
// Path: src/main/java/tc/oc/tracker/Damage.java // public interface Damage { // /** // * Gets the amount of damage that was inflicted. // * // * Note that this is the raw damage in half-hearts before dampeners (armor, // * potion effects) are applied. // * // * Contract specifies that the result is 0 or greater. // * // * @return Amount of damage inflicted // */ // int getDamage(); // // /** // * Gets the location where the damage occurred. // * // * Contract specifies that the result is never null. // * // * @return Location of damage // */ // @Nonnull Location getLocation(); // // /** // * Gets the time that the damage occurred. // * // * Contract specifies that the result is never null. // * // * @return Time of damage // */ // @Nonnull Instant getTime(); // // /** // * Gets additional information regarding this damage. // * // * @return {@link DamageInfo} subclass describing the damage in more detail // */ // @Nonnull DamageInfo getInfo(); // } // // Path: src/main/java/tc/oc/tracker/DamageInfo.java // public interface DamageInfo { // /** // * Gets the living entity most responsible for this damage. // * // * @return Resolved damager or null if none exists // */ // @Nullable LivingEntity getResolvedDamager(); // } // // Path: src/main/java/tc/oc/tracker/Lifetime.java // public interface Lifetime { // @Nullable Instant getStart(); // // void setStart(@Nonnull Instant start); // // @Nullable Instant getEnd(); // // void setEnd(@Nonnull Instant end); // // @Nonnull List<Damage> getDamage(); // // @Nonnull ListIterator<Damage> getDamageFirst(); // // @Nonnull ListIterator<Damage> getDamageLast(); // // @Nullable Damage getFirstDamage(); // // @Nullable Damage getLastDamage(); // // /** // * Gets the last damage instance where the info object is an instance of // * the specified class. Uses {@link Class#isInstance(Object)} to check info // * objects. // * // * @param damageInfoClass DamageInfo class to check for // * @return Last damage that matched or null if none matched // * // * @throws NullPointerException if damageInfoClass is null // */ // @Nullable Damage getLastDamage(@Nonnull Class<? extends DamageInfo> damageInfoClass); // // void addDamage(@Nonnull Damage damage); // } // Path: src/main/java/tc/oc/tracker/base/SimpleLifetime.java import java.util.Collections; import java.util.List; import java.util.ListIterator; import javax.annotation.Nonnull; import javax.annotation.Nullable; import org.joda.time.Instant; import tc.oc.tracker.Damage; import tc.oc.tracker.DamageInfo; import tc.oc.tracker.Lifetime; import com.google.common.base.Preconditions; import com.google.common.collect.Lists; package tc.oc.tracker.base; public class SimpleLifetime implements Lifetime { private Instant start; private Instant end;
private final List<Damage> damage = Lists.newArrayList();
OvercastNetwork/Tracker
src/main/java/tc/oc/tracker/base/SimpleLifetime.java
// Path: src/main/java/tc/oc/tracker/Damage.java // public interface Damage { // /** // * Gets the amount of damage that was inflicted. // * // * Note that this is the raw damage in half-hearts before dampeners (armor, // * potion effects) are applied. // * // * Contract specifies that the result is 0 or greater. // * // * @return Amount of damage inflicted // */ // int getDamage(); // // /** // * Gets the location where the damage occurred. // * // * Contract specifies that the result is never null. // * // * @return Location of damage // */ // @Nonnull Location getLocation(); // // /** // * Gets the time that the damage occurred. // * // * Contract specifies that the result is never null. // * // * @return Time of damage // */ // @Nonnull Instant getTime(); // // /** // * Gets additional information regarding this damage. // * // * @return {@link DamageInfo} subclass describing the damage in more detail // */ // @Nonnull DamageInfo getInfo(); // } // // Path: src/main/java/tc/oc/tracker/DamageInfo.java // public interface DamageInfo { // /** // * Gets the living entity most responsible for this damage. // * // * @return Resolved damager or null if none exists // */ // @Nullable LivingEntity getResolvedDamager(); // } // // Path: src/main/java/tc/oc/tracker/Lifetime.java // public interface Lifetime { // @Nullable Instant getStart(); // // void setStart(@Nonnull Instant start); // // @Nullable Instant getEnd(); // // void setEnd(@Nonnull Instant end); // // @Nonnull List<Damage> getDamage(); // // @Nonnull ListIterator<Damage> getDamageFirst(); // // @Nonnull ListIterator<Damage> getDamageLast(); // // @Nullable Damage getFirstDamage(); // // @Nullable Damage getLastDamage(); // // /** // * Gets the last damage instance where the info object is an instance of // * the specified class. Uses {@link Class#isInstance(Object)} to check info // * objects. // * // * @param damageInfoClass DamageInfo class to check for // * @return Last damage that matched or null if none matched // * // * @throws NullPointerException if damageInfoClass is null // */ // @Nullable Damage getLastDamage(@Nonnull Class<? extends DamageInfo> damageInfoClass); // // void addDamage(@Nonnull Damage damage); // }
import java.util.Collections; import java.util.List; import java.util.ListIterator; import javax.annotation.Nonnull; import javax.annotation.Nullable; import org.joda.time.Instant; import tc.oc.tracker.Damage; import tc.oc.tracker.DamageInfo; import tc.oc.tracker.Lifetime; import com.google.common.base.Preconditions; import com.google.common.collect.Lists;
} public @Nonnull List<Damage> getDamage() { return Collections.unmodifiableList(this.damage); } public @Nonnull ListIterator<Damage> getDamageFirst() { return Collections.unmodifiableList(this.damage).listIterator(); } public @Nonnull ListIterator<Damage> getDamageLast() { return Collections.unmodifiableList(this.damage).listIterator(this.damage.size()); } public @Nullable Damage getFirstDamage() { if(!this.damage.isEmpty()) { return this.damage.get(0); } else { return null; } } public @Nullable Damage getLastDamage() { if(!this.damage.isEmpty()) { return this.damage.get(this.damage.size() - 1); } else { return null; } }
// Path: src/main/java/tc/oc/tracker/Damage.java // public interface Damage { // /** // * Gets the amount of damage that was inflicted. // * // * Note that this is the raw damage in half-hearts before dampeners (armor, // * potion effects) are applied. // * // * Contract specifies that the result is 0 or greater. // * // * @return Amount of damage inflicted // */ // int getDamage(); // // /** // * Gets the location where the damage occurred. // * // * Contract specifies that the result is never null. // * // * @return Location of damage // */ // @Nonnull Location getLocation(); // // /** // * Gets the time that the damage occurred. // * // * Contract specifies that the result is never null. // * // * @return Time of damage // */ // @Nonnull Instant getTime(); // // /** // * Gets additional information regarding this damage. // * // * @return {@link DamageInfo} subclass describing the damage in more detail // */ // @Nonnull DamageInfo getInfo(); // } // // Path: src/main/java/tc/oc/tracker/DamageInfo.java // public interface DamageInfo { // /** // * Gets the living entity most responsible for this damage. // * // * @return Resolved damager or null if none exists // */ // @Nullable LivingEntity getResolvedDamager(); // } // // Path: src/main/java/tc/oc/tracker/Lifetime.java // public interface Lifetime { // @Nullable Instant getStart(); // // void setStart(@Nonnull Instant start); // // @Nullable Instant getEnd(); // // void setEnd(@Nonnull Instant end); // // @Nonnull List<Damage> getDamage(); // // @Nonnull ListIterator<Damage> getDamageFirst(); // // @Nonnull ListIterator<Damage> getDamageLast(); // // @Nullable Damage getFirstDamage(); // // @Nullable Damage getLastDamage(); // // /** // * Gets the last damage instance where the info object is an instance of // * the specified class. Uses {@link Class#isInstance(Object)} to check info // * objects. // * // * @param damageInfoClass DamageInfo class to check for // * @return Last damage that matched or null if none matched // * // * @throws NullPointerException if damageInfoClass is null // */ // @Nullable Damage getLastDamage(@Nonnull Class<? extends DamageInfo> damageInfoClass); // // void addDamage(@Nonnull Damage damage); // } // Path: src/main/java/tc/oc/tracker/base/SimpleLifetime.java import java.util.Collections; import java.util.List; import java.util.ListIterator; import javax.annotation.Nonnull; import javax.annotation.Nullable; import org.joda.time.Instant; import tc.oc.tracker.Damage; import tc.oc.tracker.DamageInfo; import tc.oc.tracker.Lifetime; import com.google.common.base.Preconditions; import com.google.common.collect.Lists; } public @Nonnull List<Damage> getDamage() { return Collections.unmodifiableList(this.damage); } public @Nonnull ListIterator<Damage> getDamageFirst() { return Collections.unmodifiableList(this.damage).listIterator(); } public @Nonnull ListIterator<Damage> getDamageLast() { return Collections.unmodifiableList(this.damage).listIterator(this.damage.size()); } public @Nullable Damage getFirstDamage() { if(!this.damage.isEmpty()) { return this.damage.get(0); } else { return null; } } public @Nullable Damage getLastDamage() { if(!this.damage.isEmpty()) { return this.damage.get(this.damage.size() - 1); } else { return null; } }
public @Nullable Damage getLastDamage(@Nonnull Class<? extends DamageInfo> damageInfoClass) {
OvercastNetwork/Tracker
src/main/java/tc/oc/tracker/DamageResolvers.java
// Path: src/main/java/tc/oc/tracker/base/SimpleResolverManager.java // public class SimpleResolverManager implements DamageResolverManager { // public boolean isRegistered(@Nonnull DamageResolver resolver) { // Preconditions.checkNotNull(resolver, "resolver"); // // return this.resolvers.contains(resolver); // } // // public void register(@Nonnull DamageResolver resolver) { // Preconditions.checkNotNull(resolver, "resolver"); // // this.register(resolver, Collections.<Class<? extends DamageResolver>>emptySet()); // } // // public void register(@Nonnull DamageResolver resolver, @Nonnull Class<? extends DamageResolver>... before) { // Preconditions.checkNotNull(resolver, "resolver"); // Preconditions.checkNotNull(before, "resolvers before"); // // this.register(resolver, ImmutableSet.copyOf(before)); // } // // public void register(@Nonnull DamageResolver resolver, @Nonnull Collection<Class<? extends DamageResolver>> resolversBefore) { // Preconditions.checkNotNull(resolver, "resolver"); // Preconditions.checkNotNull(resolversBefore, "resolvers before"); // Preconditions.checkArgument(!this.isRegistered(resolver), "resolver is already registered"); // // ResolverEntry entry = new ResolverEntry(resolver, ImmutableSet.copyOf(resolversBefore)); // // Set<ResolverEntry> before = this.getEntriesBefore(entry); // Set<ResolverEntry> after = this.getEntriesAfter(entry); // // int index = 0; // for(; index < this.resolvers.size(); index++) { // ResolverEntry loopEntry = this.resolvers.get(index); // // before.remove(loopEntry); // if(after.contains(loopEntry)) { // if(before.isEmpty()) { // break; // } else { // throw new IllegalArgumentException("failed to solve constraints (" + resolver + " could not come before " + loopEntry.resolver + ") while obeying all other constraints"); // } // } // } // // this.resolvers.add(index, entry); // } // // private Set<ResolverEntry> getEntriesBefore(ResolverEntry entry) { // Set<ResolverEntry> before = Sets.newHashSet(); // // for(ResolverEntry loopEntry : this.resolvers) { // if(loopEntry.isBefore(entry)) { // before.add(loopEntry); // } // } // // return before; // } // // private Set<ResolverEntry> getEntriesAfter(ResolverEntry entry) { // Set<ResolverEntry> after = Sets.newHashSet(); // // for(ResolverEntry loopEntry : this.resolvers) { // if(loopEntry.isAfter(entry)) { // after.add(loopEntry); // } // } // // return after; // } // // public void unregister(@Nonnull DamageResolver resolver) { // Preconditions.checkNotNull(resolver, "resolver"); // // this.resolvers.remove(resolver); // } // // public @Nonnull Set<DamageResolver> getResolvers() { // ImmutableSet.Builder<DamageResolver> resolvers = ImmutableSet.builder(); // // for(ResolverEntry entry : this.resolvers) { // resolvers.add(entry.resolver); // } // // return resolvers.build(); // } // // public @Nonnull DamageInfo resolve(@Nonnull LivingEntity entity, @Nonnull Lifetime lifetime, @Nonnull EntityDamageEvent damageEvent) { // DamageInfo info = null; // // for(ResolverEntry entry : this.resolvers) { // DamageInfo resolvedInfo = entry.resolver.resolve(entity, lifetime, damageEvent); // if(resolvedInfo != null) { // info = resolvedInfo; // } // } // // if(info == null) { // info = new BukkitDamageInfo(damageEvent.getCause()); // } // // return info; // } // // private final @Nonnull List<ResolverEntry> resolvers = Lists.newArrayList(); // // private static class ResolverEntry { // public final DamageResolver resolver; // public final Set<Class<? extends DamageResolver>> before; // // public ResolverEntry(DamageResolver resolver, Set<Class<? extends DamageResolver>> before) { // this.resolver = resolver; // this.before = before; // } // // public boolean isBefore(ResolverEntry entry) { // for(Class<? extends DamageResolver> cls : entry.before) { // if(cls.isInstance(this.resolver)) { // return true; // } // } // return false; // } // // public boolean isAfter(ResolverEntry entry) { // for(Class<? extends DamageResolver> cls : this.before) { // if(cls.isInstance(entry.resolver)) { // return true; // } // } // return false; // } // // @Override // public boolean equals(Object obj) { // if(obj instanceof DamageResolver) { // return this.resolver.equals(obj); // } else { // return super.equals(obj); // } // } // } // }
import javax.annotation.Nonnull; import javax.annotation.Nullable; import tc.oc.tracker.base.SimpleResolverManager;
package tc.oc.tracker; public final class DamageResolvers { private DamageResolvers() { } public static @Nonnull DamageResolverManager getManager() { if(manager == null) {
// Path: src/main/java/tc/oc/tracker/base/SimpleResolverManager.java // public class SimpleResolverManager implements DamageResolverManager { // public boolean isRegistered(@Nonnull DamageResolver resolver) { // Preconditions.checkNotNull(resolver, "resolver"); // // return this.resolvers.contains(resolver); // } // // public void register(@Nonnull DamageResolver resolver) { // Preconditions.checkNotNull(resolver, "resolver"); // // this.register(resolver, Collections.<Class<? extends DamageResolver>>emptySet()); // } // // public void register(@Nonnull DamageResolver resolver, @Nonnull Class<? extends DamageResolver>... before) { // Preconditions.checkNotNull(resolver, "resolver"); // Preconditions.checkNotNull(before, "resolvers before"); // // this.register(resolver, ImmutableSet.copyOf(before)); // } // // public void register(@Nonnull DamageResolver resolver, @Nonnull Collection<Class<? extends DamageResolver>> resolversBefore) { // Preconditions.checkNotNull(resolver, "resolver"); // Preconditions.checkNotNull(resolversBefore, "resolvers before"); // Preconditions.checkArgument(!this.isRegistered(resolver), "resolver is already registered"); // // ResolverEntry entry = new ResolverEntry(resolver, ImmutableSet.copyOf(resolversBefore)); // // Set<ResolverEntry> before = this.getEntriesBefore(entry); // Set<ResolverEntry> after = this.getEntriesAfter(entry); // // int index = 0; // for(; index < this.resolvers.size(); index++) { // ResolverEntry loopEntry = this.resolvers.get(index); // // before.remove(loopEntry); // if(after.contains(loopEntry)) { // if(before.isEmpty()) { // break; // } else { // throw new IllegalArgumentException("failed to solve constraints (" + resolver + " could not come before " + loopEntry.resolver + ") while obeying all other constraints"); // } // } // } // // this.resolvers.add(index, entry); // } // // private Set<ResolverEntry> getEntriesBefore(ResolverEntry entry) { // Set<ResolverEntry> before = Sets.newHashSet(); // // for(ResolverEntry loopEntry : this.resolvers) { // if(loopEntry.isBefore(entry)) { // before.add(loopEntry); // } // } // // return before; // } // // private Set<ResolverEntry> getEntriesAfter(ResolverEntry entry) { // Set<ResolverEntry> after = Sets.newHashSet(); // // for(ResolverEntry loopEntry : this.resolvers) { // if(loopEntry.isAfter(entry)) { // after.add(loopEntry); // } // } // // return after; // } // // public void unregister(@Nonnull DamageResolver resolver) { // Preconditions.checkNotNull(resolver, "resolver"); // // this.resolvers.remove(resolver); // } // // public @Nonnull Set<DamageResolver> getResolvers() { // ImmutableSet.Builder<DamageResolver> resolvers = ImmutableSet.builder(); // // for(ResolverEntry entry : this.resolvers) { // resolvers.add(entry.resolver); // } // // return resolvers.build(); // } // // public @Nonnull DamageInfo resolve(@Nonnull LivingEntity entity, @Nonnull Lifetime lifetime, @Nonnull EntityDamageEvent damageEvent) { // DamageInfo info = null; // // for(ResolverEntry entry : this.resolvers) { // DamageInfo resolvedInfo = entry.resolver.resolve(entity, lifetime, damageEvent); // if(resolvedInfo != null) { // info = resolvedInfo; // } // } // // if(info == null) { // info = new BukkitDamageInfo(damageEvent.getCause()); // } // // return info; // } // // private final @Nonnull List<ResolverEntry> resolvers = Lists.newArrayList(); // // private static class ResolverEntry { // public final DamageResolver resolver; // public final Set<Class<? extends DamageResolver>> before; // // public ResolverEntry(DamageResolver resolver, Set<Class<? extends DamageResolver>> before) { // this.resolver = resolver; // this.before = before; // } // // public boolean isBefore(ResolverEntry entry) { // for(Class<? extends DamageResolver> cls : entry.before) { // if(cls.isInstance(this.resolver)) { // return true; // } // } // return false; // } // // public boolean isAfter(ResolverEntry entry) { // for(Class<? extends DamageResolver> cls : this.before) { // if(cls.isInstance(entry.resolver)) { // return true; // } // } // return false; // } // // @Override // public boolean equals(Object obj) { // if(obj instanceof DamageResolver) { // return this.resolver.equals(obj); // } else { // return super.equals(obj); // } // } // } // } // Path: src/main/java/tc/oc/tracker/DamageResolvers.java import javax.annotation.Nonnull; import javax.annotation.Nullable; import tc.oc.tracker.base.SimpleResolverManager; package tc.oc.tracker; public final class DamageResolvers { private DamageResolvers() { } public static @Nonnull DamageResolverManager getManager() { if(manager == null) {
manager = new SimpleResolverManager();
OvercastNetwork/Tracker
src/main/java/tc/oc/tracker/damage/resolvers/FallDamageResolver.java
// Path: src/main/java/tc/oc/tracker/DamageInfo.java // public interface DamageInfo { // /** // * Gets the living entity most responsible for this damage. // * // * @return Resolved damager or null if none exists // */ // @Nullable LivingEntity getResolvedDamager(); // } // // Path: src/main/java/tc/oc/tracker/DamageResolver.java // public interface DamageResolver { // @Nullable DamageInfo resolve(@Nonnull LivingEntity entity, @Nonnull Lifetime lifetime, @Nonnull EntityDamageEvent damageEvent); // } // // Path: src/main/java/tc/oc/tracker/Lifetime.java // public interface Lifetime { // @Nullable Instant getStart(); // // void setStart(@Nonnull Instant start); // // @Nullable Instant getEnd(); // // void setEnd(@Nonnull Instant end); // // @Nonnull List<Damage> getDamage(); // // @Nonnull ListIterator<Damage> getDamageFirst(); // // @Nonnull ListIterator<Damage> getDamageLast(); // // @Nullable Damage getFirstDamage(); // // @Nullable Damage getLastDamage(); // // /** // * Gets the last damage instance where the info object is an instance of // * the specified class. Uses {@link Class#isInstance(Object)} to check info // * objects. // * // * @param damageInfoClass DamageInfo class to check for // * @return Last damage that matched or null if none matched // * // * @throws NullPointerException if damageInfoClass is null // */ // @Nullable Damage getLastDamage(@Nonnull Class<? extends DamageInfo> damageInfoClass); // // void addDamage(@Nonnull Damage damage); // } // // Path: src/main/java/tc/oc/tracker/damage/base/SimpleFallDamageInfo.java // public class SimpleFallDamageInfo extends AbstractDamageInfo implements FallDamageInfo { // public SimpleFallDamageInfo(@Nullable LivingEntity resolvedDamager, float fallDistance) { // super(resolvedDamager); // // Preconditions.checkArgument(fallDistance >= 0, "fall distance must be >= 0"); // // this.fallDistance = fallDistance; // } // // public float getFallDistance() { // return this.fallDistance; // } // // private final float fallDistance; // }
import javax.annotation.Nonnull; import javax.annotation.Nullable; import org.bukkit.entity.LivingEntity; import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import tc.oc.tracker.DamageInfo; import tc.oc.tracker.DamageResolver; import tc.oc.tracker.Lifetime; import tc.oc.tracker.damage.base.SimpleFallDamageInfo;
package tc.oc.tracker.damage.resolvers; public class FallDamageResolver implements DamageResolver { public @Nullable DamageInfo resolve(@Nonnull LivingEntity entity, @Nonnull Lifetime lifetime, @Nonnull EntityDamageEvent damageEvent) { if(damageEvent.getCause() == DamageCause.FALL) { float fallDistance = Math.max(0, entity.getFallDistance());
// Path: src/main/java/tc/oc/tracker/DamageInfo.java // public interface DamageInfo { // /** // * Gets the living entity most responsible for this damage. // * // * @return Resolved damager or null if none exists // */ // @Nullable LivingEntity getResolvedDamager(); // } // // Path: src/main/java/tc/oc/tracker/DamageResolver.java // public interface DamageResolver { // @Nullable DamageInfo resolve(@Nonnull LivingEntity entity, @Nonnull Lifetime lifetime, @Nonnull EntityDamageEvent damageEvent); // } // // Path: src/main/java/tc/oc/tracker/Lifetime.java // public interface Lifetime { // @Nullable Instant getStart(); // // void setStart(@Nonnull Instant start); // // @Nullable Instant getEnd(); // // void setEnd(@Nonnull Instant end); // // @Nonnull List<Damage> getDamage(); // // @Nonnull ListIterator<Damage> getDamageFirst(); // // @Nonnull ListIterator<Damage> getDamageLast(); // // @Nullable Damage getFirstDamage(); // // @Nullable Damage getLastDamage(); // // /** // * Gets the last damage instance where the info object is an instance of // * the specified class. Uses {@link Class#isInstance(Object)} to check info // * objects. // * // * @param damageInfoClass DamageInfo class to check for // * @return Last damage that matched or null if none matched // * // * @throws NullPointerException if damageInfoClass is null // */ // @Nullable Damage getLastDamage(@Nonnull Class<? extends DamageInfo> damageInfoClass); // // void addDamage(@Nonnull Damage damage); // } // // Path: src/main/java/tc/oc/tracker/damage/base/SimpleFallDamageInfo.java // public class SimpleFallDamageInfo extends AbstractDamageInfo implements FallDamageInfo { // public SimpleFallDamageInfo(@Nullable LivingEntity resolvedDamager, float fallDistance) { // super(resolvedDamager); // // Preconditions.checkArgument(fallDistance >= 0, "fall distance must be >= 0"); // // this.fallDistance = fallDistance; // } // // public float getFallDistance() { // return this.fallDistance; // } // // private final float fallDistance; // } // Path: src/main/java/tc/oc/tracker/damage/resolvers/FallDamageResolver.java import javax.annotation.Nonnull; import javax.annotation.Nullable; import org.bukkit.entity.LivingEntity; import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import tc.oc.tracker.DamageInfo; import tc.oc.tracker.DamageResolver; import tc.oc.tracker.Lifetime; import tc.oc.tracker.damage.base.SimpleFallDamageInfo; package tc.oc.tracker.damage.resolvers; public class FallDamageResolver implements DamageResolver { public @Nullable DamageInfo resolve(@Nonnull LivingEntity entity, @Nonnull Lifetime lifetime, @Nonnull EntityDamageEvent damageEvent) { if(damageEvent.getCause() == DamageCause.FALL) { float fallDistance = Math.max(0, entity.getFallDistance());
return new SimpleFallDamageInfo(null, fallDistance);
OvercastNetwork/Tracker
src/main/java/tc/oc/tracker/damage/resolvers/AnvilDamageResolver.java
// Path: src/main/java/tc/oc/tracker/DamageInfo.java // public interface DamageInfo { // /** // * Gets the living entity most responsible for this damage. // * // * @return Resolved damager or null if none exists // */ // @Nullable LivingEntity getResolvedDamager(); // } // // Path: src/main/java/tc/oc/tracker/DamageResolver.java // public interface DamageResolver { // @Nullable DamageInfo resolve(@Nonnull LivingEntity entity, @Nonnull Lifetime lifetime, @Nonnull EntityDamageEvent damageEvent); // } // // Path: src/main/java/tc/oc/tracker/Lifetime.java // public interface Lifetime { // @Nullable Instant getStart(); // // void setStart(@Nonnull Instant start); // // @Nullable Instant getEnd(); // // void setEnd(@Nonnull Instant end); // // @Nonnull List<Damage> getDamage(); // // @Nonnull ListIterator<Damage> getDamageFirst(); // // @Nonnull ListIterator<Damage> getDamageLast(); // // @Nullable Damage getFirstDamage(); // // @Nullable Damage getLastDamage(); // // /** // * Gets the last damage instance where the info object is an instance of // * the specified class. Uses {@link Class#isInstance(Object)} to check info // * objects. // * // * @param damageInfoClass DamageInfo class to check for // * @return Last damage that matched or null if none matched // * // * @throws NullPointerException if damageInfoClass is null // */ // @Nullable Damage getLastDamage(@Nonnull Class<? extends DamageInfo> damageInfoClass); // // void addDamage(@Nonnull Damage damage); // } // // Path: src/main/java/tc/oc/tracker/damage/AnvilDamageInfo.java // public class AnvilDamageInfo extends AbstractDamageInfo { // // public AnvilDamageInfo(@Nullable FallingBlock anvil, @Nullable LivingEntity resolvedDamager, @Nullable OfflinePlayer offlinePlayer) { // super(resolvedDamager); // // this.anvil = anvil; // this.offlinePlayer = offlinePlayer; // } // // public @Nonnull FallingBlock getAnvil() { // return this.anvil; // } // // public @Nullable OfflinePlayer getOffinePlayer() { // return this.offlinePlayer; // } // // protected final @Nonnull FallingBlock anvil; // protected final @Nullable OfflinePlayer offlinePlayer; // // @Override // public @Nonnull String toString() { // return "AnvilDamageInfo{anvil=" + this.anvil + ",damager=" + this.resolvedDamager + ",offlinePlayer=" + this.offlinePlayer + "}"; // } // } // // Path: src/main/java/tc/oc/tracker/trackers/AnvilTracker.java // public interface AnvilTracker extends Tracker { // boolean hasOwner(@Nonnull FallingBlock entity); // // @Nullable OfflinePlayer getOwner(@Nonnull FallingBlock anvil); // // @Nullable OfflinePlayer setOwner(@Nonnull FallingBlock anvil, @Nullable OfflinePlayer offlinePlayer); // // boolean hasPlacer(@Nonnull Block block); // // @Nullable OfflinePlayer getPlacer(@Nonnull Block block); // // @Nullable OfflinePlayer setPlacer(@Nonnull Block block, @Nonnull OfflinePlayer offlinePlayer); // // @Nonnull OfflinePlayer clearPlacer(@Nullable Block block); // }
import org.bukkit.OfflinePlayer; import org.bukkit.entity.FallingBlock; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageEvent; import tc.oc.tracker.DamageInfo; import tc.oc.tracker.DamageResolver; import tc.oc.tracker.Lifetime; import tc.oc.tracker.damage.AnvilDamageInfo; import tc.oc.tracker.trackers.AnvilTracker;
package tc.oc.tracker.damage.resolvers; public class AnvilDamageResolver implements DamageResolver { private final AnvilTracker anvilTracker; public AnvilDamageResolver(AnvilTracker anvilTracker) { this.anvilTracker = anvilTracker; }
// Path: src/main/java/tc/oc/tracker/DamageInfo.java // public interface DamageInfo { // /** // * Gets the living entity most responsible for this damage. // * // * @return Resolved damager or null if none exists // */ // @Nullable LivingEntity getResolvedDamager(); // } // // Path: src/main/java/tc/oc/tracker/DamageResolver.java // public interface DamageResolver { // @Nullable DamageInfo resolve(@Nonnull LivingEntity entity, @Nonnull Lifetime lifetime, @Nonnull EntityDamageEvent damageEvent); // } // // Path: src/main/java/tc/oc/tracker/Lifetime.java // public interface Lifetime { // @Nullable Instant getStart(); // // void setStart(@Nonnull Instant start); // // @Nullable Instant getEnd(); // // void setEnd(@Nonnull Instant end); // // @Nonnull List<Damage> getDamage(); // // @Nonnull ListIterator<Damage> getDamageFirst(); // // @Nonnull ListIterator<Damage> getDamageLast(); // // @Nullable Damage getFirstDamage(); // // @Nullable Damage getLastDamage(); // // /** // * Gets the last damage instance where the info object is an instance of // * the specified class. Uses {@link Class#isInstance(Object)} to check info // * objects. // * // * @param damageInfoClass DamageInfo class to check for // * @return Last damage that matched or null if none matched // * // * @throws NullPointerException if damageInfoClass is null // */ // @Nullable Damage getLastDamage(@Nonnull Class<? extends DamageInfo> damageInfoClass); // // void addDamage(@Nonnull Damage damage); // } // // Path: src/main/java/tc/oc/tracker/damage/AnvilDamageInfo.java // public class AnvilDamageInfo extends AbstractDamageInfo { // // public AnvilDamageInfo(@Nullable FallingBlock anvil, @Nullable LivingEntity resolvedDamager, @Nullable OfflinePlayer offlinePlayer) { // super(resolvedDamager); // // this.anvil = anvil; // this.offlinePlayer = offlinePlayer; // } // // public @Nonnull FallingBlock getAnvil() { // return this.anvil; // } // // public @Nullable OfflinePlayer getOffinePlayer() { // return this.offlinePlayer; // } // // protected final @Nonnull FallingBlock anvil; // protected final @Nullable OfflinePlayer offlinePlayer; // // @Override // public @Nonnull String toString() { // return "AnvilDamageInfo{anvil=" + this.anvil + ",damager=" + this.resolvedDamager + ",offlinePlayer=" + this.offlinePlayer + "}"; // } // } // // Path: src/main/java/tc/oc/tracker/trackers/AnvilTracker.java // public interface AnvilTracker extends Tracker { // boolean hasOwner(@Nonnull FallingBlock entity); // // @Nullable OfflinePlayer getOwner(@Nonnull FallingBlock anvil); // // @Nullable OfflinePlayer setOwner(@Nonnull FallingBlock anvil, @Nullable OfflinePlayer offlinePlayer); // // boolean hasPlacer(@Nonnull Block block); // // @Nullable OfflinePlayer getPlacer(@Nonnull Block block); // // @Nullable OfflinePlayer setPlacer(@Nonnull Block block, @Nonnull OfflinePlayer offlinePlayer); // // @Nonnull OfflinePlayer clearPlacer(@Nullable Block block); // } // Path: src/main/java/tc/oc/tracker/damage/resolvers/AnvilDamageResolver.java import org.bukkit.OfflinePlayer; import org.bukkit.entity.FallingBlock; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageEvent; import tc.oc.tracker.DamageInfo; import tc.oc.tracker.DamageResolver; import tc.oc.tracker.Lifetime; import tc.oc.tracker.damage.AnvilDamageInfo; import tc.oc.tracker.trackers.AnvilTracker; package tc.oc.tracker.damage.resolvers; public class AnvilDamageResolver implements DamageResolver { private final AnvilTracker anvilTracker; public AnvilDamageResolver(AnvilTracker anvilTracker) { this.anvilTracker = anvilTracker; }
public DamageInfo resolve(LivingEntity entity, Lifetime lifetime, EntityDamageEvent damageEvent) {
OvercastNetwork/Tracker
src/main/java/tc/oc/tracker/damage/resolvers/AnvilDamageResolver.java
// Path: src/main/java/tc/oc/tracker/DamageInfo.java // public interface DamageInfo { // /** // * Gets the living entity most responsible for this damage. // * // * @return Resolved damager or null if none exists // */ // @Nullable LivingEntity getResolvedDamager(); // } // // Path: src/main/java/tc/oc/tracker/DamageResolver.java // public interface DamageResolver { // @Nullable DamageInfo resolve(@Nonnull LivingEntity entity, @Nonnull Lifetime lifetime, @Nonnull EntityDamageEvent damageEvent); // } // // Path: src/main/java/tc/oc/tracker/Lifetime.java // public interface Lifetime { // @Nullable Instant getStart(); // // void setStart(@Nonnull Instant start); // // @Nullable Instant getEnd(); // // void setEnd(@Nonnull Instant end); // // @Nonnull List<Damage> getDamage(); // // @Nonnull ListIterator<Damage> getDamageFirst(); // // @Nonnull ListIterator<Damage> getDamageLast(); // // @Nullable Damage getFirstDamage(); // // @Nullable Damage getLastDamage(); // // /** // * Gets the last damage instance where the info object is an instance of // * the specified class. Uses {@link Class#isInstance(Object)} to check info // * objects. // * // * @param damageInfoClass DamageInfo class to check for // * @return Last damage that matched or null if none matched // * // * @throws NullPointerException if damageInfoClass is null // */ // @Nullable Damage getLastDamage(@Nonnull Class<? extends DamageInfo> damageInfoClass); // // void addDamage(@Nonnull Damage damage); // } // // Path: src/main/java/tc/oc/tracker/damage/AnvilDamageInfo.java // public class AnvilDamageInfo extends AbstractDamageInfo { // // public AnvilDamageInfo(@Nullable FallingBlock anvil, @Nullable LivingEntity resolvedDamager, @Nullable OfflinePlayer offlinePlayer) { // super(resolvedDamager); // // this.anvil = anvil; // this.offlinePlayer = offlinePlayer; // } // // public @Nonnull FallingBlock getAnvil() { // return this.anvil; // } // // public @Nullable OfflinePlayer getOffinePlayer() { // return this.offlinePlayer; // } // // protected final @Nonnull FallingBlock anvil; // protected final @Nullable OfflinePlayer offlinePlayer; // // @Override // public @Nonnull String toString() { // return "AnvilDamageInfo{anvil=" + this.anvil + ",damager=" + this.resolvedDamager + ",offlinePlayer=" + this.offlinePlayer + "}"; // } // } // // Path: src/main/java/tc/oc/tracker/trackers/AnvilTracker.java // public interface AnvilTracker extends Tracker { // boolean hasOwner(@Nonnull FallingBlock entity); // // @Nullable OfflinePlayer getOwner(@Nonnull FallingBlock anvil); // // @Nullable OfflinePlayer setOwner(@Nonnull FallingBlock anvil, @Nullable OfflinePlayer offlinePlayer); // // boolean hasPlacer(@Nonnull Block block); // // @Nullable OfflinePlayer getPlacer(@Nonnull Block block); // // @Nullable OfflinePlayer setPlacer(@Nonnull Block block, @Nonnull OfflinePlayer offlinePlayer); // // @Nonnull OfflinePlayer clearPlacer(@Nullable Block block); // }
import org.bukkit.OfflinePlayer; import org.bukkit.entity.FallingBlock; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageEvent; import tc.oc.tracker.DamageInfo; import tc.oc.tracker.DamageResolver; import tc.oc.tracker.Lifetime; import tc.oc.tracker.damage.AnvilDamageInfo; import tc.oc.tracker.trackers.AnvilTracker;
package tc.oc.tracker.damage.resolvers; public class AnvilDamageResolver implements DamageResolver { private final AnvilTracker anvilTracker; public AnvilDamageResolver(AnvilTracker anvilTracker) { this.anvilTracker = anvilTracker; }
// Path: src/main/java/tc/oc/tracker/DamageInfo.java // public interface DamageInfo { // /** // * Gets the living entity most responsible for this damage. // * // * @return Resolved damager or null if none exists // */ // @Nullable LivingEntity getResolvedDamager(); // } // // Path: src/main/java/tc/oc/tracker/DamageResolver.java // public interface DamageResolver { // @Nullable DamageInfo resolve(@Nonnull LivingEntity entity, @Nonnull Lifetime lifetime, @Nonnull EntityDamageEvent damageEvent); // } // // Path: src/main/java/tc/oc/tracker/Lifetime.java // public interface Lifetime { // @Nullable Instant getStart(); // // void setStart(@Nonnull Instant start); // // @Nullable Instant getEnd(); // // void setEnd(@Nonnull Instant end); // // @Nonnull List<Damage> getDamage(); // // @Nonnull ListIterator<Damage> getDamageFirst(); // // @Nonnull ListIterator<Damage> getDamageLast(); // // @Nullable Damage getFirstDamage(); // // @Nullable Damage getLastDamage(); // // /** // * Gets the last damage instance where the info object is an instance of // * the specified class. Uses {@link Class#isInstance(Object)} to check info // * objects. // * // * @param damageInfoClass DamageInfo class to check for // * @return Last damage that matched or null if none matched // * // * @throws NullPointerException if damageInfoClass is null // */ // @Nullable Damage getLastDamage(@Nonnull Class<? extends DamageInfo> damageInfoClass); // // void addDamage(@Nonnull Damage damage); // } // // Path: src/main/java/tc/oc/tracker/damage/AnvilDamageInfo.java // public class AnvilDamageInfo extends AbstractDamageInfo { // // public AnvilDamageInfo(@Nullable FallingBlock anvil, @Nullable LivingEntity resolvedDamager, @Nullable OfflinePlayer offlinePlayer) { // super(resolvedDamager); // // this.anvil = anvil; // this.offlinePlayer = offlinePlayer; // } // // public @Nonnull FallingBlock getAnvil() { // return this.anvil; // } // // public @Nullable OfflinePlayer getOffinePlayer() { // return this.offlinePlayer; // } // // protected final @Nonnull FallingBlock anvil; // protected final @Nullable OfflinePlayer offlinePlayer; // // @Override // public @Nonnull String toString() { // return "AnvilDamageInfo{anvil=" + this.anvil + ",damager=" + this.resolvedDamager + ",offlinePlayer=" + this.offlinePlayer + "}"; // } // } // // Path: src/main/java/tc/oc/tracker/trackers/AnvilTracker.java // public interface AnvilTracker extends Tracker { // boolean hasOwner(@Nonnull FallingBlock entity); // // @Nullable OfflinePlayer getOwner(@Nonnull FallingBlock anvil); // // @Nullable OfflinePlayer setOwner(@Nonnull FallingBlock anvil, @Nullable OfflinePlayer offlinePlayer); // // boolean hasPlacer(@Nonnull Block block); // // @Nullable OfflinePlayer getPlacer(@Nonnull Block block); // // @Nullable OfflinePlayer setPlacer(@Nonnull Block block, @Nonnull OfflinePlayer offlinePlayer); // // @Nonnull OfflinePlayer clearPlacer(@Nullable Block block); // } // Path: src/main/java/tc/oc/tracker/damage/resolvers/AnvilDamageResolver.java import org.bukkit.OfflinePlayer; import org.bukkit.entity.FallingBlock; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageEvent; import tc.oc.tracker.DamageInfo; import tc.oc.tracker.DamageResolver; import tc.oc.tracker.Lifetime; import tc.oc.tracker.damage.AnvilDamageInfo; import tc.oc.tracker.trackers.AnvilTracker; package tc.oc.tracker.damage.resolvers; public class AnvilDamageResolver implements DamageResolver { private final AnvilTracker anvilTracker; public AnvilDamageResolver(AnvilTracker anvilTracker) { this.anvilTracker = anvilTracker; }
public DamageInfo resolve(LivingEntity entity, Lifetime lifetime, EntityDamageEvent damageEvent) {
OvercastNetwork/Tracker
src/main/java/tc/oc/tracker/damage/resolvers/AnvilDamageResolver.java
// Path: src/main/java/tc/oc/tracker/DamageInfo.java // public interface DamageInfo { // /** // * Gets the living entity most responsible for this damage. // * // * @return Resolved damager or null if none exists // */ // @Nullable LivingEntity getResolvedDamager(); // } // // Path: src/main/java/tc/oc/tracker/DamageResolver.java // public interface DamageResolver { // @Nullable DamageInfo resolve(@Nonnull LivingEntity entity, @Nonnull Lifetime lifetime, @Nonnull EntityDamageEvent damageEvent); // } // // Path: src/main/java/tc/oc/tracker/Lifetime.java // public interface Lifetime { // @Nullable Instant getStart(); // // void setStart(@Nonnull Instant start); // // @Nullable Instant getEnd(); // // void setEnd(@Nonnull Instant end); // // @Nonnull List<Damage> getDamage(); // // @Nonnull ListIterator<Damage> getDamageFirst(); // // @Nonnull ListIterator<Damage> getDamageLast(); // // @Nullable Damage getFirstDamage(); // // @Nullable Damage getLastDamage(); // // /** // * Gets the last damage instance where the info object is an instance of // * the specified class. Uses {@link Class#isInstance(Object)} to check info // * objects. // * // * @param damageInfoClass DamageInfo class to check for // * @return Last damage that matched or null if none matched // * // * @throws NullPointerException if damageInfoClass is null // */ // @Nullable Damage getLastDamage(@Nonnull Class<? extends DamageInfo> damageInfoClass); // // void addDamage(@Nonnull Damage damage); // } // // Path: src/main/java/tc/oc/tracker/damage/AnvilDamageInfo.java // public class AnvilDamageInfo extends AbstractDamageInfo { // // public AnvilDamageInfo(@Nullable FallingBlock anvil, @Nullable LivingEntity resolvedDamager, @Nullable OfflinePlayer offlinePlayer) { // super(resolvedDamager); // // this.anvil = anvil; // this.offlinePlayer = offlinePlayer; // } // // public @Nonnull FallingBlock getAnvil() { // return this.anvil; // } // // public @Nullable OfflinePlayer getOffinePlayer() { // return this.offlinePlayer; // } // // protected final @Nonnull FallingBlock anvil; // protected final @Nullable OfflinePlayer offlinePlayer; // // @Override // public @Nonnull String toString() { // return "AnvilDamageInfo{anvil=" + this.anvil + ",damager=" + this.resolvedDamager + ",offlinePlayer=" + this.offlinePlayer + "}"; // } // } // // Path: src/main/java/tc/oc/tracker/trackers/AnvilTracker.java // public interface AnvilTracker extends Tracker { // boolean hasOwner(@Nonnull FallingBlock entity); // // @Nullable OfflinePlayer getOwner(@Nonnull FallingBlock anvil); // // @Nullable OfflinePlayer setOwner(@Nonnull FallingBlock anvil, @Nullable OfflinePlayer offlinePlayer); // // boolean hasPlacer(@Nonnull Block block); // // @Nullable OfflinePlayer getPlacer(@Nonnull Block block); // // @Nullable OfflinePlayer setPlacer(@Nonnull Block block, @Nonnull OfflinePlayer offlinePlayer); // // @Nonnull OfflinePlayer clearPlacer(@Nullable Block block); // }
import org.bukkit.OfflinePlayer; import org.bukkit.entity.FallingBlock; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageEvent; import tc.oc.tracker.DamageInfo; import tc.oc.tracker.DamageResolver; import tc.oc.tracker.Lifetime; import tc.oc.tracker.damage.AnvilDamageInfo; import tc.oc.tracker.trackers.AnvilTracker;
package tc.oc.tracker.damage.resolvers; public class AnvilDamageResolver implements DamageResolver { private final AnvilTracker anvilTracker; public AnvilDamageResolver(AnvilTracker anvilTracker) { this.anvilTracker = anvilTracker; } public DamageInfo resolve(LivingEntity entity, Lifetime lifetime, EntityDamageEvent damageEvent) { if(damageEvent instanceof EntityDamageByEntityEvent) { EntityDamageByEntityEvent event = (EntityDamageByEntityEvent) damageEvent; if(event.getDamager() instanceof FallingBlock) { FallingBlock anvil = (FallingBlock) event.getDamager(); OfflinePlayer offlineOwner = this.anvilTracker.getOwner(anvil); Player onlineOwner = null; if(offlineOwner != null) onlineOwner = offlineOwner.getPlayer();
// Path: src/main/java/tc/oc/tracker/DamageInfo.java // public interface DamageInfo { // /** // * Gets the living entity most responsible for this damage. // * // * @return Resolved damager or null if none exists // */ // @Nullable LivingEntity getResolvedDamager(); // } // // Path: src/main/java/tc/oc/tracker/DamageResolver.java // public interface DamageResolver { // @Nullable DamageInfo resolve(@Nonnull LivingEntity entity, @Nonnull Lifetime lifetime, @Nonnull EntityDamageEvent damageEvent); // } // // Path: src/main/java/tc/oc/tracker/Lifetime.java // public interface Lifetime { // @Nullable Instant getStart(); // // void setStart(@Nonnull Instant start); // // @Nullable Instant getEnd(); // // void setEnd(@Nonnull Instant end); // // @Nonnull List<Damage> getDamage(); // // @Nonnull ListIterator<Damage> getDamageFirst(); // // @Nonnull ListIterator<Damage> getDamageLast(); // // @Nullable Damage getFirstDamage(); // // @Nullable Damage getLastDamage(); // // /** // * Gets the last damage instance where the info object is an instance of // * the specified class. Uses {@link Class#isInstance(Object)} to check info // * objects. // * // * @param damageInfoClass DamageInfo class to check for // * @return Last damage that matched or null if none matched // * // * @throws NullPointerException if damageInfoClass is null // */ // @Nullable Damage getLastDamage(@Nonnull Class<? extends DamageInfo> damageInfoClass); // // void addDamage(@Nonnull Damage damage); // } // // Path: src/main/java/tc/oc/tracker/damage/AnvilDamageInfo.java // public class AnvilDamageInfo extends AbstractDamageInfo { // // public AnvilDamageInfo(@Nullable FallingBlock anvil, @Nullable LivingEntity resolvedDamager, @Nullable OfflinePlayer offlinePlayer) { // super(resolvedDamager); // // this.anvil = anvil; // this.offlinePlayer = offlinePlayer; // } // // public @Nonnull FallingBlock getAnvil() { // return this.anvil; // } // // public @Nullable OfflinePlayer getOffinePlayer() { // return this.offlinePlayer; // } // // protected final @Nonnull FallingBlock anvil; // protected final @Nullable OfflinePlayer offlinePlayer; // // @Override // public @Nonnull String toString() { // return "AnvilDamageInfo{anvil=" + this.anvil + ",damager=" + this.resolvedDamager + ",offlinePlayer=" + this.offlinePlayer + "}"; // } // } // // Path: src/main/java/tc/oc/tracker/trackers/AnvilTracker.java // public interface AnvilTracker extends Tracker { // boolean hasOwner(@Nonnull FallingBlock entity); // // @Nullable OfflinePlayer getOwner(@Nonnull FallingBlock anvil); // // @Nullable OfflinePlayer setOwner(@Nonnull FallingBlock anvil, @Nullable OfflinePlayer offlinePlayer); // // boolean hasPlacer(@Nonnull Block block); // // @Nullable OfflinePlayer getPlacer(@Nonnull Block block); // // @Nullable OfflinePlayer setPlacer(@Nonnull Block block, @Nonnull OfflinePlayer offlinePlayer); // // @Nonnull OfflinePlayer clearPlacer(@Nullable Block block); // } // Path: src/main/java/tc/oc/tracker/damage/resolvers/AnvilDamageResolver.java import org.bukkit.OfflinePlayer; import org.bukkit.entity.FallingBlock; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageEvent; import tc.oc.tracker.DamageInfo; import tc.oc.tracker.DamageResolver; import tc.oc.tracker.Lifetime; import tc.oc.tracker.damage.AnvilDamageInfo; import tc.oc.tracker.trackers.AnvilTracker; package tc.oc.tracker.damage.resolvers; public class AnvilDamageResolver implements DamageResolver { private final AnvilTracker anvilTracker; public AnvilDamageResolver(AnvilTracker anvilTracker) { this.anvilTracker = anvilTracker; } public DamageInfo resolve(LivingEntity entity, Lifetime lifetime, EntityDamageEvent damageEvent) { if(damageEvent instanceof EntityDamageByEntityEvent) { EntityDamageByEntityEvent event = (EntityDamageByEntityEvent) damageEvent; if(event.getDamager() instanceof FallingBlock) { FallingBlock anvil = (FallingBlock) event.getDamager(); OfflinePlayer offlineOwner = this.anvilTracker.getOwner(anvil); Player onlineOwner = null; if(offlineOwner != null) onlineOwner = offlineOwner.getPlayer();
return new AnvilDamageInfo(anvil, onlineOwner, offlineOwner);
OvercastNetwork/Tracker
src/main/java/tc/oc/tracker/damage/resolvers/DispensedProjectileDamageResolver.java
// Path: src/main/java/tc/oc/tracker/DamageInfo.java // public interface DamageInfo { // /** // * Gets the living entity most responsible for this damage. // * // * @return Resolved damager or null if none exists // */ // @Nullable LivingEntity getResolvedDamager(); // } // // Path: src/main/java/tc/oc/tracker/DamageResolver.java // public interface DamageResolver { // @Nullable DamageInfo resolve(@Nonnull LivingEntity entity, @Nonnull Lifetime lifetime, @Nonnull EntityDamageEvent damageEvent); // } // // Path: src/main/java/tc/oc/tracker/Lifetime.java // public interface Lifetime { // @Nullable Instant getStart(); // // void setStart(@Nonnull Instant start); // // @Nullable Instant getEnd(); // // void setEnd(@Nonnull Instant end); // // @Nonnull List<Damage> getDamage(); // // @Nonnull ListIterator<Damage> getDamageFirst(); // // @Nonnull ListIterator<Damage> getDamageLast(); // // @Nullable Damage getFirstDamage(); // // @Nullable Damage getLastDamage(); // // /** // * Gets the last damage instance where the info object is an instance of // * the specified class. Uses {@link Class#isInstance(Object)} to check info // * objects. // * // * @param damageInfoClass DamageInfo class to check for // * @return Last damage that matched or null if none matched // * // * @throws NullPointerException if damageInfoClass is null // */ // @Nullable Damage getLastDamage(@Nonnull Class<? extends DamageInfo> damageInfoClass); // // void addDamage(@Nonnull Damage damage); // } // // Path: src/main/java/tc/oc/tracker/damage/DispensedProjectileDamageInfo.java // public class DispensedProjectileDamageInfo extends ProjectileDamageInfo { // // public DispensedProjectileDamageInfo(@Nonnull Projectile projectile, @Nullable LivingEntity resolvedDamager, @Nullable Double projectileDistance, @Nullable OfflinePlayer dispenserOwner) { // super(projectile, resolvedDamager, projectileDistance); // // this.dispenserOwner = dispenserOwner; // } // // public @Nullable OfflinePlayer getdispenserOwner() { // return this.dispenserOwner; // } // // protected final @Nonnull OfflinePlayer dispenserOwner; // // @Override // public @Nonnull String toString() { // return "DispensedProjectileDamageInfo{shooter=" + this.resolvedDamager + ",projectile=" + this.projectile + ",distance=" + this.projectileDistance + ",dispenserOwner=" + this.dispenserOwner + "}"; // } // } // // Path: src/main/java/tc/oc/tracker/trackers/DispenserTracker.java // public interface DispenserTracker extends Tracker { // boolean hasOwner(@Nonnull Entity entity); // // @Nullable OfflinePlayer getOwner(@Nonnull Entity entity); // // @Nullable OfflinePlayer setOwner(@Nonnull Entity entity, @Nullable Player player); // // boolean hasPlacer(@Nonnull Block block); // // @Nullable OfflinePlayer getPlacer(@Nonnull Block block); // // @Nullable OfflinePlayer setPlacer(@Nonnull Block block, @Nullable Player player); // // @Nonnull OfflinePlayer clearPlacer(@Nonnull Block block); // } // // Path: src/main/java/tc/oc/tracker/trackers/ProjectileDistanceTracker.java // public interface ProjectileDistanceTracker extends Tracker { // boolean hasLaunchLocation(@Nonnull Projectile entity); // // @Nullable Location getLaunchLocation(@Nonnull Projectile projectile); // // @Nullable Location setLaunchLocation(@Nonnull Projectile projectile, @Nullable Location location); // }
import javax.annotation.Nonnull; import javax.annotation.Nullable; import org.bukkit.Location; import org.bukkit.OfflinePlayer; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Projectile; import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageEvent; import tc.oc.tracker.DamageInfo; import tc.oc.tracker.DamageResolver; import tc.oc.tracker.Lifetime; import tc.oc.tracker.damage.DispensedProjectileDamageInfo; import tc.oc.tracker.trackers.DispenserTracker; import tc.oc.tracker.trackers.ProjectileDistanceTracker;
package tc.oc.tracker.damage.resolvers; public class DispensedProjectileDamageResolver implements DamageResolver { private final ProjectileDistanceTracker projectileDistanceTracker;
// Path: src/main/java/tc/oc/tracker/DamageInfo.java // public interface DamageInfo { // /** // * Gets the living entity most responsible for this damage. // * // * @return Resolved damager or null if none exists // */ // @Nullable LivingEntity getResolvedDamager(); // } // // Path: src/main/java/tc/oc/tracker/DamageResolver.java // public interface DamageResolver { // @Nullable DamageInfo resolve(@Nonnull LivingEntity entity, @Nonnull Lifetime lifetime, @Nonnull EntityDamageEvent damageEvent); // } // // Path: src/main/java/tc/oc/tracker/Lifetime.java // public interface Lifetime { // @Nullable Instant getStart(); // // void setStart(@Nonnull Instant start); // // @Nullable Instant getEnd(); // // void setEnd(@Nonnull Instant end); // // @Nonnull List<Damage> getDamage(); // // @Nonnull ListIterator<Damage> getDamageFirst(); // // @Nonnull ListIterator<Damage> getDamageLast(); // // @Nullable Damage getFirstDamage(); // // @Nullable Damage getLastDamage(); // // /** // * Gets the last damage instance where the info object is an instance of // * the specified class. Uses {@link Class#isInstance(Object)} to check info // * objects. // * // * @param damageInfoClass DamageInfo class to check for // * @return Last damage that matched or null if none matched // * // * @throws NullPointerException if damageInfoClass is null // */ // @Nullable Damage getLastDamage(@Nonnull Class<? extends DamageInfo> damageInfoClass); // // void addDamage(@Nonnull Damage damage); // } // // Path: src/main/java/tc/oc/tracker/damage/DispensedProjectileDamageInfo.java // public class DispensedProjectileDamageInfo extends ProjectileDamageInfo { // // public DispensedProjectileDamageInfo(@Nonnull Projectile projectile, @Nullable LivingEntity resolvedDamager, @Nullable Double projectileDistance, @Nullable OfflinePlayer dispenserOwner) { // super(projectile, resolvedDamager, projectileDistance); // // this.dispenserOwner = dispenserOwner; // } // // public @Nullable OfflinePlayer getdispenserOwner() { // return this.dispenserOwner; // } // // protected final @Nonnull OfflinePlayer dispenserOwner; // // @Override // public @Nonnull String toString() { // return "DispensedProjectileDamageInfo{shooter=" + this.resolvedDamager + ",projectile=" + this.projectile + ",distance=" + this.projectileDistance + ",dispenserOwner=" + this.dispenserOwner + "}"; // } // } // // Path: src/main/java/tc/oc/tracker/trackers/DispenserTracker.java // public interface DispenserTracker extends Tracker { // boolean hasOwner(@Nonnull Entity entity); // // @Nullable OfflinePlayer getOwner(@Nonnull Entity entity); // // @Nullable OfflinePlayer setOwner(@Nonnull Entity entity, @Nullable Player player); // // boolean hasPlacer(@Nonnull Block block); // // @Nullable OfflinePlayer getPlacer(@Nonnull Block block); // // @Nullable OfflinePlayer setPlacer(@Nonnull Block block, @Nullable Player player); // // @Nonnull OfflinePlayer clearPlacer(@Nonnull Block block); // } // // Path: src/main/java/tc/oc/tracker/trackers/ProjectileDistanceTracker.java // public interface ProjectileDistanceTracker extends Tracker { // boolean hasLaunchLocation(@Nonnull Projectile entity); // // @Nullable Location getLaunchLocation(@Nonnull Projectile projectile); // // @Nullable Location setLaunchLocation(@Nonnull Projectile projectile, @Nullable Location location); // } // Path: src/main/java/tc/oc/tracker/damage/resolvers/DispensedProjectileDamageResolver.java import javax.annotation.Nonnull; import javax.annotation.Nullable; import org.bukkit.Location; import org.bukkit.OfflinePlayer; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Projectile; import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageEvent; import tc.oc.tracker.DamageInfo; import tc.oc.tracker.DamageResolver; import tc.oc.tracker.Lifetime; import tc.oc.tracker.damage.DispensedProjectileDamageInfo; import tc.oc.tracker.trackers.DispenserTracker; import tc.oc.tracker.trackers.ProjectileDistanceTracker; package tc.oc.tracker.damage.resolvers; public class DispensedProjectileDamageResolver implements DamageResolver { private final ProjectileDistanceTracker projectileDistanceTracker;
private final DispenserTracker dispenserTracker;
OvercastNetwork/Tracker
src/main/java/tc/oc/tracker/damage/resolvers/DispensedProjectileDamageResolver.java
// Path: src/main/java/tc/oc/tracker/DamageInfo.java // public interface DamageInfo { // /** // * Gets the living entity most responsible for this damage. // * // * @return Resolved damager or null if none exists // */ // @Nullable LivingEntity getResolvedDamager(); // } // // Path: src/main/java/tc/oc/tracker/DamageResolver.java // public interface DamageResolver { // @Nullable DamageInfo resolve(@Nonnull LivingEntity entity, @Nonnull Lifetime lifetime, @Nonnull EntityDamageEvent damageEvent); // } // // Path: src/main/java/tc/oc/tracker/Lifetime.java // public interface Lifetime { // @Nullable Instant getStart(); // // void setStart(@Nonnull Instant start); // // @Nullable Instant getEnd(); // // void setEnd(@Nonnull Instant end); // // @Nonnull List<Damage> getDamage(); // // @Nonnull ListIterator<Damage> getDamageFirst(); // // @Nonnull ListIterator<Damage> getDamageLast(); // // @Nullable Damage getFirstDamage(); // // @Nullable Damage getLastDamage(); // // /** // * Gets the last damage instance where the info object is an instance of // * the specified class. Uses {@link Class#isInstance(Object)} to check info // * objects. // * // * @param damageInfoClass DamageInfo class to check for // * @return Last damage that matched or null if none matched // * // * @throws NullPointerException if damageInfoClass is null // */ // @Nullable Damage getLastDamage(@Nonnull Class<? extends DamageInfo> damageInfoClass); // // void addDamage(@Nonnull Damage damage); // } // // Path: src/main/java/tc/oc/tracker/damage/DispensedProjectileDamageInfo.java // public class DispensedProjectileDamageInfo extends ProjectileDamageInfo { // // public DispensedProjectileDamageInfo(@Nonnull Projectile projectile, @Nullable LivingEntity resolvedDamager, @Nullable Double projectileDistance, @Nullable OfflinePlayer dispenserOwner) { // super(projectile, resolvedDamager, projectileDistance); // // this.dispenserOwner = dispenserOwner; // } // // public @Nullable OfflinePlayer getdispenserOwner() { // return this.dispenserOwner; // } // // protected final @Nonnull OfflinePlayer dispenserOwner; // // @Override // public @Nonnull String toString() { // return "DispensedProjectileDamageInfo{shooter=" + this.resolvedDamager + ",projectile=" + this.projectile + ",distance=" + this.projectileDistance + ",dispenserOwner=" + this.dispenserOwner + "}"; // } // } // // Path: src/main/java/tc/oc/tracker/trackers/DispenserTracker.java // public interface DispenserTracker extends Tracker { // boolean hasOwner(@Nonnull Entity entity); // // @Nullable OfflinePlayer getOwner(@Nonnull Entity entity); // // @Nullable OfflinePlayer setOwner(@Nonnull Entity entity, @Nullable Player player); // // boolean hasPlacer(@Nonnull Block block); // // @Nullable OfflinePlayer getPlacer(@Nonnull Block block); // // @Nullable OfflinePlayer setPlacer(@Nonnull Block block, @Nullable Player player); // // @Nonnull OfflinePlayer clearPlacer(@Nonnull Block block); // } // // Path: src/main/java/tc/oc/tracker/trackers/ProjectileDistanceTracker.java // public interface ProjectileDistanceTracker extends Tracker { // boolean hasLaunchLocation(@Nonnull Projectile entity); // // @Nullable Location getLaunchLocation(@Nonnull Projectile projectile); // // @Nullable Location setLaunchLocation(@Nonnull Projectile projectile, @Nullable Location location); // }
import javax.annotation.Nonnull; import javax.annotation.Nullable; import org.bukkit.Location; import org.bukkit.OfflinePlayer; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Projectile; import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageEvent; import tc.oc.tracker.DamageInfo; import tc.oc.tracker.DamageResolver; import tc.oc.tracker.Lifetime; import tc.oc.tracker.damage.DispensedProjectileDamageInfo; import tc.oc.tracker.trackers.DispenserTracker; import tc.oc.tracker.trackers.ProjectileDistanceTracker;
package tc.oc.tracker.damage.resolvers; public class DispensedProjectileDamageResolver implements DamageResolver { private final ProjectileDistanceTracker projectileDistanceTracker; private final DispenserTracker dispenserTracker; public DispensedProjectileDamageResolver(ProjectileDistanceTracker projectileDistanceTracker, DispenserTracker dispenserTracker) { this.projectileDistanceTracker = projectileDistanceTracker; this.dispenserTracker = dispenserTracker; }
// Path: src/main/java/tc/oc/tracker/DamageInfo.java // public interface DamageInfo { // /** // * Gets the living entity most responsible for this damage. // * // * @return Resolved damager or null if none exists // */ // @Nullable LivingEntity getResolvedDamager(); // } // // Path: src/main/java/tc/oc/tracker/DamageResolver.java // public interface DamageResolver { // @Nullable DamageInfo resolve(@Nonnull LivingEntity entity, @Nonnull Lifetime lifetime, @Nonnull EntityDamageEvent damageEvent); // } // // Path: src/main/java/tc/oc/tracker/Lifetime.java // public interface Lifetime { // @Nullable Instant getStart(); // // void setStart(@Nonnull Instant start); // // @Nullable Instant getEnd(); // // void setEnd(@Nonnull Instant end); // // @Nonnull List<Damage> getDamage(); // // @Nonnull ListIterator<Damage> getDamageFirst(); // // @Nonnull ListIterator<Damage> getDamageLast(); // // @Nullable Damage getFirstDamage(); // // @Nullable Damage getLastDamage(); // // /** // * Gets the last damage instance where the info object is an instance of // * the specified class. Uses {@link Class#isInstance(Object)} to check info // * objects. // * // * @param damageInfoClass DamageInfo class to check for // * @return Last damage that matched or null if none matched // * // * @throws NullPointerException if damageInfoClass is null // */ // @Nullable Damage getLastDamage(@Nonnull Class<? extends DamageInfo> damageInfoClass); // // void addDamage(@Nonnull Damage damage); // } // // Path: src/main/java/tc/oc/tracker/damage/DispensedProjectileDamageInfo.java // public class DispensedProjectileDamageInfo extends ProjectileDamageInfo { // // public DispensedProjectileDamageInfo(@Nonnull Projectile projectile, @Nullable LivingEntity resolvedDamager, @Nullable Double projectileDistance, @Nullable OfflinePlayer dispenserOwner) { // super(projectile, resolvedDamager, projectileDistance); // // this.dispenserOwner = dispenserOwner; // } // // public @Nullable OfflinePlayer getdispenserOwner() { // return this.dispenserOwner; // } // // protected final @Nonnull OfflinePlayer dispenserOwner; // // @Override // public @Nonnull String toString() { // return "DispensedProjectileDamageInfo{shooter=" + this.resolvedDamager + ",projectile=" + this.projectile + ",distance=" + this.projectileDistance + ",dispenserOwner=" + this.dispenserOwner + "}"; // } // } // // Path: src/main/java/tc/oc/tracker/trackers/DispenserTracker.java // public interface DispenserTracker extends Tracker { // boolean hasOwner(@Nonnull Entity entity); // // @Nullable OfflinePlayer getOwner(@Nonnull Entity entity); // // @Nullable OfflinePlayer setOwner(@Nonnull Entity entity, @Nullable Player player); // // boolean hasPlacer(@Nonnull Block block); // // @Nullable OfflinePlayer getPlacer(@Nonnull Block block); // // @Nullable OfflinePlayer setPlacer(@Nonnull Block block, @Nullable Player player); // // @Nonnull OfflinePlayer clearPlacer(@Nonnull Block block); // } // // Path: src/main/java/tc/oc/tracker/trackers/ProjectileDistanceTracker.java // public interface ProjectileDistanceTracker extends Tracker { // boolean hasLaunchLocation(@Nonnull Projectile entity); // // @Nullable Location getLaunchLocation(@Nonnull Projectile projectile); // // @Nullable Location setLaunchLocation(@Nonnull Projectile projectile, @Nullable Location location); // } // Path: src/main/java/tc/oc/tracker/damage/resolvers/DispensedProjectileDamageResolver.java import javax.annotation.Nonnull; import javax.annotation.Nullable; import org.bukkit.Location; import org.bukkit.OfflinePlayer; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Projectile; import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageEvent; import tc.oc.tracker.DamageInfo; import tc.oc.tracker.DamageResolver; import tc.oc.tracker.Lifetime; import tc.oc.tracker.damage.DispensedProjectileDamageInfo; import tc.oc.tracker.trackers.DispenserTracker; import tc.oc.tracker.trackers.ProjectileDistanceTracker; package tc.oc.tracker.damage.resolvers; public class DispensedProjectileDamageResolver implements DamageResolver { private final ProjectileDistanceTracker projectileDistanceTracker; private final DispenserTracker dispenserTracker; public DispensedProjectileDamageResolver(ProjectileDistanceTracker projectileDistanceTracker, DispenserTracker dispenserTracker) { this.projectileDistanceTracker = projectileDistanceTracker; this.dispenserTracker = dispenserTracker; }
public @Nullable DamageInfo resolve(@Nonnull LivingEntity entity, @Nonnull Lifetime lifetime, @Nonnull EntityDamageEvent damageEvent) {
OvercastNetwork/Tracker
src/main/java/tc/oc/tracker/damage/resolvers/DispensedProjectileDamageResolver.java
// Path: src/main/java/tc/oc/tracker/DamageInfo.java // public interface DamageInfo { // /** // * Gets the living entity most responsible for this damage. // * // * @return Resolved damager or null if none exists // */ // @Nullable LivingEntity getResolvedDamager(); // } // // Path: src/main/java/tc/oc/tracker/DamageResolver.java // public interface DamageResolver { // @Nullable DamageInfo resolve(@Nonnull LivingEntity entity, @Nonnull Lifetime lifetime, @Nonnull EntityDamageEvent damageEvent); // } // // Path: src/main/java/tc/oc/tracker/Lifetime.java // public interface Lifetime { // @Nullable Instant getStart(); // // void setStart(@Nonnull Instant start); // // @Nullable Instant getEnd(); // // void setEnd(@Nonnull Instant end); // // @Nonnull List<Damage> getDamage(); // // @Nonnull ListIterator<Damage> getDamageFirst(); // // @Nonnull ListIterator<Damage> getDamageLast(); // // @Nullable Damage getFirstDamage(); // // @Nullable Damage getLastDamage(); // // /** // * Gets the last damage instance where the info object is an instance of // * the specified class. Uses {@link Class#isInstance(Object)} to check info // * objects. // * // * @param damageInfoClass DamageInfo class to check for // * @return Last damage that matched or null if none matched // * // * @throws NullPointerException if damageInfoClass is null // */ // @Nullable Damage getLastDamage(@Nonnull Class<? extends DamageInfo> damageInfoClass); // // void addDamage(@Nonnull Damage damage); // } // // Path: src/main/java/tc/oc/tracker/damage/DispensedProjectileDamageInfo.java // public class DispensedProjectileDamageInfo extends ProjectileDamageInfo { // // public DispensedProjectileDamageInfo(@Nonnull Projectile projectile, @Nullable LivingEntity resolvedDamager, @Nullable Double projectileDistance, @Nullable OfflinePlayer dispenserOwner) { // super(projectile, resolvedDamager, projectileDistance); // // this.dispenserOwner = dispenserOwner; // } // // public @Nullable OfflinePlayer getdispenserOwner() { // return this.dispenserOwner; // } // // protected final @Nonnull OfflinePlayer dispenserOwner; // // @Override // public @Nonnull String toString() { // return "DispensedProjectileDamageInfo{shooter=" + this.resolvedDamager + ",projectile=" + this.projectile + ",distance=" + this.projectileDistance + ",dispenserOwner=" + this.dispenserOwner + "}"; // } // } // // Path: src/main/java/tc/oc/tracker/trackers/DispenserTracker.java // public interface DispenserTracker extends Tracker { // boolean hasOwner(@Nonnull Entity entity); // // @Nullable OfflinePlayer getOwner(@Nonnull Entity entity); // // @Nullable OfflinePlayer setOwner(@Nonnull Entity entity, @Nullable Player player); // // boolean hasPlacer(@Nonnull Block block); // // @Nullable OfflinePlayer getPlacer(@Nonnull Block block); // // @Nullable OfflinePlayer setPlacer(@Nonnull Block block, @Nullable Player player); // // @Nonnull OfflinePlayer clearPlacer(@Nonnull Block block); // } // // Path: src/main/java/tc/oc/tracker/trackers/ProjectileDistanceTracker.java // public interface ProjectileDistanceTracker extends Tracker { // boolean hasLaunchLocation(@Nonnull Projectile entity); // // @Nullable Location getLaunchLocation(@Nonnull Projectile projectile); // // @Nullable Location setLaunchLocation(@Nonnull Projectile projectile, @Nullable Location location); // }
import javax.annotation.Nonnull; import javax.annotation.Nullable; import org.bukkit.Location; import org.bukkit.OfflinePlayer; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Projectile; import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageEvent; import tc.oc.tracker.DamageInfo; import tc.oc.tracker.DamageResolver; import tc.oc.tracker.Lifetime; import tc.oc.tracker.damage.DispensedProjectileDamageInfo; import tc.oc.tracker.trackers.DispenserTracker; import tc.oc.tracker.trackers.ProjectileDistanceTracker;
package tc.oc.tracker.damage.resolvers; public class DispensedProjectileDamageResolver implements DamageResolver { private final ProjectileDistanceTracker projectileDistanceTracker; private final DispenserTracker dispenserTracker; public DispensedProjectileDamageResolver(ProjectileDistanceTracker projectileDistanceTracker, DispenserTracker dispenserTracker) { this.projectileDistanceTracker = projectileDistanceTracker; this.dispenserTracker = dispenserTracker; }
// Path: src/main/java/tc/oc/tracker/DamageInfo.java // public interface DamageInfo { // /** // * Gets the living entity most responsible for this damage. // * // * @return Resolved damager or null if none exists // */ // @Nullable LivingEntity getResolvedDamager(); // } // // Path: src/main/java/tc/oc/tracker/DamageResolver.java // public interface DamageResolver { // @Nullable DamageInfo resolve(@Nonnull LivingEntity entity, @Nonnull Lifetime lifetime, @Nonnull EntityDamageEvent damageEvent); // } // // Path: src/main/java/tc/oc/tracker/Lifetime.java // public interface Lifetime { // @Nullable Instant getStart(); // // void setStart(@Nonnull Instant start); // // @Nullable Instant getEnd(); // // void setEnd(@Nonnull Instant end); // // @Nonnull List<Damage> getDamage(); // // @Nonnull ListIterator<Damage> getDamageFirst(); // // @Nonnull ListIterator<Damage> getDamageLast(); // // @Nullable Damage getFirstDamage(); // // @Nullable Damage getLastDamage(); // // /** // * Gets the last damage instance where the info object is an instance of // * the specified class. Uses {@link Class#isInstance(Object)} to check info // * objects. // * // * @param damageInfoClass DamageInfo class to check for // * @return Last damage that matched or null if none matched // * // * @throws NullPointerException if damageInfoClass is null // */ // @Nullable Damage getLastDamage(@Nonnull Class<? extends DamageInfo> damageInfoClass); // // void addDamage(@Nonnull Damage damage); // } // // Path: src/main/java/tc/oc/tracker/damage/DispensedProjectileDamageInfo.java // public class DispensedProjectileDamageInfo extends ProjectileDamageInfo { // // public DispensedProjectileDamageInfo(@Nonnull Projectile projectile, @Nullable LivingEntity resolvedDamager, @Nullable Double projectileDistance, @Nullable OfflinePlayer dispenserOwner) { // super(projectile, resolvedDamager, projectileDistance); // // this.dispenserOwner = dispenserOwner; // } // // public @Nullable OfflinePlayer getdispenserOwner() { // return this.dispenserOwner; // } // // protected final @Nonnull OfflinePlayer dispenserOwner; // // @Override // public @Nonnull String toString() { // return "DispensedProjectileDamageInfo{shooter=" + this.resolvedDamager + ",projectile=" + this.projectile + ",distance=" + this.projectileDistance + ",dispenserOwner=" + this.dispenserOwner + "}"; // } // } // // Path: src/main/java/tc/oc/tracker/trackers/DispenserTracker.java // public interface DispenserTracker extends Tracker { // boolean hasOwner(@Nonnull Entity entity); // // @Nullable OfflinePlayer getOwner(@Nonnull Entity entity); // // @Nullable OfflinePlayer setOwner(@Nonnull Entity entity, @Nullable Player player); // // boolean hasPlacer(@Nonnull Block block); // // @Nullable OfflinePlayer getPlacer(@Nonnull Block block); // // @Nullable OfflinePlayer setPlacer(@Nonnull Block block, @Nullable Player player); // // @Nonnull OfflinePlayer clearPlacer(@Nonnull Block block); // } // // Path: src/main/java/tc/oc/tracker/trackers/ProjectileDistanceTracker.java // public interface ProjectileDistanceTracker extends Tracker { // boolean hasLaunchLocation(@Nonnull Projectile entity); // // @Nullable Location getLaunchLocation(@Nonnull Projectile projectile); // // @Nullable Location setLaunchLocation(@Nonnull Projectile projectile, @Nullable Location location); // } // Path: src/main/java/tc/oc/tracker/damage/resolvers/DispensedProjectileDamageResolver.java import javax.annotation.Nonnull; import javax.annotation.Nullable; import org.bukkit.Location; import org.bukkit.OfflinePlayer; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Projectile; import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageEvent; import tc.oc.tracker.DamageInfo; import tc.oc.tracker.DamageResolver; import tc.oc.tracker.Lifetime; import tc.oc.tracker.damage.DispensedProjectileDamageInfo; import tc.oc.tracker.trackers.DispenserTracker; import tc.oc.tracker.trackers.ProjectileDistanceTracker; package tc.oc.tracker.damage.resolvers; public class DispensedProjectileDamageResolver implements DamageResolver { private final ProjectileDistanceTracker projectileDistanceTracker; private final DispenserTracker dispenserTracker; public DispensedProjectileDamageResolver(ProjectileDistanceTracker projectileDistanceTracker, DispenserTracker dispenserTracker) { this.projectileDistanceTracker = projectileDistanceTracker; this.dispenserTracker = dispenserTracker; }
public @Nullable DamageInfo resolve(@Nonnull LivingEntity entity, @Nonnull Lifetime lifetime, @Nonnull EntityDamageEvent damageEvent) {
OvercastNetwork/Tracker
src/main/java/tc/oc/tracker/damage/resolvers/DispensedProjectileDamageResolver.java
// Path: src/main/java/tc/oc/tracker/DamageInfo.java // public interface DamageInfo { // /** // * Gets the living entity most responsible for this damage. // * // * @return Resolved damager or null if none exists // */ // @Nullable LivingEntity getResolvedDamager(); // } // // Path: src/main/java/tc/oc/tracker/DamageResolver.java // public interface DamageResolver { // @Nullable DamageInfo resolve(@Nonnull LivingEntity entity, @Nonnull Lifetime lifetime, @Nonnull EntityDamageEvent damageEvent); // } // // Path: src/main/java/tc/oc/tracker/Lifetime.java // public interface Lifetime { // @Nullable Instant getStart(); // // void setStart(@Nonnull Instant start); // // @Nullable Instant getEnd(); // // void setEnd(@Nonnull Instant end); // // @Nonnull List<Damage> getDamage(); // // @Nonnull ListIterator<Damage> getDamageFirst(); // // @Nonnull ListIterator<Damage> getDamageLast(); // // @Nullable Damage getFirstDamage(); // // @Nullable Damage getLastDamage(); // // /** // * Gets the last damage instance where the info object is an instance of // * the specified class. Uses {@link Class#isInstance(Object)} to check info // * objects. // * // * @param damageInfoClass DamageInfo class to check for // * @return Last damage that matched or null if none matched // * // * @throws NullPointerException if damageInfoClass is null // */ // @Nullable Damage getLastDamage(@Nonnull Class<? extends DamageInfo> damageInfoClass); // // void addDamage(@Nonnull Damage damage); // } // // Path: src/main/java/tc/oc/tracker/damage/DispensedProjectileDamageInfo.java // public class DispensedProjectileDamageInfo extends ProjectileDamageInfo { // // public DispensedProjectileDamageInfo(@Nonnull Projectile projectile, @Nullable LivingEntity resolvedDamager, @Nullable Double projectileDistance, @Nullable OfflinePlayer dispenserOwner) { // super(projectile, resolvedDamager, projectileDistance); // // this.dispenserOwner = dispenserOwner; // } // // public @Nullable OfflinePlayer getdispenserOwner() { // return this.dispenserOwner; // } // // protected final @Nonnull OfflinePlayer dispenserOwner; // // @Override // public @Nonnull String toString() { // return "DispensedProjectileDamageInfo{shooter=" + this.resolvedDamager + ",projectile=" + this.projectile + ",distance=" + this.projectileDistance + ",dispenserOwner=" + this.dispenserOwner + "}"; // } // } // // Path: src/main/java/tc/oc/tracker/trackers/DispenserTracker.java // public interface DispenserTracker extends Tracker { // boolean hasOwner(@Nonnull Entity entity); // // @Nullable OfflinePlayer getOwner(@Nonnull Entity entity); // // @Nullable OfflinePlayer setOwner(@Nonnull Entity entity, @Nullable Player player); // // boolean hasPlacer(@Nonnull Block block); // // @Nullable OfflinePlayer getPlacer(@Nonnull Block block); // // @Nullable OfflinePlayer setPlacer(@Nonnull Block block, @Nullable Player player); // // @Nonnull OfflinePlayer clearPlacer(@Nonnull Block block); // } // // Path: src/main/java/tc/oc/tracker/trackers/ProjectileDistanceTracker.java // public interface ProjectileDistanceTracker extends Tracker { // boolean hasLaunchLocation(@Nonnull Projectile entity); // // @Nullable Location getLaunchLocation(@Nonnull Projectile projectile); // // @Nullable Location setLaunchLocation(@Nonnull Projectile projectile, @Nullable Location location); // }
import javax.annotation.Nonnull; import javax.annotation.Nullable; import org.bukkit.Location; import org.bukkit.OfflinePlayer; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Projectile; import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageEvent; import tc.oc.tracker.DamageInfo; import tc.oc.tracker.DamageResolver; import tc.oc.tracker.Lifetime; import tc.oc.tracker.damage.DispensedProjectileDamageInfo; import tc.oc.tracker.trackers.DispenserTracker; import tc.oc.tracker.trackers.ProjectileDistanceTracker;
package tc.oc.tracker.damage.resolvers; public class DispensedProjectileDamageResolver implements DamageResolver { private final ProjectileDistanceTracker projectileDistanceTracker; private final DispenserTracker dispenserTracker; public DispensedProjectileDamageResolver(ProjectileDistanceTracker projectileDistanceTracker, DispenserTracker dispenserTracker) { this.projectileDistanceTracker = projectileDistanceTracker; this.dispenserTracker = dispenserTracker; } public @Nullable DamageInfo resolve(@Nonnull LivingEntity entity, @Nonnull Lifetime lifetime, @Nonnull EntityDamageEvent damageEvent) { if(damageEvent instanceof EntityDamageByEntityEvent) { EntityDamageByEntityEvent event = (EntityDamageByEntityEvent) damageEvent; if(event.getDamager() instanceof Projectile) { Projectile projectile = (Projectile) event.getDamager(); Location launchLocation = this.projectileDistanceTracker.getLaunchLocation(projectile); Double projectileDistance = null; OfflinePlayer dispenserOwner = dispenserTracker.getOwner(projectile); if(launchLocation != null) projectileDistance = event.getEntity().getLocation().distance(launchLocation); if(projectile.getShooter() instanceof LivingEntity) {
// Path: src/main/java/tc/oc/tracker/DamageInfo.java // public interface DamageInfo { // /** // * Gets the living entity most responsible for this damage. // * // * @return Resolved damager or null if none exists // */ // @Nullable LivingEntity getResolvedDamager(); // } // // Path: src/main/java/tc/oc/tracker/DamageResolver.java // public interface DamageResolver { // @Nullable DamageInfo resolve(@Nonnull LivingEntity entity, @Nonnull Lifetime lifetime, @Nonnull EntityDamageEvent damageEvent); // } // // Path: src/main/java/tc/oc/tracker/Lifetime.java // public interface Lifetime { // @Nullable Instant getStart(); // // void setStart(@Nonnull Instant start); // // @Nullable Instant getEnd(); // // void setEnd(@Nonnull Instant end); // // @Nonnull List<Damage> getDamage(); // // @Nonnull ListIterator<Damage> getDamageFirst(); // // @Nonnull ListIterator<Damage> getDamageLast(); // // @Nullable Damage getFirstDamage(); // // @Nullable Damage getLastDamage(); // // /** // * Gets the last damage instance where the info object is an instance of // * the specified class. Uses {@link Class#isInstance(Object)} to check info // * objects. // * // * @param damageInfoClass DamageInfo class to check for // * @return Last damage that matched or null if none matched // * // * @throws NullPointerException if damageInfoClass is null // */ // @Nullable Damage getLastDamage(@Nonnull Class<? extends DamageInfo> damageInfoClass); // // void addDamage(@Nonnull Damage damage); // } // // Path: src/main/java/tc/oc/tracker/damage/DispensedProjectileDamageInfo.java // public class DispensedProjectileDamageInfo extends ProjectileDamageInfo { // // public DispensedProjectileDamageInfo(@Nonnull Projectile projectile, @Nullable LivingEntity resolvedDamager, @Nullable Double projectileDistance, @Nullable OfflinePlayer dispenserOwner) { // super(projectile, resolvedDamager, projectileDistance); // // this.dispenserOwner = dispenserOwner; // } // // public @Nullable OfflinePlayer getdispenserOwner() { // return this.dispenserOwner; // } // // protected final @Nonnull OfflinePlayer dispenserOwner; // // @Override // public @Nonnull String toString() { // return "DispensedProjectileDamageInfo{shooter=" + this.resolvedDamager + ",projectile=" + this.projectile + ",distance=" + this.projectileDistance + ",dispenserOwner=" + this.dispenserOwner + "}"; // } // } // // Path: src/main/java/tc/oc/tracker/trackers/DispenserTracker.java // public interface DispenserTracker extends Tracker { // boolean hasOwner(@Nonnull Entity entity); // // @Nullable OfflinePlayer getOwner(@Nonnull Entity entity); // // @Nullable OfflinePlayer setOwner(@Nonnull Entity entity, @Nullable Player player); // // boolean hasPlacer(@Nonnull Block block); // // @Nullable OfflinePlayer getPlacer(@Nonnull Block block); // // @Nullable OfflinePlayer setPlacer(@Nonnull Block block, @Nullable Player player); // // @Nonnull OfflinePlayer clearPlacer(@Nonnull Block block); // } // // Path: src/main/java/tc/oc/tracker/trackers/ProjectileDistanceTracker.java // public interface ProjectileDistanceTracker extends Tracker { // boolean hasLaunchLocation(@Nonnull Projectile entity); // // @Nullable Location getLaunchLocation(@Nonnull Projectile projectile); // // @Nullable Location setLaunchLocation(@Nonnull Projectile projectile, @Nullable Location location); // } // Path: src/main/java/tc/oc/tracker/damage/resolvers/DispensedProjectileDamageResolver.java import javax.annotation.Nonnull; import javax.annotation.Nullable; import org.bukkit.Location; import org.bukkit.OfflinePlayer; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Projectile; import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageEvent; import tc.oc.tracker.DamageInfo; import tc.oc.tracker.DamageResolver; import tc.oc.tracker.Lifetime; import tc.oc.tracker.damage.DispensedProjectileDamageInfo; import tc.oc.tracker.trackers.DispenserTracker; import tc.oc.tracker.trackers.ProjectileDistanceTracker; package tc.oc.tracker.damage.resolvers; public class DispensedProjectileDamageResolver implements DamageResolver { private final ProjectileDistanceTracker projectileDistanceTracker; private final DispenserTracker dispenserTracker; public DispensedProjectileDamageResolver(ProjectileDistanceTracker projectileDistanceTracker, DispenserTracker dispenserTracker) { this.projectileDistanceTracker = projectileDistanceTracker; this.dispenserTracker = dispenserTracker; } public @Nullable DamageInfo resolve(@Nonnull LivingEntity entity, @Nonnull Lifetime lifetime, @Nonnull EntityDamageEvent damageEvent) { if(damageEvent instanceof EntityDamageByEntityEvent) { EntityDamageByEntityEvent event = (EntityDamageByEntityEvent) damageEvent; if(event.getDamager() instanceof Projectile) { Projectile projectile = (Projectile) event.getDamager(); Location launchLocation = this.projectileDistanceTracker.getLaunchLocation(projectile); Double projectileDistance = null; OfflinePlayer dispenserOwner = dispenserTracker.getOwner(projectile); if(launchLocation != null) projectileDistance = event.getEntity().getLocation().distance(launchLocation); if(projectile.getShooter() instanceof LivingEntity) {
return new DispensedProjectileDamageInfo(projectile, (LivingEntity) projectile.getShooter(), projectileDistance, dispenserOwner);
OvercastNetwork/Tracker
src/main/java/tc/oc/tracker/damage/resolvers/VoidDamageResolver.java
// Path: src/main/java/tc/oc/tracker/DamageInfo.java // public interface DamageInfo { // /** // * Gets the living entity most responsible for this damage. // * // * @return Resolved damager or null if none exists // */ // @Nullable LivingEntity getResolvedDamager(); // } // // Path: src/main/java/tc/oc/tracker/DamageResolver.java // public interface DamageResolver { // @Nullable DamageInfo resolve(@Nonnull LivingEntity entity, @Nonnull Lifetime lifetime, @Nonnull EntityDamageEvent damageEvent); // } // // Path: src/main/java/tc/oc/tracker/Lifetime.java // public interface Lifetime { // @Nullable Instant getStart(); // // void setStart(@Nonnull Instant start); // // @Nullable Instant getEnd(); // // void setEnd(@Nonnull Instant end); // // @Nonnull List<Damage> getDamage(); // // @Nonnull ListIterator<Damage> getDamageFirst(); // // @Nonnull ListIterator<Damage> getDamageLast(); // // @Nullable Damage getFirstDamage(); // // @Nullable Damage getLastDamage(); // // /** // * Gets the last damage instance where the info object is an instance of // * the specified class. Uses {@link Class#isInstance(Object)} to check info // * objects. // * // * @param damageInfoClass DamageInfo class to check for // * @return Last damage that matched or null if none matched // * // * @throws NullPointerException if damageInfoClass is null // */ // @Nullable Damage getLastDamage(@Nonnull Class<? extends DamageInfo> damageInfoClass); // // void addDamage(@Nonnull Damage damage); // } // // Path: src/main/java/tc/oc/tracker/damage/base/SimpleVoidDamageInfo.java // public class SimpleVoidDamageInfo extends AbstractDamageInfo implements VoidDamageInfo { // public SimpleVoidDamageInfo(@Nullable LivingEntity resolvedDamager) { // super(resolvedDamager); // } // }
import javax.annotation.Nonnull; import javax.annotation.Nullable; import org.bukkit.entity.LivingEntity; import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import tc.oc.tracker.DamageInfo; import tc.oc.tracker.DamageResolver; import tc.oc.tracker.Lifetime; import tc.oc.tracker.damage.base.SimpleVoidDamageInfo;
package tc.oc.tracker.damage.resolvers; public class VoidDamageResolver implements DamageResolver { public @Nullable DamageInfo resolve(@Nonnull LivingEntity entity, @Nonnull Lifetime lifetime, @Nonnull EntityDamageEvent damageEvent) { if(damageEvent.getCause() == DamageCause.VOID) {
// Path: src/main/java/tc/oc/tracker/DamageInfo.java // public interface DamageInfo { // /** // * Gets the living entity most responsible for this damage. // * // * @return Resolved damager or null if none exists // */ // @Nullable LivingEntity getResolvedDamager(); // } // // Path: src/main/java/tc/oc/tracker/DamageResolver.java // public interface DamageResolver { // @Nullable DamageInfo resolve(@Nonnull LivingEntity entity, @Nonnull Lifetime lifetime, @Nonnull EntityDamageEvent damageEvent); // } // // Path: src/main/java/tc/oc/tracker/Lifetime.java // public interface Lifetime { // @Nullable Instant getStart(); // // void setStart(@Nonnull Instant start); // // @Nullable Instant getEnd(); // // void setEnd(@Nonnull Instant end); // // @Nonnull List<Damage> getDamage(); // // @Nonnull ListIterator<Damage> getDamageFirst(); // // @Nonnull ListIterator<Damage> getDamageLast(); // // @Nullable Damage getFirstDamage(); // // @Nullable Damage getLastDamage(); // // /** // * Gets the last damage instance where the info object is an instance of // * the specified class. Uses {@link Class#isInstance(Object)} to check info // * objects. // * // * @param damageInfoClass DamageInfo class to check for // * @return Last damage that matched or null if none matched // * // * @throws NullPointerException if damageInfoClass is null // */ // @Nullable Damage getLastDamage(@Nonnull Class<? extends DamageInfo> damageInfoClass); // // void addDamage(@Nonnull Damage damage); // } // // Path: src/main/java/tc/oc/tracker/damage/base/SimpleVoidDamageInfo.java // public class SimpleVoidDamageInfo extends AbstractDamageInfo implements VoidDamageInfo { // public SimpleVoidDamageInfo(@Nullable LivingEntity resolvedDamager) { // super(resolvedDamager); // } // } // Path: src/main/java/tc/oc/tracker/damage/resolvers/VoidDamageResolver.java import javax.annotation.Nonnull; import javax.annotation.Nullable; import org.bukkit.entity.LivingEntity; import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import tc.oc.tracker.DamageInfo; import tc.oc.tracker.DamageResolver; import tc.oc.tracker.Lifetime; import tc.oc.tracker.damage.base.SimpleVoidDamageInfo; package tc.oc.tracker.damage.resolvers; public class VoidDamageResolver implements DamageResolver { public @Nullable DamageInfo resolve(@Nonnull LivingEntity entity, @Nonnull Lifetime lifetime, @Nonnull EntityDamageEvent damageEvent) { if(damageEvent.getCause() == DamageCause.VOID) {
return new SimpleVoidDamageInfo(null);
OvercastNetwork/Tracker
src/main/java/tc/oc/tracker/plugin/LifetimeListener.java
// Path: src/main/java/tc/oc/tracker/Lifetimes.java // public final class Lifetimes { // private Lifetimes() { } // // public static @Nonnull LifetimeManager getManager() { // if(manager == null) { // manager = new SimpleLifetimeManager(); // } // return manager; // } // // public static @Nonnull Lifetime getLifetime(@Nonnull LivingEntity entity) { // return getManager().getLifetime(entity); // } // // private static @Nullable LifetimeManager manager; // }
import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerRespawnEvent; import tc.oc.tracker.Lifetimes;
package tc.oc.tracker.plugin; public class LifetimeListener implements Listener { @EventHandler(priority = EventPriority.LOWEST) public void onPlayerRespawn(final PlayerRespawnEvent event) {
// Path: src/main/java/tc/oc/tracker/Lifetimes.java // public final class Lifetimes { // private Lifetimes() { } // // public static @Nonnull LifetimeManager getManager() { // if(manager == null) { // manager = new SimpleLifetimeManager(); // } // return manager; // } // // public static @Nonnull Lifetime getLifetime(@Nonnull LivingEntity entity) { // return getManager().getLifetime(entity); // } // // private static @Nullable LifetimeManager manager; // } // Path: src/main/java/tc/oc/tracker/plugin/LifetimeListener.java import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerRespawnEvent; import tc.oc.tracker.Lifetimes; package tc.oc.tracker.plugin; public class LifetimeListener implements Listener { @EventHandler(priority = EventPriority.LOWEST) public void onPlayerRespawn(final PlayerRespawnEvent event) {
Lifetimes.getManager().newLifetime(event.getPlayer());
OvercastNetwork/Tracker
src/main/java/tc/oc/tracker/damage/resolvers/BlockDamageResolver.java
// Path: src/main/java/tc/oc/tracker/DamageInfo.java // public interface DamageInfo { // /** // * Gets the living entity most responsible for this damage. // * // * @return Resolved damager or null if none exists // */ // @Nullable LivingEntity getResolvedDamager(); // } // // Path: src/main/java/tc/oc/tracker/DamageResolver.java // public interface DamageResolver { // @Nullable DamageInfo resolve(@Nonnull LivingEntity entity, @Nonnull Lifetime lifetime, @Nonnull EntityDamageEvent damageEvent); // } // // Path: src/main/java/tc/oc/tracker/Lifetime.java // public interface Lifetime { // @Nullable Instant getStart(); // // void setStart(@Nonnull Instant start); // // @Nullable Instant getEnd(); // // void setEnd(@Nonnull Instant end); // // @Nonnull List<Damage> getDamage(); // // @Nonnull ListIterator<Damage> getDamageFirst(); // // @Nonnull ListIterator<Damage> getDamageLast(); // // @Nullable Damage getFirstDamage(); // // @Nullable Damage getLastDamage(); // // /** // * Gets the last damage instance where the info object is an instance of // * the specified class. Uses {@link Class#isInstance(Object)} to check info // * objects. // * // * @param damageInfoClass DamageInfo class to check for // * @return Last damage that matched or null if none matched // * // * @throws NullPointerException if damageInfoClass is null // */ // @Nullable Damage getLastDamage(@Nonnull Class<? extends DamageInfo> damageInfoClass); // // void addDamage(@Nonnull Damage damage); // } // // Path: src/main/java/tc/oc/tracker/damage/base/SimpleBlockDamageInfo.java // public class SimpleBlockDamageInfo extends AbstractBlockDamageInfo { // public SimpleBlockDamageInfo(@Nonnull BlockState blockDamager) { // super(null, blockDamager); // } // }
import javax.annotation.Nonnull; import javax.annotation.Nullable; import org.bukkit.entity.LivingEntity; import org.bukkit.event.entity.EntityDamageByBlockEvent; import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import tc.oc.tracker.DamageInfo; import tc.oc.tracker.DamageResolver; import tc.oc.tracker.Lifetime; import tc.oc.tracker.damage.base.SimpleBlockDamageInfo;
package tc.oc.tracker.damage.resolvers; public class BlockDamageResolver implements DamageResolver { public @Nullable DamageInfo resolve(@Nonnull LivingEntity entity, @Nonnull Lifetime lifetime, @Nonnull EntityDamageEvent damageEvent) { if(damageEvent instanceof EntityDamageByBlockEvent && damageEvent.getCause() == DamageCause.CONTACT) { EntityDamageByBlockEvent blockEvent = (EntityDamageByBlockEvent) damageEvent;
// Path: src/main/java/tc/oc/tracker/DamageInfo.java // public interface DamageInfo { // /** // * Gets the living entity most responsible for this damage. // * // * @return Resolved damager or null if none exists // */ // @Nullable LivingEntity getResolvedDamager(); // } // // Path: src/main/java/tc/oc/tracker/DamageResolver.java // public interface DamageResolver { // @Nullable DamageInfo resolve(@Nonnull LivingEntity entity, @Nonnull Lifetime lifetime, @Nonnull EntityDamageEvent damageEvent); // } // // Path: src/main/java/tc/oc/tracker/Lifetime.java // public interface Lifetime { // @Nullable Instant getStart(); // // void setStart(@Nonnull Instant start); // // @Nullable Instant getEnd(); // // void setEnd(@Nonnull Instant end); // // @Nonnull List<Damage> getDamage(); // // @Nonnull ListIterator<Damage> getDamageFirst(); // // @Nonnull ListIterator<Damage> getDamageLast(); // // @Nullable Damage getFirstDamage(); // // @Nullable Damage getLastDamage(); // // /** // * Gets the last damage instance where the info object is an instance of // * the specified class. Uses {@link Class#isInstance(Object)} to check info // * objects. // * // * @param damageInfoClass DamageInfo class to check for // * @return Last damage that matched or null if none matched // * // * @throws NullPointerException if damageInfoClass is null // */ // @Nullable Damage getLastDamage(@Nonnull Class<? extends DamageInfo> damageInfoClass); // // void addDamage(@Nonnull Damage damage); // } // // Path: src/main/java/tc/oc/tracker/damage/base/SimpleBlockDamageInfo.java // public class SimpleBlockDamageInfo extends AbstractBlockDamageInfo { // public SimpleBlockDamageInfo(@Nonnull BlockState blockDamager) { // super(null, blockDamager); // } // } // Path: src/main/java/tc/oc/tracker/damage/resolvers/BlockDamageResolver.java import javax.annotation.Nonnull; import javax.annotation.Nullable; import org.bukkit.entity.LivingEntity; import org.bukkit.event.entity.EntityDamageByBlockEvent; import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import tc.oc.tracker.DamageInfo; import tc.oc.tracker.DamageResolver; import tc.oc.tracker.Lifetime; import tc.oc.tracker.damage.base.SimpleBlockDamageInfo; package tc.oc.tracker.damage.resolvers; public class BlockDamageResolver implements DamageResolver { public @Nullable DamageInfo resolve(@Nonnull LivingEntity entity, @Nonnull Lifetime lifetime, @Nonnull EntityDamageEvent damageEvent) { if(damageEvent instanceof EntityDamageByBlockEvent && damageEvent.getCause() == DamageCause.CONTACT) { EntityDamageByBlockEvent blockEvent = (EntityDamageByBlockEvent) damageEvent;
return new SimpleBlockDamageInfo(blockEvent.getDamager().getState());
OvercastNetwork/Tracker
src/main/java/tc/oc/tracker/DamageAPI.java
// Path: src/main/java/tc/oc/tracker/plugin/DamageAPIHelper.java // public final class DamageAPIHelper { // /** // * Gets the singleton DamageAPIHelper instance. // * // * @return DamageAPIHelper instance (never null) // */ // public static @Nonnull DamageAPIHelper get() { // return inst; // } // private static final @Nonnull DamageAPIHelper inst = new DamageAPIHelper(); // // /** // * Fetches the given {@link DamageInfo} object specified by // * {@link DamageAPI#inflictDamage} so it can be fetched by the // * {@link DamageAPIResolver} when plugins who listen to the Bukkit event // * ask for it. // * // * @param event EntityDamageEvent to fetch the given damage for // * @return Stored damage info or null if none is stored // * // * @throws NullPointerException if event is null // */ // public @Nullable DamageInfo getEventDamageInfo(@Nonnull org.bukkit.event.entity.EntityDamageEvent event) { // Preconditions.checkNotNull(event, "entity damage event"); // // return this.eventDamageMapping.get(event); // } // // /** // * Sets the API damage info that corresponds to the specified event. // * // * Intended for internal use only, so this method is not guaranteed to stay // * the same through stable version releases. // * // * @param event Specified event // * @param damage Damage info that describes the damage or null to clear the // * store information // * @return Previous damage info associated with the event // * // * @throws NullPointerException if event is null // */ // public @Nullable DamageInfo setEventDamageInfo(@Nonnull org.bukkit.event.entity.EntityDamageEvent event, @Nullable DamageInfo info) { // Preconditions.checkNotNull(event, "entity damage event"); // // if(info != null) { // return this.eventDamageMapping.put(event, info); // } else { // return this.eventDamageMapping.remove(event); // } // } // // private final @Nonnull Map<org.bukkit.event.entity.EntityDamageEvent, DamageInfo> eventDamageMapping = Maps.newHashMap(); // // /** // * Gets our version of the EntityDamageEvent so it can be called in // * parallel to Bukkit's. // * // * @param bukkit Bukkit's version of the EntityDamageEvent // * @return Our version of the event or null if there is none registered // * // * @throws NullPointerException if bukkit is null // */ // public @Nullable EntityDamageEvent getOurEvent(@Nonnull org.bukkit.event.entity.EntityDamageEvent bukkit) { // Preconditions.checkNotNull(bukkit, "entity damage event"); // // return this.eventMapping.get(bukkit); // } // // /** // * Sets our version of the EntityDamageEvent so it can be called in // * parallel with Bukkit's. // * // * @param bukkit Bukkit's version of the EntityDamageEvent // * @param our Our version of the EntityDamageEvent or null to clear it // * @return The previous association or null if none existed // * // * @throws NullPointerException if bukkit is null // */ // public @Nullable EntityDamageEvent setOurEvent(@Nonnull org.bukkit.event.entity.EntityDamageEvent bukkit, @Nullable EntityDamageEvent our) { // Preconditions.checkNotNull(bukkit, "entity damage event"); // // if(our != null) { // return this.eventMapping.put(bukkit, our); // } else { // return this.eventMapping.remove(bukkit); // } // } // // private final @Nonnull Map<org.bukkit.event.entity.EntityDamageEvent, EntityDamageEvent> eventMapping = Maps.newHashMap(); // }
import javax.annotation.Nonnull; import org.bukkit.Bukkit; import org.bukkit.entity.LivingEntity; import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import tc.oc.tracker.plugin.DamageAPIHelper; import com.google.common.base.Preconditions;
package tc.oc.tracker; /** * Provides convenient static API calls for other plugins to use. */ public final class DamageAPI { private DamageAPI() { } /** * Inflicts the given damage on an entity. * * This method will call the appropriate damage method and fire an {@link EntityDamageEvent}. * * @param entity Entity to inflict damage upon * @param damage Amount of half-hearts of damage to inflict * @param info {@link DamageInfo} object that details the type of damage * @return the final {@link Damage} object (never null) * * @throws NullPointerException if entity or info is null * @throws IllegalArgumentExcpetion if hearts is less than zero */ public static @Nonnull Damage inflictDamage(@Nonnull LivingEntity entity, int damage, @Nonnull DamageInfo info) { Preconditions.checkNotNull(entity, "living entity"); Preconditions.checkArgument(damage >= 0, "damage must be greater than or equal to zero"); Preconditions.checkNotNull(info, "damage info");
// Path: src/main/java/tc/oc/tracker/plugin/DamageAPIHelper.java // public final class DamageAPIHelper { // /** // * Gets the singleton DamageAPIHelper instance. // * // * @return DamageAPIHelper instance (never null) // */ // public static @Nonnull DamageAPIHelper get() { // return inst; // } // private static final @Nonnull DamageAPIHelper inst = new DamageAPIHelper(); // // /** // * Fetches the given {@link DamageInfo} object specified by // * {@link DamageAPI#inflictDamage} so it can be fetched by the // * {@link DamageAPIResolver} when plugins who listen to the Bukkit event // * ask for it. // * // * @param event EntityDamageEvent to fetch the given damage for // * @return Stored damage info or null if none is stored // * // * @throws NullPointerException if event is null // */ // public @Nullable DamageInfo getEventDamageInfo(@Nonnull org.bukkit.event.entity.EntityDamageEvent event) { // Preconditions.checkNotNull(event, "entity damage event"); // // return this.eventDamageMapping.get(event); // } // // /** // * Sets the API damage info that corresponds to the specified event. // * // * Intended for internal use only, so this method is not guaranteed to stay // * the same through stable version releases. // * // * @param event Specified event // * @param damage Damage info that describes the damage or null to clear the // * store information // * @return Previous damage info associated with the event // * // * @throws NullPointerException if event is null // */ // public @Nullable DamageInfo setEventDamageInfo(@Nonnull org.bukkit.event.entity.EntityDamageEvent event, @Nullable DamageInfo info) { // Preconditions.checkNotNull(event, "entity damage event"); // // if(info != null) { // return this.eventDamageMapping.put(event, info); // } else { // return this.eventDamageMapping.remove(event); // } // } // // private final @Nonnull Map<org.bukkit.event.entity.EntityDamageEvent, DamageInfo> eventDamageMapping = Maps.newHashMap(); // // /** // * Gets our version of the EntityDamageEvent so it can be called in // * parallel to Bukkit's. // * // * @param bukkit Bukkit's version of the EntityDamageEvent // * @return Our version of the event or null if there is none registered // * // * @throws NullPointerException if bukkit is null // */ // public @Nullable EntityDamageEvent getOurEvent(@Nonnull org.bukkit.event.entity.EntityDamageEvent bukkit) { // Preconditions.checkNotNull(bukkit, "entity damage event"); // // return this.eventMapping.get(bukkit); // } // // /** // * Sets our version of the EntityDamageEvent so it can be called in // * parallel with Bukkit's. // * // * @param bukkit Bukkit's version of the EntityDamageEvent // * @param our Our version of the EntityDamageEvent or null to clear it // * @return The previous association or null if none existed // * // * @throws NullPointerException if bukkit is null // */ // public @Nullable EntityDamageEvent setOurEvent(@Nonnull org.bukkit.event.entity.EntityDamageEvent bukkit, @Nullable EntityDamageEvent our) { // Preconditions.checkNotNull(bukkit, "entity damage event"); // // if(our != null) { // return this.eventMapping.put(bukkit, our); // } else { // return this.eventMapping.remove(bukkit); // } // } // // private final @Nonnull Map<org.bukkit.event.entity.EntityDamageEvent, EntityDamageEvent> eventMapping = Maps.newHashMap(); // } // Path: src/main/java/tc/oc/tracker/DamageAPI.java import javax.annotation.Nonnull; import org.bukkit.Bukkit; import org.bukkit.entity.LivingEntity; import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import tc.oc.tracker.plugin.DamageAPIHelper; import com.google.common.base.Preconditions; package tc.oc.tracker; /** * Provides convenient static API calls for other plugins to use. */ public final class DamageAPI { private DamageAPI() { } /** * Inflicts the given damage on an entity. * * This method will call the appropriate damage method and fire an {@link EntityDamageEvent}. * * @param entity Entity to inflict damage upon * @param damage Amount of half-hearts of damage to inflict * @param info {@link DamageInfo} object that details the type of damage * @return the final {@link Damage} object (never null) * * @throws NullPointerException if entity or info is null * @throws IllegalArgumentExcpetion if hearts is less than zero */ public static @Nonnull Damage inflictDamage(@Nonnull LivingEntity entity, int damage, @Nonnull DamageInfo info) { Preconditions.checkNotNull(entity, "living entity"); Preconditions.checkArgument(damage >= 0, "damage must be greater than or equal to zero"); Preconditions.checkNotNull(info, "damage info");
DamageAPIHelper helper = DamageAPIHelper.get();
OvercastNetwork/Tracker
src/main/java/tc/oc/tracker/plugin/WorldListener.java
// Path: src/main/java/tc/oc/tracker/Tracker.java // public interface Tracker { // /** // * Indicates whether the tracker is enabled and collecting data in the // * specified world. // * // * @param world Specified world // * @return true if the tracker is enabled in the world, false otherwise // * // * @throws NullPointerException if world is null // */ // boolean isEnabled(@Nonnull World world); // // /** // * Enables the tracker in all current and future worlds. // * // * @return true if one or more worlds that were not enabled are now // * enabled, false otherwise // */ // boolean enable(); // // /** // * Enables the tracker in the specified world. // * // * @param world Specified world // * @return true if the world was disabled, false otherwise // * // * @throws NullPointerException if world is null // */ // boolean enable(@Nonnull World world); // // /** // * Disables the tracker in all current and future worlds. // * // * Note that any data that was tracked will be discarded. // * // * @return true if one or more worlds that were enabled are now disabled, // * false otherwise // */ // boolean disable(); // // /** // * Disables the tracker in the specified world. // * // * Note that any data that was tracked will be discarded. // * // * @param world Specified world // * @return true if the world was enabled, false otherwise // * // * @throws NullPointerException if world is null // */ // boolean disable(@Nonnull World world); // // /** // * Clears stored information regarding the specified world. // * // * @param world Specified world // * // * @throws NullPointerException if world is null // */ // void clear(@Nonnull World world); // } // // Path: src/main/java/tc/oc/tracker/TrackerManager.java // public interface TrackerManager { // Set<Tracker> getTrackers(); // // boolean hasTracker(@Nonnull Class<? extends Tracker> trackerClass); // // @Nullable <T extends Tracker> T getTracker(@Nonnull Class<T> trackerClass); // // @Nullable <T extends Tracker> T setTracker(@Nonnull Class<T> trackerClass, @Nullable T tracker); // // @Nullable <T extends Tracker> T clearTracker(@Nonnull Class<T> trackerClass); // // @Nullable <T extends Tracker> T clearTracker(@Nonnull Class<T> trackerClass, @Nonnull Class<? extends T> trackerImplClass); // // void clearTrackers(@Nonnull World world); // }
import javax.annotation.Nonnull; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; import org.bukkit.event.world.WorldUnloadEvent; import tc.oc.tracker.Tracker; import tc.oc.tracker.TrackerManager; import com.google.common.base.Preconditions;
package tc.oc.tracker.plugin; public class WorldListener implements Listener { private final @Nonnull TrackerManager manager; public WorldListener(@Nonnull TrackerManager manager) { Preconditions.checkNotNull(manager, "tracker manager"); this.manager = manager; } @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onWorldUnload(final WorldUnloadEvent event) {
// Path: src/main/java/tc/oc/tracker/Tracker.java // public interface Tracker { // /** // * Indicates whether the tracker is enabled and collecting data in the // * specified world. // * // * @param world Specified world // * @return true if the tracker is enabled in the world, false otherwise // * // * @throws NullPointerException if world is null // */ // boolean isEnabled(@Nonnull World world); // // /** // * Enables the tracker in all current and future worlds. // * // * @return true if one or more worlds that were not enabled are now // * enabled, false otherwise // */ // boolean enable(); // // /** // * Enables the tracker in the specified world. // * // * @param world Specified world // * @return true if the world was disabled, false otherwise // * // * @throws NullPointerException if world is null // */ // boolean enable(@Nonnull World world); // // /** // * Disables the tracker in all current and future worlds. // * // * Note that any data that was tracked will be discarded. // * // * @return true if one or more worlds that were enabled are now disabled, // * false otherwise // */ // boolean disable(); // // /** // * Disables the tracker in the specified world. // * // * Note that any data that was tracked will be discarded. // * // * @param world Specified world // * @return true if the world was enabled, false otherwise // * // * @throws NullPointerException if world is null // */ // boolean disable(@Nonnull World world); // // /** // * Clears stored information regarding the specified world. // * // * @param world Specified world // * // * @throws NullPointerException if world is null // */ // void clear(@Nonnull World world); // } // // Path: src/main/java/tc/oc/tracker/TrackerManager.java // public interface TrackerManager { // Set<Tracker> getTrackers(); // // boolean hasTracker(@Nonnull Class<? extends Tracker> trackerClass); // // @Nullable <T extends Tracker> T getTracker(@Nonnull Class<T> trackerClass); // // @Nullable <T extends Tracker> T setTracker(@Nonnull Class<T> trackerClass, @Nullable T tracker); // // @Nullable <T extends Tracker> T clearTracker(@Nonnull Class<T> trackerClass); // // @Nullable <T extends Tracker> T clearTracker(@Nonnull Class<T> trackerClass, @Nonnull Class<? extends T> trackerImplClass); // // void clearTrackers(@Nonnull World world); // } // Path: src/main/java/tc/oc/tracker/plugin/WorldListener.java import javax.annotation.Nonnull; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; import org.bukkit.event.world.WorldUnloadEvent; import tc.oc.tracker.Tracker; import tc.oc.tracker.TrackerManager; import com.google.common.base.Preconditions; package tc.oc.tracker.plugin; public class WorldListener implements Listener { private final @Nonnull TrackerManager manager; public WorldListener(@Nonnull TrackerManager manager) { Preconditions.checkNotNull(manager, "tracker manager"); this.manager = manager; } @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onWorldUnload(final WorldUnloadEvent event) {
for(Tracker tracker : this.manager.getTrackers()) {
OvercastNetwork/Tracker
src/main/java/tc/oc/tracker/plugin/DamageAPIHelper.java
// Path: src/main/java/tc/oc/tracker/DamageAPI.java // public final class DamageAPI { // private DamageAPI() { } // // /** // * Inflicts the given damage on an entity. // * // * This method will call the appropriate damage method and fire an {@link EntityDamageEvent}. // * // * @param entity Entity to inflict damage upon // * @param damage Amount of half-hearts of damage to inflict // * @param info {@link DamageInfo} object that details the type of damage // * @return the final {@link Damage} object (never null) // * // * @throws NullPointerException if entity or info is null // * @throws IllegalArgumentExcpetion if hearts is less than zero // */ // public static @Nonnull Damage inflictDamage(@Nonnull LivingEntity entity, int damage, @Nonnull DamageInfo info) { // Preconditions.checkNotNull(entity, "living entity"); // Preconditions.checkArgument(damage >= 0, "damage must be greater than or equal to zero"); // Preconditions.checkNotNull(info, "damage info"); // // DamageAPIHelper helper = DamageAPIHelper.get(); // // EntityDamageEvent event = new EntityDamageEvent(entity, DamageCause.CUSTOM, damage); // helper.setEventDamageInfo(event, info); // // Bukkit.getPluginManager().callEvent(event); // // if(event.isCancelled()) { // return null; // } // // entity.damage(event.getDamage()); // // helper.setEventDamageInfo(event, null); // // return helper.getOurEvent(event).toDamageObject(); // } // } // // Path: src/main/java/tc/oc/tracker/DamageInfo.java // public interface DamageInfo { // /** // * Gets the living entity most responsible for this damage. // * // * @return Resolved damager or null if none exists // */ // @Nullable LivingEntity getResolvedDamager(); // } // // Path: src/main/java/tc/oc/tracker/damage/resolvers/DamageAPIResolver.java // public class DamageAPIResolver implements DamageResolver { // /** @see DamageResolvers#resolve */ // public @Nullable DamageInfo resolve(@Nonnull LivingEntity entity, @Nonnull Lifetime lifetime, @Nonnull EntityDamageEvent damageEvent) { // return DamageAPIHelper.get().getEventDamageInfo(damageEvent); // } // // static { // DamageResolvers.getManager().register(new DamageAPIResolver()); // } // } // // Path: src/main/java/tc/oc/tracker/event/EntityDamageEvent.java // public class EntityDamageEvent extends Event implements Cancellable { // private final @Nonnull LivingEntity entity; // private final @Nonnull Lifetime lifetime; // private int damage; // private final @Nonnull Location location; // private final @Nonnull Instant time; // private final @Nonnull DamageInfo info; // private boolean cancelled = false; // // public EntityDamageEvent(@Nonnull LivingEntity entity, @Nonnull Lifetime lifetime, int damage, @Nonnull Location location, @Nonnull Instant time, @Nonnull DamageInfo info) { // Preconditions.checkNotNull(entity, "entity"); // Preconditions.checkNotNull(lifetime, "lifetime"); // Preconditions.checkArgument(damage >= 0, "damage must be greater than or equal to zero"); // Preconditions.checkNotNull(location, "location"); // Preconditions.checkNotNull(time, "time"); // Preconditions.checkNotNull(info, "damage info"); // // this.entity = entity; // this.lifetime = lifetime; // this.damage = damage; // this.location = location.clone(); // this.time = time; // this.info = info; // } // // public @Nonnull LivingEntity getEntity() { // return this.entity; // } // // public @Nonnull Lifetime getLifetime() { // return this.lifetime; // } // // public int getDamage() { // return this.damage; // } // // public void setDamage(int damage) { // Preconditions.checkArgument(damage >= 0, "damage must be greater than or equal to zero"); // // this.damage = damage; // } // // public @Nonnull Location getLocation() { // return this.location; // } // // public @Nonnull Instant getTime() { // return this.time; // } // // public @Nonnull DamageInfo getInfo() { // return this.info; // } // // public @Nonnull Damage toDamageObject() { // return new SimpleDamage(this.damage, this.location, this.time, this.info); // } // // public boolean isCancelled() { // return this.cancelled; // } // // public void setCancelled(boolean cancel) { // this.cancelled = cancel; // } // // // Bukkit event junk // public static final HandlerList handlers = new HandlerList(); // // @Override // public HandlerList getHandlers() { // return handlers; // } // // public static HandlerList getHandlerList() { // return handlers; // } // }
import java.util.Map; import javax.annotation.Nonnull; import javax.annotation.Nullable; import tc.oc.tracker.DamageAPI; import tc.oc.tracker.DamageInfo; import tc.oc.tracker.damage.resolvers.DamageAPIResolver; import tc.oc.tracker.event.EntityDamageEvent; import com.google.common.base.Preconditions; import com.google.common.collect.Maps;
package tc.oc.tracker.plugin; /** * Helper class for the {@link DamageAPI} and Tracker plugin to properly handle * damage inflicted through the API. * * Class is intended for internal use only. Methods are not guaranteed to * respect versioning contract. */ public final class DamageAPIHelper { /** * Gets the singleton DamageAPIHelper instance. * * @return DamageAPIHelper instance (never null) */ public static @Nonnull DamageAPIHelper get() { return inst; } private static final @Nonnull DamageAPIHelper inst = new DamageAPIHelper(); /** * Fetches the given {@link DamageInfo} object specified by * {@link DamageAPI#inflictDamage} so it can be fetched by the * {@link DamageAPIResolver} when plugins who listen to the Bukkit event * ask for it. * * @param event EntityDamageEvent to fetch the given damage for * @return Stored damage info or null if none is stored * * @throws NullPointerException if event is null */
// Path: src/main/java/tc/oc/tracker/DamageAPI.java // public final class DamageAPI { // private DamageAPI() { } // // /** // * Inflicts the given damage on an entity. // * // * This method will call the appropriate damage method and fire an {@link EntityDamageEvent}. // * // * @param entity Entity to inflict damage upon // * @param damage Amount of half-hearts of damage to inflict // * @param info {@link DamageInfo} object that details the type of damage // * @return the final {@link Damage} object (never null) // * // * @throws NullPointerException if entity or info is null // * @throws IllegalArgumentExcpetion if hearts is less than zero // */ // public static @Nonnull Damage inflictDamage(@Nonnull LivingEntity entity, int damage, @Nonnull DamageInfo info) { // Preconditions.checkNotNull(entity, "living entity"); // Preconditions.checkArgument(damage >= 0, "damage must be greater than or equal to zero"); // Preconditions.checkNotNull(info, "damage info"); // // DamageAPIHelper helper = DamageAPIHelper.get(); // // EntityDamageEvent event = new EntityDamageEvent(entity, DamageCause.CUSTOM, damage); // helper.setEventDamageInfo(event, info); // // Bukkit.getPluginManager().callEvent(event); // // if(event.isCancelled()) { // return null; // } // // entity.damage(event.getDamage()); // // helper.setEventDamageInfo(event, null); // // return helper.getOurEvent(event).toDamageObject(); // } // } // // Path: src/main/java/tc/oc/tracker/DamageInfo.java // public interface DamageInfo { // /** // * Gets the living entity most responsible for this damage. // * // * @return Resolved damager or null if none exists // */ // @Nullable LivingEntity getResolvedDamager(); // } // // Path: src/main/java/tc/oc/tracker/damage/resolvers/DamageAPIResolver.java // public class DamageAPIResolver implements DamageResolver { // /** @see DamageResolvers#resolve */ // public @Nullable DamageInfo resolve(@Nonnull LivingEntity entity, @Nonnull Lifetime lifetime, @Nonnull EntityDamageEvent damageEvent) { // return DamageAPIHelper.get().getEventDamageInfo(damageEvent); // } // // static { // DamageResolvers.getManager().register(new DamageAPIResolver()); // } // } // // Path: src/main/java/tc/oc/tracker/event/EntityDamageEvent.java // public class EntityDamageEvent extends Event implements Cancellable { // private final @Nonnull LivingEntity entity; // private final @Nonnull Lifetime lifetime; // private int damage; // private final @Nonnull Location location; // private final @Nonnull Instant time; // private final @Nonnull DamageInfo info; // private boolean cancelled = false; // // public EntityDamageEvent(@Nonnull LivingEntity entity, @Nonnull Lifetime lifetime, int damage, @Nonnull Location location, @Nonnull Instant time, @Nonnull DamageInfo info) { // Preconditions.checkNotNull(entity, "entity"); // Preconditions.checkNotNull(lifetime, "lifetime"); // Preconditions.checkArgument(damage >= 0, "damage must be greater than or equal to zero"); // Preconditions.checkNotNull(location, "location"); // Preconditions.checkNotNull(time, "time"); // Preconditions.checkNotNull(info, "damage info"); // // this.entity = entity; // this.lifetime = lifetime; // this.damage = damage; // this.location = location.clone(); // this.time = time; // this.info = info; // } // // public @Nonnull LivingEntity getEntity() { // return this.entity; // } // // public @Nonnull Lifetime getLifetime() { // return this.lifetime; // } // // public int getDamage() { // return this.damage; // } // // public void setDamage(int damage) { // Preconditions.checkArgument(damage >= 0, "damage must be greater than or equal to zero"); // // this.damage = damage; // } // // public @Nonnull Location getLocation() { // return this.location; // } // // public @Nonnull Instant getTime() { // return this.time; // } // // public @Nonnull DamageInfo getInfo() { // return this.info; // } // // public @Nonnull Damage toDamageObject() { // return new SimpleDamage(this.damage, this.location, this.time, this.info); // } // // public boolean isCancelled() { // return this.cancelled; // } // // public void setCancelled(boolean cancel) { // this.cancelled = cancel; // } // // // Bukkit event junk // public static final HandlerList handlers = new HandlerList(); // // @Override // public HandlerList getHandlers() { // return handlers; // } // // public static HandlerList getHandlerList() { // return handlers; // } // } // Path: src/main/java/tc/oc/tracker/plugin/DamageAPIHelper.java import java.util.Map; import javax.annotation.Nonnull; import javax.annotation.Nullable; import tc.oc.tracker.DamageAPI; import tc.oc.tracker.DamageInfo; import tc.oc.tracker.damage.resolvers.DamageAPIResolver; import tc.oc.tracker.event.EntityDamageEvent; import com.google.common.base.Preconditions; import com.google.common.collect.Maps; package tc.oc.tracker.plugin; /** * Helper class for the {@link DamageAPI} and Tracker plugin to properly handle * damage inflicted through the API. * * Class is intended for internal use only. Methods are not guaranteed to * respect versioning contract. */ public final class DamageAPIHelper { /** * Gets the singleton DamageAPIHelper instance. * * @return DamageAPIHelper instance (never null) */ public static @Nonnull DamageAPIHelper get() { return inst; } private static final @Nonnull DamageAPIHelper inst = new DamageAPIHelper(); /** * Fetches the given {@link DamageInfo} object specified by * {@link DamageAPI#inflictDamage} so it can be fetched by the * {@link DamageAPIResolver} when plugins who listen to the Bukkit event * ask for it. * * @param event EntityDamageEvent to fetch the given damage for * @return Stored damage info or null if none is stored * * @throws NullPointerException if event is null */
public @Nullable DamageInfo getEventDamageInfo(@Nonnull org.bukkit.event.entity.EntityDamageEvent event) {
OvercastNetwork/Tracker
src/main/java/tc/oc/tracker/plugin/DamageAPIHelper.java
// Path: src/main/java/tc/oc/tracker/DamageAPI.java // public final class DamageAPI { // private DamageAPI() { } // // /** // * Inflicts the given damage on an entity. // * // * This method will call the appropriate damage method and fire an {@link EntityDamageEvent}. // * // * @param entity Entity to inflict damage upon // * @param damage Amount of half-hearts of damage to inflict // * @param info {@link DamageInfo} object that details the type of damage // * @return the final {@link Damage} object (never null) // * // * @throws NullPointerException if entity or info is null // * @throws IllegalArgumentExcpetion if hearts is less than zero // */ // public static @Nonnull Damage inflictDamage(@Nonnull LivingEntity entity, int damage, @Nonnull DamageInfo info) { // Preconditions.checkNotNull(entity, "living entity"); // Preconditions.checkArgument(damage >= 0, "damage must be greater than or equal to zero"); // Preconditions.checkNotNull(info, "damage info"); // // DamageAPIHelper helper = DamageAPIHelper.get(); // // EntityDamageEvent event = new EntityDamageEvent(entity, DamageCause.CUSTOM, damage); // helper.setEventDamageInfo(event, info); // // Bukkit.getPluginManager().callEvent(event); // // if(event.isCancelled()) { // return null; // } // // entity.damage(event.getDamage()); // // helper.setEventDamageInfo(event, null); // // return helper.getOurEvent(event).toDamageObject(); // } // } // // Path: src/main/java/tc/oc/tracker/DamageInfo.java // public interface DamageInfo { // /** // * Gets the living entity most responsible for this damage. // * // * @return Resolved damager or null if none exists // */ // @Nullable LivingEntity getResolvedDamager(); // } // // Path: src/main/java/tc/oc/tracker/damage/resolvers/DamageAPIResolver.java // public class DamageAPIResolver implements DamageResolver { // /** @see DamageResolvers#resolve */ // public @Nullable DamageInfo resolve(@Nonnull LivingEntity entity, @Nonnull Lifetime lifetime, @Nonnull EntityDamageEvent damageEvent) { // return DamageAPIHelper.get().getEventDamageInfo(damageEvent); // } // // static { // DamageResolvers.getManager().register(new DamageAPIResolver()); // } // } // // Path: src/main/java/tc/oc/tracker/event/EntityDamageEvent.java // public class EntityDamageEvent extends Event implements Cancellable { // private final @Nonnull LivingEntity entity; // private final @Nonnull Lifetime lifetime; // private int damage; // private final @Nonnull Location location; // private final @Nonnull Instant time; // private final @Nonnull DamageInfo info; // private boolean cancelled = false; // // public EntityDamageEvent(@Nonnull LivingEntity entity, @Nonnull Lifetime lifetime, int damage, @Nonnull Location location, @Nonnull Instant time, @Nonnull DamageInfo info) { // Preconditions.checkNotNull(entity, "entity"); // Preconditions.checkNotNull(lifetime, "lifetime"); // Preconditions.checkArgument(damage >= 0, "damage must be greater than or equal to zero"); // Preconditions.checkNotNull(location, "location"); // Preconditions.checkNotNull(time, "time"); // Preconditions.checkNotNull(info, "damage info"); // // this.entity = entity; // this.lifetime = lifetime; // this.damage = damage; // this.location = location.clone(); // this.time = time; // this.info = info; // } // // public @Nonnull LivingEntity getEntity() { // return this.entity; // } // // public @Nonnull Lifetime getLifetime() { // return this.lifetime; // } // // public int getDamage() { // return this.damage; // } // // public void setDamage(int damage) { // Preconditions.checkArgument(damage >= 0, "damage must be greater than or equal to zero"); // // this.damage = damage; // } // // public @Nonnull Location getLocation() { // return this.location; // } // // public @Nonnull Instant getTime() { // return this.time; // } // // public @Nonnull DamageInfo getInfo() { // return this.info; // } // // public @Nonnull Damage toDamageObject() { // return new SimpleDamage(this.damage, this.location, this.time, this.info); // } // // public boolean isCancelled() { // return this.cancelled; // } // // public void setCancelled(boolean cancel) { // this.cancelled = cancel; // } // // // Bukkit event junk // public static final HandlerList handlers = new HandlerList(); // // @Override // public HandlerList getHandlers() { // return handlers; // } // // public static HandlerList getHandlerList() { // return handlers; // } // }
import java.util.Map; import javax.annotation.Nonnull; import javax.annotation.Nullable; import tc.oc.tracker.DamageAPI; import tc.oc.tracker.DamageInfo; import tc.oc.tracker.damage.resolvers.DamageAPIResolver; import tc.oc.tracker.event.EntityDamageEvent; import com.google.common.base.Preconditions; import com.google.common.collect.Maps;
package tc.oc.tracker.plugin; /** * Helper class for the {@link DamageAPI} and Tracker plugin to properly handle * damage inflicted through the API. * * Class is intended for internal use only. Methods are not guaranteed to * respect versioning contract. */ public final class DamageAPIHelper { /** * Gets the singleton DamageAPIHelper instance. * * @return DamageAPIHelper instance (never null) */ public static @Nonnull DamageAPIHelper get() { return inst; } private static final @Nonnull DamageAPIHelper inst = new DamageAPIHelper(); /** * Fetches the given {@link DamageInfo} object specified by * {@link DamageAPI#inflictDamage} so it can be fetched by the * {@link DamageAPIResolver} when plugins who listen to the Bukkit event * ask for it. * * @param event EntityDamageEvent to fetch the given damage for * @return Stored damage info or null if none is stored * * @throws NullPointerException if event is null */
// Path: src/main/java/tc/oc/tracker/DamageAPI.java // public final class DamageAPI { // private DamageAPI() { } // // /** // * Inflicts the given damage on an entity. // * // * This method will call the appropriate damage method and fire an {@link EntityDamageEvent}. // * // * @param entity Entity to inflict damage upon // * @param damage Amount of half-hearts of damage to inflict // * @param info {@link DamageInfo} object that details the type of damage // * @return the final {@link Damage} object (never null) // * // * @throws NullPointerException if entity or info is null // * @throws IllegalArgumentExcpetion if hearts is less than zero // */ // public static @Nonnull Damage inflictDamage(@Nonnull LivingEntity entity, int damage, @Nonnull DamageInfo info) { // Preconditions.checkNotNull(entity, "living entity"); // Preconditions.checkArgument(damage >= 0, "damage must be greater than or equal to zero"); // Preconditions.checkNotNull(info, "damage info"); // // DamageAPIHelper helper = DamageAPIHelper.get(); // // EntityDamageEvent event = new EntityDamageEvent(entity, DamageCause.CUSTOM, damage); // helper.setEventDamageInfo(event, info); // // Bukkit.getPluginManager().callEvent(event); // // if(event.isCancelled()) { // return null; // } // // entity.damage(event.getDamage()); // // helper.setEventDamageInfo(event, null); // // return helper.getOurEvent(event).toDamageObject(); // } // } // // Path: src/main/java/tc/oc/tracker/DamageInfo.java // public interface DamageInfo { // /** // * Gets the living entity most responsible for this damage. // * // * @return Resolved damager or null if none exists // */ // @Nullable LivingEntity getResolvedDamager(); // } // // Path: src/main/java/tc/oc/tracker/damage/resolvers/DamageAPIResolver.java // public class DamageAPIResolver implements DamageResolver { // /** @see DamageResolvers#resolve */ // public @Nullable DamageInfo resolve(@Nonnull LivingEntity entity, @Nonnull Lifetime lifetime, @Nonnull EntityDamageEvent damageEvent) { // return DamageAPIHelper.get().getEventDamageInfo(damageEvent); // } // // static { // DamageResolvers.getManager().register(new DamageAPIResolver()); // } // } // // Path: src/main/java/tc/oc/tracker/event/EntityDamageEvent.java // public class EntityDamageEvent extends Event implements Cancellable { // private final @Nonnull LivingEntity entity; // private final @Nonnull Lifetime lifetime; // private int damage; // private final @Nonnull Location location; // private final @Nonnull Instant time; // private final @Nonnull DamageInfo info; // private boolean cancelled = false; // // public EntityDamageEvent(@Nonnull LivingEntity entity, @Nonnull Lifetime lifetime, int damage, @Nonnull Location location, @Nonnull Instant time, @Nonnull DamageInfo info) { // Preconditions.checkNotNull(entity, "entity"); // Preconditions.checkNotNull(lifetime, "lifetime"); // Preconditions.checkArgument(damage >= 0, "damage must be greater than or equal to zero"); // Preconditions.checkNotNull(location, "location"); // Preconditions.checkNotNull(time, "time"); // Preconditions.checkNotNull(info, "damage info"); // // this.entity = entity; // this.lifetime = lifetime; // this.damage = damage; // this.location = location.clone(); // this.time = time; // this.info = info; // } // // public @Nonnull LivingEntity getEntity() { // return this.entity; // } // // public @Nonnull Lifetime getLifetime() { // return this.lifetime; // } // // public int getDamage() { // return this.damage; // } // // public void setDamage(int damage) { // Preconditions.checkArgument(damage >= 0, "damage must be greater than or equal to zero"); // // this.damage = damage; // } // // public @Nonnull Location getLocation() { // return this.location; // } // // public @Nonnull Instant getTime() { // return this.time; // } // // public @Nonnull DamageInfo getInfo() { // return this.info; // } // // public @Nonnull Damage toDamageObject() { // return new SimpleDamage(this.damage, this.location, this.time, this.info); // } // // public boolean isCancelled() { // return this.cancelled; // } // // public void setCancelled(boolean cancel) { // this.cancelled = cancel; // } // // // Bukkit event junk // public static final HandlerList handlers = new HandlerList(); // // @Override // public HandlerList getHandlers() { // return handlers; // } // // public static HandlerList getHandlerList() { // return handlers; // } // } // Path: src/main/java/tc/oc/tracker/plugin/DamageAPIHelper.java import java.util.Map; import javax.annotation.Nonnull; import javax.annotation.Nullable; import tc.oc.tracker.DamageAPI; import tc.oc.tracker.DamageInfo; import tc.oc.tracker.damage.resolvers.DamageAPIResolver; import tc.oc.tracker.event.EntityDamageEvent; import com.google.common.base.Preconditions; import com.google.common.collect.Maps; package tc.oc.tracker.plugin; /** * Helper class for the {@link DamageAPI} and Tracker plugin to properly handle * damage inflicted through the API. * * Class is intended for internal use only. Methods are not guaranteed to * respect versioning contract. */ public final class DamageAPIHelper { /** * Gets the singleton DamageAPIHelper instance. * * @return DamageAPIHelper instance (never null) */ public static @Nonnull DamageAPIHelper get() { return inst; } private static final @Nonnull DamageAPIHelper inst = new DamageAPIHelper(); /** * Fetches the given {@link DamageInfo} object specified by * {@link DamageAPI#inflictDamage} so it can be fetched by the * {@link DamageAPIResolver} when plugins who listen to the Bukkit event * ask for it. * * @param event EntityDamageEvent to fetch the given damage for * @return Stored damage info or null if none is stored * * @throws NullPointerException if event is null */
public @Nullable DamageInfo getEventDamageInfo(@Nonnull org.bukkit.event.entity.EntityDamageEvent event) {
OvercastNetwork/Tracker
src/main/java/tc/oc/tracker/Trackers.java
// Path: src/main/java/tc/oc/tracker/base/SimpleTrackerManager.java // public class SimpleTrackerManager implements TrackerManager { // public Set<Tracker> getTrackers() { // return ImmutableSet.copyOf(this.trackers.values()); // } // // public boolean hasTracker(@Nonnull Class<? extends Tracker> trackerClass) { // return this.getTracker(trackerClass) != null; // } // // public @Nullable <T extends Tracker> T getTracker(@Nonnull Class<T> trackerClass) { // Preconditions.checkNotNull(trackerClass, "tracker class"); // // return findTracker(this.trackers, trackerClass); // } // // public @Nullable <T extends Tracker> T setTracker(@Nonnull Class<T> trackerClass, @Nullable T tracker) { // Preconditions.checkNotNull(trackerClass, "tracker class"); // Preconditions.checkArgument(trackerClass.isInstance(tracker), "tracker is not an instance of the specified class"); // // return setTrackerInDB(this.trackers, trackerClass, tracker); // } // // @SuppressWarnings("unchecked") // public @Nullable <T extends Tracker> T clearTracker(@Nonnull Class<T> trackerClass) { // Preconditions.checkNotNull(trackerClass, "tracker class"); // // return (T) this.trackers.remove(trackerClass); // } // // @SuppressWarnings("unchecked") // public @Nullable <T extends Tracker> T clearTracker(@Nonnull Class<T> trackerClass, @Nonnull Class<? extends T> trackerImplClass) { // Preconditions.checkNotNull(trackerClass, "tracker class"); // Preconditions.checkNotNull(trackerImplClass, "tracker implementation class"); // // Tracker tracker = this.trackers.get(trackerClass); // if(trackerImplClass.isInstance(tracker)) { // return (T) this.trackers.remove(trackerClass); // } else { // return null; // } // } // // @SuppressWarnings("unchecked") // private static @Nullable <T extends Tracker> T findTracker(@Nonnull Map<Class<? extends Tracker>, Tracker> db, @Nonnull Class<T> search) { // for(Map.Entry<Class<? extends Tracker>, Tracker> entry : db.entrySet()) { // if(search.isAssignableFrom(entry.getKey())) { // return (T) entry.getValue(); // } // } // return null; // } // // @SuppressWarnings("unchecked") // private static @Nullable <T extends Tracker> T setTrackerInDB(@Nonnull Map<Class<? extends Tracker>, Tracker> db, @Nonnull Class<T> trackerClass, @Nullable T tracker) { // if(tracker != null) { // return (T) db.put(trackerClass, tracker); // } else { // return (T) db.remove(trackerClass); // } // } // // public void clearTrackers(@Nonnull World world) { // Preconditions.checkNotNull(world, "world"); // // for(Tracker tracker : this.getTrackers()) { // tracker.clear(world); // } // } // // private final Map<Class<? extends Tracker>, Tracker> trackers = Maps.newHashMap(); // }
import javax.annotation.Nonnull; import tc.oc.tracker.base.SimpleTrackerManager;
package tc.oc.tracker; public final class Trackers { private Trackers() { } public static @Nonnull TrackerManager getManager() { if(manager == null) {
// Path: src/main/java/tc/oc/tracker/base/SimpleTrackerManager.java // public class SimpleTrackerManager implements TrackerManager { // public Set<Tracker> getTrackers() { // return ImmutableSet.copyOf(this.trackers.values()); // } // // public boolean hasTracker(@Nonnull Class<? extends Tracker> trackerClass) { // return this.getTracker(trackerClass) != null; // } // // public @Nullable <T extends Tracker> T getTracker(@Nonnull Class<T> trackerClass) { // Preconditions.checkNotNull(trackerClass, "tracker class"); // // return findTracker(this.trackers, trackerClass); // } // // public @Nullable <T extends Tracker> T setTracker(@Nonnull Class<T> trackerClass, @Nullable T tracker) { // Preconditions.checkNotNull(trackerClass, "tracker class"); // Preconditions.checkArgument(trackerClass.isInstance(tracker), "tracker is not an instance of the specified class"); // // return setTrackerInDB(this.trackers, trackerClass, tracker); // } // // @SuppressWarnings("unchecked") // public @Nullable <T extends Tracker> T clearTracker(@Nonnull Class<T> trackerClass) { // Preconditions.checkNotNull(trackerClass, "tracker class"); // // return (T) this.trackers.remove(trackerClass); // } // // @SuppressWarnings("unchecked") // public @Nullable <T extends Tracker> T clearTracker(@Nonnull Class<T> trackerClass, @Nonnull Class<? extends T> trackerImplClass) { // Preconditions.checkNotNull(trackerClass, "tracker class"); // Preconditions.checkNotNull(trackerImplClass, "tracker implementation class"); // // Tracker tracker = this.trackers.get(trackerClass); // if(trackerImplClass.isInstance(tracker)) { // return (T) this.trackers.remove(trackerClass); // } else { // return null; // } // } // // @SuppressWarnings("unchecked") // private static @Nullable <T extends Tracker> T findTracker(@Nonnull Map<Class<? extends Tracker>, Tracker> db, @Nonnull Class<T> search) { // for(Map.Entry<Class<? extends Tracker>, Tracker> entry : db.entrySet()) { // if(search.isAssignableFrom(entry.getKey())) { // return (T) entry.getValue(); // } // } // return null; // } // // @SuppressWarnings("unchecked") // private static @Nullable <T extends Tracker> T setTrackerInDB(@Nonnull Map<Class<? extends Tracker>, Tracker> db, @Nonnull Class<T> trackerClass, @Nullable T tracker) { // if(tracker != null) { // return (T) db.put(trackerClass, tracker); // } else { // return (T) db.remove(trackerClass); // } // } // // public void clearTrackers(@Nonnull World world) { // Preconditions.checkNotNull(world, "world"); // // for(Tracker tracker : this.getTrackers()) { // tracker.clear(world); // } // } // // private final Map<Class<? extends Tracker>, Tracker> trackers = Maps.newHashMap(); // } // Path: src/main/java/tc/oc/tracker/Trackers.java import javax.annotation.Nonnull; import tc.oc.tracker.base.SimpleTrackerManager; package tc.oc.tracker; public final class Trackers { private Trackers() { } public static @Nonnull TrackerManager getManager() { if(manager == null) {
manager = new SimpleTrackerManager();
OvercastNetwork/Tracker
src/main/java/tc/oc/tracker/damage/resolvers/TNTDamageResolver.java
// Path: src/main/java/tc/oc/tracker/DamageInfo.java // public interface DamageInfo { // /** // * Gets the living entity most responsible for this damage. // * // * @return Resolved damager or null if none exists // */ // @Nullable LivingEntity getResolvedDamager(); // } // // Path: src/main/java/tc/oc/tracker/DamageResolver.java // public interface DamageResolver { // @Nullable DamageInfo resolve(@Nonnull LivingEntity entity, @Nonnull Lifetime lifetime, @Nonnull EntityDamageEvent damageEvent); // } // // Path: src/main/java/tc/oc/tracker/Lifetime.java // public interface Lifetime { // @Nullable Instant getStart(); // // void setStart(@Nonnull Instant start); // // @Nullable Instant getEnd(); // // void setEnd(@Nonnull Instant end); // // @Nonnull List<Damage> getDamage(); // // @Nonnull ListIterator<Damage> getDamageFirst(); // // @Nonnull ListIterator<Damage> getDamageLast(); // // @Nullable Damage getFirstDamage(); // // @Nullable Damage getLastDamage(); // // /** // * Gets the last damage instance where the info object is an instance of // * the specified class. Uses {@link Class#isInstance(Object)} to check info // * objects. // * // * @param damageInfoClass DamageInfo class to check for // * @return Last damage that matched or null if none matched // * // * @throws NullPointerException if damageInfoClass is null // */ // @Nullable Damage getLastDamage(@Nonnull Class<? extends DamageInfo> damageInfoClass); // // void addDamage(@Nonnull Damage damage); // } // // Path: src/main/java/tc/oc/tracker/damage/TNTDamageInfo.java // public class TNTDamageInfo extends ExplosiveDamageInfo { // public TNTDamageInfo(@Nonnull TNTPrimed explosive, @Nullable LivingEntity resolvedDamager) { // super(explosive, resolvedDamager); // } // // @Override // public @Nonnull TNTPrimed getExplosive() { // return (TNTPrimed) this.explosive; // } // // @Override // public @Nonnull String toString() { // return "TNTDamageInfo{explosive=" + this.explosive + ",damager=" + this.resolvedDamager + "}"; // } // } // // Path: src/main/java/tc/oc/tracker/trackers/DispenserTracker.java // public interface DispenserTracker extends Tracker { // boolean hasOwner(@Nonnull Entity entity); // // @Nullable OfflinePlayer getOwner(@Nonnull Entity entity); // // @Nullable OfflinePlayer setOwner(@Nonnull Entity entity, @Nullable Player player); // // boolean hasPlacer(@Nonnull Block block); // // @Nullable OfflinePlayer getPlacer(@Nonnull Block block); // // @Nullable OfflinePlayer setPlacer(@Nonnull Block block, @Nullable Player player); // // @Nonnull OfflinePlayer clearPlacer(@Nonnull Block block); // } // // Path: src/main/java/tc/oc/tracker/trackers/ExplosiveTracker.java // public interface ExplosiveTracker extends Tracker { // boolean hasOwner(@Nonnull TNTPrimed entity); // // @Nullable Player getOwner(@Nonnull TNTPrimed entity); // // @Nullable Player setOwner(@Nonnull TNTPrimed entity, @Nullable Player player); // // boolean hasPlacer(@Nonnull Block block); // // @Nullable Player getPlacer(@Nonnull Block block); // // @Nullable Player setPlacer(@Nonnull Block block, @Nullable Player player); // }
import javax.annotation.Nonnull; import javax.annotation.Nullable; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.entity.TNTPrimed; import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageEvent; import tc.oc.tracker.DamageInfo; import tc.oc.tracker.DamageResolver; import tc.oc.tracker.Lifetime; import tc.oc.tracker.damage.TNTDamageInfo; import tc.oc.tracker.trackers.DispenserTracker; import tc.oc.tracker.trackers.ExplosiveTracker;
package tc.oc.tracker.damage.resolvers; public class TNTDamageResolver implements DamageResolver { private final ExplosiveTracker explosiveTracker;
// Path: src/main/java/tc/oc/tracker/DamageInfo.java // public interface DamageInfo { // /** // * Gets the living entity most responsible for this damage. // * // * @return Resolved damager or null if none exists // */ // @Nullable LivingEntity getResolvedDamager(); // } // // Path: src/main/java/tc/oc/tracker/DamageResolver.java // public interface DamageResolver { // @Nullable DamageInfo resolve(@Nonnull LivingEntity entity, @Nonnull Lifetime lifetime, @Nonnull EntityDamageEvent damageEvent); // } // // Path: src/main/java/tc/oc/tracker/Lifetime.java // public interface Lifetime { // @Nullable Instant getStart(); // // void setStart(@Nonnull Instant start); // // @Nullable Instant getEnd(); // // void setEnd(@Nonnull Instant end); // // @Nonnull List<Damage> getDamage(); // // @Nonnull ListIterator<Damage> getDamageFirst(); // // @Nonnull ListIterator<Damage> getDamageLast(); // // @Nullable Damage getFirstDamage(); // // @Nullable Damage getLastDamage(); // // /** // * Gets the last damage instance where the info object is an instance of // * the specified class. Uses {@link Class#isInstance(Object)} to check info // * objects. // * // * @param damageInfoClass DamageInfo class to check for // * @return Last damage that matched or null if none matched // * // * @throws NullPointerException if damageInfoClass is null // */ // @Nullable Damage getLastDamage(@Nonnull Class<? extends DamageInfo> damageInfoClass); // // void addDamage(@Nonnull Damage damage); // } // // Path: src/main/java/tc/oc/tracker/damage/TNTDamageInfo.java // public class TNTDamageInfo extends ExplosiveDamageInfo { // public TNTDamageInfo(@Nonnull TNTPrimed explosive, @Nullable LivingEntity resolvedDamager) { // super(explosive, resolvedDamager); // } // // @Override // public @Nonnull TNTPrimed getExplosive() { // return (TNTPrimed) this.explosive; // } // // @Override // public @Nonnull String toString() { // return "TNTDamageInfo{explosive=" + this.explosive + ",damager=" + this.resolvedDamager + "}"; // } // } // // Path: src/main/java/tc/oc/tracker/trackers/DispenserTracker.java // public interface DispenserTracker extends Tracker { // boolean hasOwner(@Nonnull Entity entity); // // @Nullable OfflinePlayer getOwner(@Nonnull Entity entity); // // @Nullable OfflinePlayer setOwner(@Nonnull Entity entity, @Nullable Player player); // // boolean hasPlacer(@Nonnull Block block); // // @Nullable OfflinePlayer getPlacer(@Nonnull Block block); // // @Nullable OfflinePlayer setPlacer(@Nonnull Block block, @Nullable Player player); // // @Nonnull OfflinePlayer clearPlacer(@Nonnull Block block); // } // // Path: src/main/java/tc/oc/tracker/trackers/ExplosiveTracker.java // public interface ExplosiveTracker extends Tracker { // boolean hasOwner(@Nonnull TNTPrimed entity); // // @Nullable Player getOwner(@Nonnull TNTPrimed entity); // // @Nullable Player setOwner(@Nonnull TNTPrimed entity, @Nullable Player player); // // boolean hasPlacer(@Nonnull Block block); // // @Nullable Player getPlacer(@Nonnull Block block); // // @Nullable Player setPlacer(@Nonnull Block block, @Nullable Player player); // } // Path: src/main/java/tc/oc/tracker/damage/resolvers/TNTDamageResolver.java import javax.annotation.Nonnull; import javax.annotation.Nullable; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.entity.TNTPrimed; import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageEvent; import tc.oc.tracker.DamageInfo; import tc.oc.tracker.DamageResolver; import tc.oc.tracker.Lifetime; import tc.oc.tracker.damage.TNTDamageInfo; import tc.oc.tracker.trackers.DispenserTracker; import tc.oc.tracker.trackers.ExplosiveTracker; package tc.oc.tracker.damage.resolvers; public class TNTDamageResolver implements DamageResolver { private final ExplosiveTracker explosiveTracker;
private final DispenserTracker dispenserTracker;
OvercastNetwork/Tracker
src/main/java/tc/oc/tracker/damage/resolvers/TNTDamageResolver.java
// Path: src/main/java/tc/oc/tracker/DamageInfo.java // public interface DamageInfo { // /** // * Gets the living entity most responsible for this damage. // * // * @return Resolved damager or null if none exists // */ // @Nullable LivingEntity getResolvedDamager(); // } // // Path: src/main/java/tc/oc/tracker/DamageResolver.java // public interface DamageResolver { // @Nullable DamageInfo resolve(@Nonnull LivingEntity entity, @Nonnull Lifetime lifetime, @Nonnull EntityDamageEvent damageEvent); // } // // Path: src/main/java/tc/oc/tracker/Lifetime.java // public interface Lifetime { // @Nullable Instant getStart(); // // void setStart(@Nonnull Instant start); // // @Nullable Instant getEnd(); // // void setEnd(@Nonnull Instant end); // // @Nonnull List<Damage> getDamage(); // // @Nonnull ListIterator<Damage> getDamageFirst(); // // @Nonnull ListIterator<Damage> getDamageLast(); // // @Nullable Damage getFirstDamage(); // // @Nullable Damage getLastDamage(); // // /** // * Gets the last damage instance where the info object is an instance of // * the specified class. Uses {@link Class#isInstance(Object)} to check info // * objects. // * // * @param damageInfoClass DamageInfo class to check for // * @return Last damage that matched or null if none matched // * // * @throws NullPointerException if damageInfoClass is null // */ // @Nullable Damage getLastDamage(@Nonnull Class<? extends DamageInfo> damageInfoClass); // // void addDamage(@Nonnull Damage damage); // } // // Path: src/main/java/tc/oc/tracker/damage/TNTDamageInfo.java // public class TNTDamageInfo extends ExplosiveDamageInfo { // public TNTDamageInfo(@Nonnull TNTPrimed explosive, @Nullable LivingEntity resolvedDamager) { // super(explosive, resolvedDamager); // } // // @Override // public @Nonnull TNTPrimed getExplosive() { // return (TNTPrimed) this.explosive; // } // // @Override // public @Nonnull String toString() { // return "TNTDamageInfo{explosive=" + this.explosive + ",damager=" + this.resolvedDamager + "}"; // } // } // // Path: src/main/java/tc/oc/tracker/trackers/DispenserTracker.java // public interface DispenserTracker extends Tracker { // boolean hasOwner(@Nonnull Entity entity); // // @Nullable OfflinePlayer getOwner(@Nonnull Entity entity); // // @Nullable OfflinePlayer setOwner(@Nonnull Entity entity, @Nullable Player player); // // boolean hasPlacer(@Nonnull Block block); // // @Nullable OfflinePlayer getPlacer(@Nonnull Block block); // // @Nullable OfflinePlayer setPlacer(@Nonnull Block block, @Nullable Player player); // // @Nonnull OfflinePlayer clearPlacer(@Nonnull Block block); // } // // Path: src/main/java/tc/oc/tracker/trackers/ExplosiveTracker.java // public interface ExplosiveTracker extends Tracker { // boolean hasOwner(@Nonnull TNTPrimed entity); // // @Nullable Player getOwner(@Nonnull TNTPrimed entity); // // @Nullable Player setOwner(@Nonnull TNTPrimed entity, @Nullable Player player); // // boolean hasPlacer(@Nonnull Block block); // // @Nullable Player getPlacer(@Nonnull Block block); // // @Nullable Player setPlacer(@Nonnull Block block, @Nullable Player player); // }
import javax.annotation.Nonnull; import javax.annotation.Nullable; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.entity.TNTPrimed; import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageEvent; import tc.oc.tracker.DamageInfo; import tc.oc.tracker.DamageResolver; import tc.oc.tracker.Lifetime; import tc.oc.tracker.damage.TNTDamageInfo; import tc.oc.tracker.trackers.DispenserTracker; import tc.oc.tracker.trackers.ExplosiveTracker;
package tc.oc.tracker.damage.resolvers; public class TNTDamageResolver implements DamageResolver { private final ExplosiveTracker explosiveTracker; private final DispenserTracker dispenserTracker; public TNTDamageResolver(ExplosiveTracker explosiveTracker, DispenserTracker dispenserTracker) { this.explosiveTracker = explosiveTracker; this.dispenserTracker = dispenserTracker; }
// Path: src/main/java/tc/oc/tracker/DamageInfo.java // public interface DamageInfo { // /** // * Gets the living entity most responsible for this damage. // * // * @return Resolved damager or null if none exists // */ // @Nullable LivingEntity getResolvedDamager(); // } // // Path: src/main/java/tc/oc/tracker/DamageResolver.java // public interface DamageResolver { // @Nullable DamageInfo resolve(@Nonnull LivingEntity entity, @Nonnull Lifetime lifetime, @Nonnull EntityDamageEvent damageEvent); // } // // Path: src/main/java/tc/oc/tracker/Lifetime.java // public interface Lifetime { // @Nullable Instant getStart(); // // void setStart(@Nonnull Instant start); // // @Nullable Instant getEnd(); // // void setEnd(@Nonnull Instant end); // // @Nonnull List<Damage> getDamage(); // // @Nonnull ListIterator<Damage> getDamageFirst(); // // @Nonnull ListIterator<Damage> getDamageLast(); // // @Nullable Damage getFirstDamage(); // // @Nullable Damage getLastDamage(); // // /** // * Gets the last damage instance where the info object is an instance of // * the specified class. Uses {@link Class#isInstance(Object)} to check info // * objects. // * // * @param damageInfoClass DamageInfo class to check for // * @return Last damage that matched or null if none matched // * // * @throws NullPointerException if damageInfoClass is null // */ // @Nullable Damage getLastDamage(@Nonnull Class<? extends DamageInfo> damageInfoClass); // // void addDamage(@Nonnull Damage damage); // } // // Path: src/main/java/tc/oc/tracker/damage/TNTDamageInfo.java // public class TNTDamageInfo extends ExplosiveDamageInfo { // public TNTDamageInfo(@Nonnull TNTPrimed explosive, @Nullable LivingEntity resolvedDamager) { // super(explosive, resolvedDamager); // } // // @Override // public @Nonnull TNTPrimed getExplosive() { // return (TNTPrimed) this.explosive; // } // // @Override // public @Nonnull String toString() { // return "TNTDamageInfo{explosive=" + this.explosive + ",damager=" + this.resolvedDamager + "}"; // } // } // // Path: src/main/java/tc/oc/tracker/trackers/DispenserTracker.java // public interface DispenserTracker extends Tracker { // boolean hasOwner(@Nonnull Entity entity); // // @Nullable OfflinePlayer getOwner(@Nonnull Entity entity); // // @Nullable OfflinePlayer setOwner(@Nonnull Entity entity, @Nullable Player player); // // boolean hasPlacer(@Nonnull Block block); // // @Nullable OfflinePlayer getPlacer(@Nonnull Block block); // // @Nullable OfflinePlayer setPlacer(@Nonnull Block block, @Nullable Player player); // // @Nonnull OfflinePlayer clearPlacer(@Nonnull Block block); // } // // Path: src/main/java/tc/oc/tracker/trackers/ExplosiveTracker.java // public interface ExplosiveTracker extends Tracker { // boolean hasOwner(@Nonnull TNTPrimed entity); // // @Nullable Player getOwner(@Nonnull TNTPrimed entity); // // @Nullable Player setOwner(@Nonnull TNTPrimed entity, @Nullable Player player); // // boolean hasPlacer(@Nonnull Block block); // // @Nullable Player getPlacer(@Nonnull Block block); // // @Nullable Player setPlacer(@Nonnull Block block, @Nullable Player player); // } // Path: src/main/java/tc/oc/tracker/damage/resolvers/TNTDamageResolver.java import javax.annotation.Nonnull; import javax.annotation.Nullable; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.entity.TNTPrimed; import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageEvent; import tc.oc.tracker.DamageInfo; import tc.oc.tracker.DamageResolver; import tc.oc.tracker.Lifetime; import tc.oc.tracker.damage.TNTDamageInfo; import tc.oc.tracker.trackers.DispenserTracker; import tc.oc.tracker.trackers.ExplosiveTracker; package tc.oc.tracker.damage.resolvers; public class TNTDamageResolver implements DamageResolver { private final ExplosiveTracker explosiveTracker; private final DispenserTracker dispenserTracker; public TNTDamageResolver(ExplosiveTracker explosiveTracker, DispenserTracker dispenserTracker) { this.explosiveTracker = explosiveTracker; this.dispenserTracker = dispenserTracker; }
public @Nullable DamageInfo resolve(@Nonnull LivingEntity entity, @Nonnull Lifetime lifetime, @Nonnull EntityDamageEvent damageEvent) {
OvercastNetwork/Tracker
src/main/java/tc/oc/tracker/damage/resolvers/TNTDamageResolver.java
// Path: src/main/java/tc/oc/tracker/DamageInfo.java // public interface DamageInfo { // /** // * Gets the living entity most responsible for this damage. // * // * @return Resolved damager or null if none exists // */ // @Nullable LivingEntity getResolvedDamager(); // } // // Path: src/main/java/tc/oc/tracker/DamageResolver.java // public interface DamageResolver { // @Nullable DamageInfo resolve(@Nonnull LivingEntity entity, @Nonnull Lifetime lifetime, @Nonnull EntityDamageEvent damageEvent); // } // // Path: src/main/java/tc/oc/tracker/Lifetime.java // public interface Lifetime { // @Nullable Instant getStart(); // // void setStart(@Nonnull Instant start); // // @Nullable Instant getEnd(); // // void setEnd(@Nonnull Instant end); // // @Nonnull List<Damage> getDamage(); // // @Nonnull ListIterator<Damage> getDamageFirst(); // // @Nonnull ListIterator<Damage> getDamageLast(); // // @Nullable Damage getFirstDamage(); // // @Nullable Damage getLastDamage(); // // /** // * Gets the last damage instance where the info object is an instance of // * the specified class. Uses {@link Class#isInstance(Object)} to check info // * objects. // * // * @param damageInfoClass DamageInfo class to check for // * @return Last damage that matched or null if none matched // * // * @throws NullPointerException if damageInfoClass is null // */ // @Nullable Damage getLastDamage(@Nonnull Class<? extends DamageInfo> damageInfoClass); // // void addDamage(@Nonnull Damage damage); // } // // Path: src/main/java/tc/oc/tracker/damage/TNTDamageInfo.java // public class TNTDamageInfo extends ExplosiveDamageInfo { // public TNTDamageInfo(@Nonnull TNTPrimed explosive, @Nullable LivingEntity resolvedDamager) { // super(explosive, resolvedDamager); // } // // @Override // public @Nonnull TNTPrimed getExplosive() { // return (TNTPrimed) this.explosive; // } // // @Override // public @Nonnull String toString() { // return "TNTDamageInfo{explosive=" + this.explosive + ",damager=" + this.resolvedDamager + "}"; // } // } // // Path: src/main/java/tc/oc/tracker/trackers/DispenserTracker.java // public interface DispenserTracker extends Tracker { // boolean hasOwner(@Nonnull Entity entity); // // @Nullable OfflinePlayer getOwner(@Nonnull Entity entity); // // @Nullable OfflinePlayer setOwner(@Nonnull Entity entity, @Nullable Player player); // // boolean hasPlacer(@Nonnull Block block); // // @Nullable OfflinePlayer getPlacer(@Nonnull Block block); // // @Nullable OfflinePlayer setPlacer(@Nonnull Block block, @Nullable Player player); // // @Nonnull OfflinePlayer clearPlacer(@Nonnull Block block); // } // // Path: src/main/java/tc/oc/tracker/trackers/ExplosiveTracker.java // public interface ExplosiveTracker extends Tracker { // boolean hasOwner(@Nonnull TNTPrimed entity); // // @Nullable Player getOwner(@Nonnull TNTPrimed entity); // // @Nullable Player setOwner(@Nonnull TNTPrimed entity, @Nullable Player player); // // boolean hasPlacer(@Nonnull Block block); // // @Nullable Player getPlacer(@Nonnull Block block); // // @Nullable Player setPlacer(@Nonnull Block block, @Nullable Player player); // }
import javax.annotation.Nonnull; import javax.annotation.Nullable; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.entity.TNTPrimed; import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageEvent; import tc.oc.tracker.DamageInfo; import tc.oc.tracker.DamageResolver; import tc.oc.tracker.Lifetime; import tc.oc.tracker.damage.TNTDamageInfo; import tc.oc.tracker.trackers.DispenserTracker; import tc.oc.tracker.trackers.ExplosiveTracker;
package tc.oc.tracker.damage.resolvers; public class TNTDamageResolver implements DamageResolver { private final ExplosiveTracker explosiveTracker; private final DispenserTracker dispenserTracker; public TNTDamageResolver(ExplosiveTracker explosiveTracker, DispenserTracker dispenserTracker) { this.explosiveTracker = explosiveTracker; this.dispenserTracker = dispenserTracker; }
// Path: src/main/java/tc/oc/tracker/DamageInfo.java // public interface DamageInfo { // /** // * Gets the living entity most responsible for this damage. // * // * @return Resolved damager or null if none exists // */ // @Nullable LivingEntity getResolvedDamager(); // } // // Path: src/main/java/tc/oc/tracker/DamageResolver.java // public interface DamageResolver { // @Nullable DamageInfo resolve(@Nonnull LivingEntity entity, @Nonnull Lifetime lifetime, @Nonnull EntityDamageEvent damageEvent); // } // // Path: src/main/java/tc/oc/tracker/Lifetime.java // public interface Lifetime { // @Nullable Instant getStart(); // // void setStart(@Nonnull Instant start); // // @Nullable Instant getEnd(); // // void setEnd(@Nonnull Instant end); // // @Nonnull List<Damage> getDamage(); // // @Nonnull ListIterator<Damage> getDamageFirst(); // // @Nonnull ListIterator<Damage> getDamageLast(); // // @Nullable Damage getFirstDamage(); // // @Nullable Damage getLastDamage(); // // /** // * Gets the last damage instance where the info object is an instance of // * the specified class. Uses {@link Class#isInstance(Object)} to check info // * objects. // * // * @param damageInfoClass DamageInfo class to check for // * @return Last damage that matched or null if none matched // * // * @throws NullPointerException if damageInfoClass is null // */ // @Nullable Damage getLastDamage(@Nonnull Class<? extends DamageInfo> damageInfoClass); // // void addDamage(@Nonnull Damage damage); // } // // Path: src/main/java/tc/oc/tracker/damage/TNTDamageInfo.java // public class TNTDamageInfo extends ExplosiveDamageInfo { // public TNTDamageInfo(@Nonnull TNTPrimed explosive, @Nullable LivingEntity resolvedDamager) { // super(explosive, resolvedDamager); // } // // @Override // public @Nonnull TNTPrimed getExplosive() { // return (TNTPrimed) this.explosive; // } // // @Override // public @Nonnull String toString() { // return "TNTDamageInfo{explosive=" + this.explosive + ",damager=" + this.resolvedDamager + "}"; // } // } // // Path: src/main/java/tc/oc/tracker/trackers/DispenserTracker.java // public interface DispenserTracker extends Tracker { // boolean hasOwner(@Nonnull Entity entity); // // @Nullable OfflinePlayer getOwner(@Nonnull Entity entity); // // @Nullable OfflinePlayer setOwner(@Nonnull Entity entity, @Nullable Player player); // // boolean hasPlacer(@Nonnull Block block); // // @Nullable OfflinePlayer getPlacer(@Nonnull Block block); // // @Nullable OfflinePlayer setPlacer(@Nonnull Block block, @Nullable Player player); // // @Nonnull OfflinePlayer clearPlacer(@Nonnull Block block); // } // // Path: src/main/java/tc/oc/tracker/trackers/ExplosiveTracker.java // public interface ExplosiveTracker extends Tracker { // boolean hasOwner(@Nonnull TNTPrimed entity); // // @Nullable Player getOwner(@Nonnull TNTPrimed entity); // // @Nullable Player setOwner(@Nonnull TNTPrimed entity, @Nullable Player player); // // boolean hasPlacer(@Nonnull Block block); // // @Nullable Player getPlacer(@Nonnull Block block); // // @Nullable Player setPlacer(@Nonnull Block block, @Nullable Player player); // } // Path: src/main/java/tc/oc/tracker/damage/resolvers/TNTDamageResolver.java import javax.annotation.Nonnull; import javax.annotation.Nullable; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.entity.TNTPrimed; import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageEvent; import tc.oc.tracker.DamageInfo; import tc.oc.tracker.DamageResolver; import tc.oc.tracker.Lifetime; import tc.oc.tracker.damage.TNTDamageInfo; import tc.oc.tracker.trackers.DispenserTracker; import tc.oc.tracker.trackers.ExplosiveTracker; package tc.oc.tracker.damage.resolvers; public class TNTDamageResolver implements DamageResolver { private final ExplosiveTracker explosiveTracker; private final DispenserTracker dispenserTracker; public TNTDamageResolver(ExplosiveTracker explosiveTracker, DispenserTracker dispenserTracker) { this.explosiveTracker = explosiveTracker; this.dispenserTracker = dispenserTracker; }
public @Nullable DamageInfo resolve(@Nonnull LivingEntity entity, @Nonnull Lifetime lifetime, @Nonnull EntityDamageEvent damageEvent) {
OvercastNetwork/Tracker
src/main/java/tc/oc/tracker/damage/resolvers/TNTDamageResolver.java
// Path: src/main/java/tc/oc/tracker/DamageInfo.java // public interface DamageInfo { // /** // * Gets the living entity most responsible for this damage. // * // * @return Resolved damager or null if none exists // */ // @Nullable LivingEntity getResolvedDamager(); // } // // Path: src/main/java/tc/oc/tracker/DamageResolver.java // public interface DamageResolver { // @Nullable DamageInfo resolve(@Nonnull LivingEntity entity, @Nonnull Lifetime lifetime, @Nonnull EntityDamageEvent damageEvent); // } // // Path: src/main/java/tc/oc/tracker/Lifetime.java // public interface Lifetime { // @Nullable Instant getStart(); // // void setStart(@Nonnull Instant start); // // @Nullable Instant getEnd(); // // void setEnd(@Nonnull Instant end); // // @Nonnull List<Damage> getDamage(); // // @Nonnull ListIterator<Damage> getDamageFirst(); // // @Nonnull ListIterator<Damage> getDamageLast(); // // @Nullable Damage getFirstDamage(); // // @Nullable Damage getLastDamage(); // // /** // * Gets the last damage instance where the info object is an instance of // * the specified class. Uses {@link Class#isInstance(Object)} to check info // * objects. // * // * @param damageInfoClass DamageInfo class to check for // * @return Last damage that matched or null if none matched // * // * @throws NullPointerException if damageInfoClass is null // */ // @Nullable Damage getLastDamage(@Nonnull Class<? extends DamageInfo> damageInfoClass); // // void addDamage(@Nonnull Damage damage); // } // // Path: src/main/java/tc/oc/tracker/damage/TNTDamageInfo.java // public class TNTDamageInfo extends ExplosiveDamageInfo { // public TNTDamageInfo(@Nonnull TNTPrimed explosive, @Nullable LivingEntity resolvedDamager) { // super(explosive, resolvedDamager); // } // // @Override // public @Nonnull TNTPrimed getExplosive() { // return (TNTPrimed) this.explosive; // } // // @Override // public @Nonnull String toString() { // return "TNTDamageInfo{explosive=" + this.explosive + ",damager=" + this.resolvedDamager + "}"; // } // } // // Path: src/main/java/tc/oc/tracker/trackers/DispenserTracker.java // public interface DispenserTracker extends Tracker { // boolean hasOwner(@Nonnull Entity entity); // // @Nullable OfflinePlayer getOwner(@Nonnull Entity entity); // // @Nullable OfflinePlayer setOwner(@Nonnull Entity entity, @Nullable Player player); // // boolean hasPlacer(@Nonnull Block block); // // @Nullable OfflinePlayer getPlacer(@Nonnull Block block); // // @Nullable OfflinePlayer setPlacer(@Nonnull Block block, @Nullable Player player); // // @Nonnull OfflinePlayer clearPlacer(@Nonnull Block block); // } // // Path: src/main/java/tc/oc/tracker/trackers/ExplosiveTracker.java // public interface ExplosiveTracker extends Tracker { // boolean hasOwner(@Nonnull TNTPrimed entity); // // @Nullable Player getOwner(@Nonnull TNTPrimed entity); // // @Nullable Player setOwner(@Nonnull TNTPrimed entity, @Nullable Player player); // // boolean hasPlacer(@Nonnull Block block); // // @Nullable Player getPlacer(@Nonnull Block block); // // @Nullable Player setPlacer(@Nonnull Block block, @Nullable Player player); // }
import javax.annotation.Nonnull; import javax.annotation.Nullable; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.entity.TNTPrimed; import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageEvent; import tc.oc.tracker.DamageInfo; import tc.oc.tracker.DamageResolver; import tc.oc.tracker.Lifetime; import tc.oc.tracker.damage.TNTDamageInfo; import tc.oc.tracker.trackers.DispenserTracker; import tc.oc.tracker.trackers.ExplosiveTracker;
package tc.oc.tracker.damage.resolvers; public class TNTDamageResolver implements DamageResolver { private final ExplosiveTracker explosiveTracker; private final DispenserTracker dispenserTracker; public TNTDamageResolver(ExplosiveTracker explosiveTracker, DispenserTracker dispenserTracker) { this.explosiveTracker = explosiveTracker; this.dispenserTracker = dispenserTracker; } public @Nullable DamageInfo resolve(@Nonnull LivingEntity entity, @Nonnull Lifetime lifetime, @Nonnull EntityDamageEvent damageEvent) { if(damageEvent instanceof EntityDamageByEntityEvent) { EntityDamageByEntityEvent event = (EntityDamageByEntityEvent) damageEvent; if(event.getDamager() instanceof TNTPrimed) { TNTPrimed tnt = (TNTPrimed) event.getDamager(); Player owner = null; if(this.explosiveTracker.hasOwner(tnt)) { owner = this.explosiveTracker.getOwner(tnt); } else if(this.dispenserTracker.hasOwner(tnt)) { // getPlayer() is temporary to keep owner uniform until other trackers use OfflinePlayer owner = this.dispenserTracker.getOwner(tnt).getPlayer(); }
// Path: src/main/java/tc/oc/tracker/DamageInfo.java // public interface DamageInfo { // /** // * Gets the living entity most responsible for this damage. // * // * @return Resolved damager or null if none exists // */ // @Nullable LivingEntity getResolvedDamager(); // } // // Path: src/main/java/tc/oc/tracker/DamageResolver.java // public interface DamageResolver { // @Nullable DamageInfo resolve(@Nonnull LivingEntity entity, @Nonnull Lifetime lifetime, @Nonnull EntityDamageEvent damageEvent); // } // // Path: src/main/java/tc/oc/tracker/Lifetime.java // public interface Lifetime { // @Nullable Instant getStart(); // // void setStart(@Nonnull Instant start); // // @Nullable Instant getEnd(); // // void setEnd(@Nonnull Instant end); // // @Nonnull List<Damage> getDamage(); // // @Nonnull ListIterator<Damage> getDamageFirst(); // // @Nonnull ListIterator<Damage> getDamageLast(); // // @Nullable Damage getFirstDamage(); // // @Nullable Damage getLastDamage(); // // /** // * Gets the last damage instance where the info object is an instance of // * the specified class. Uses {@link Class#isInstance(Object)} to check info // * objects. // * // * @param damageInfoClass DamageInfo class to check for // * @return Last damage that matched or null if none matched // * // * @throws NullPointerException if damageInfoClass is null // */ // @Nullable Damage getLastDamage(@Nonnull Class<? extends DamageInfo> damageInfoClass); // // void addDamage(@Nonnull Damage damage); // } // // Path: src/main/java/tc/oc/tracker/damage/TNTDamageInfo.java // public class TNTDamageInfo extends ExplosiveDamageInfo { // public TNTDamageInfo(@Nonnull TNTPrimed explosive, @Nullable LivingEntity resolvedDamager) { // super(explosive, resolvedDamager); // } // // @Override // public @Nonnull TNTPrimed getExplosive() { // return (TNTPrimed) this.explosive; // } // // @Override // public @Nonnull String toString() { // return "TNTDamageInfo{explosive=" + this.explosive + ",damager=" + this.resolvedDamager + "}"; // } // } // // Path: src/main/java/tc/oc/tracker/trackers/DispenserTracker.java // public interface DispenserTracker extends Tracker { // boolean hasOwner(@Nonnull Entity entity); // // @Nullable OfflinePlayer getOwner(@Nonnull Entity entity); // // @Nullable OfflinePlayer setOwner(@Nonnull Entity entity, @Nullable Player player); // // boolean hasPlacer(@Nonnull Block block); // // @Nullable OfflinePlayer getPlacer(@Nonnull Block block); // // @Nullable OfflinePlayer setPlacer(@Nonnull Block block, @Nullable Player player); // // @Nonnull OfflinePlayer clearPlacer(@Nonnull Block block); // } // // Path: src/main/java/tc/oc/tracker/trackers/ExplosiveTracker.java // public interface ExplosiveTracker extends Tracker { // boolean hasOwner(@Nonnull TNTPrimed entity); // // @Nullable Player getOwner(@Nonnull TNTPrimed entity); // // @Nullable Player setOwner(@Nonnull TNTPrimed entity, @Nullable Player player); // // boolean hasPlacer(@Nonnull Block block); // // @Nullable Player getPlacer(@Nonnull Block block); // // @Nullable Player setPlacer(@Nonnull Block block, @Nullable Player player); // } // Path: src/main/java/tc/oc/tracker/damage/resolvers/TNTDamageResolver.java import javax.annotation.Nonnull; import javax.annotation.Nullable; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.entity.TNTPrimed; import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageEvent; import tc.oc.tracker.DamageInfo; import tc.oc.tracker.DamageResolver; import tc.oc.tracker.Lifetime; import tc.oc.tracker.damage.TNTDamageInfo; import tc.oc.tracker.trackers.DispenserTracker; import tc.oc.tracker.trackers.ExplosiveTracker; package tc.oc.tracker.damage.resolvers; public class TNTDamageResolver implements DamageResolver { private final ExplosiveTracker explosiveTracker; private final DispenserTracker dispenserTracker; public TNTDamageResolver(ExplosiveTracker explosiveTracker, DispenserTracker dispenserTracker) { this.explosiveTracker = explosiveTracker; this.dispenserTracker = dispenserTracker; } public @Nullable DamageInfo resolve(@Nonnull LivingEntity entity, @Nonnull Lifetime lifetime, @Nonnull EntityDamageEvent damageEvent) { if(damageEvent instanceof EntityDamageByEntityEvent) { EntityDamageByEntityEvent event = (EntityDamageByEntityEvent) damageEvent; if(event.getDamager() instanceof TNTPrimed) { TNTPrimed tnt = (TNTPrimed) event.getDamager(); Player owner = null; if(this.explosiveTracker.hasOwner(tnt)) { owner = this.explosiveTracker.getOwner(tnt); } else if(this.dispenserTracker.hasOwner(tnt)) { // getPlayer() is temporary to keep owner uniform until other trackers use OfflinePlayer owner = this.dispenserTracker.getOwner(tnt).getPlayer(); }
return new TNTDamageInfo(tnt, owner);
OvercastNetwork/Tracker
src/main/java/tc/oc/tracker/damage/resolvers/MeleeDamageResolver.java
// Path: src/main/java/tc/oc/tracker/DamageInfo.java // public interface DamageInfo { // /** // * Gets the living entity most responsible for this damage. // * // * @return Resolved damager or null if none exists // */ // @Nullable LivingEntity getResolvedDamager(); // } // // Path: src/main/java/tc/oc/tracker/DamageResolver.java // public interface DamageResolver { // @Nullable DamageInfo resolve(@Nonnull LivingEntity entity, @Nonnull Lifetime lifetime, @Nonnull EntityDamageEvent damageEvent); // } // // Path: src/main/java/tc/oc/tracker/Lifetime.java // public interface Lifetime { // @Nullable Instant getStart(); // // void setStart(@Nonnull Instant start); // // @Nullable Instant getEnd(); // // void setEnd(@Nonnull Instant end); // // @Nonnull List<Damage> getDamage(); // // @Nonnull ListIterator<Damage> getDamageFirst(); // // @Nonnull ListIterator<Damage> getDamageLast(); // // @Nullable Damage getFirstDamage(); // // @Nullable Damage getLastDamage(); // // /** // * Gets the last damage instance where the info object is an instance of // * the specified class. Uses {@link Class#isInstance(Object)} to check info // * objects. // * // * @param damageInfoClass DamageInfo class to check for // * @return Last damage that matched or null if none matched // * // * @throws NullPointerException if damageInfoClass is null // */ // @Nullable Damage getLastDamage(@Nonnull Class<? extends DamageInfo> damageInfoClass); // // void addDamage(@Nonnull Damage damage); // } // // Path: src/main/java/tc/oc/tracker/damage/base/SimpleMeleeDamageInfo.java // public class SimpleMeleeDamageInfo extends AbstractDamageInfo implements MeleeDamageInfo { // public SimpleMeleeDamageInfo(@Nonnull LivingEntity attacker, @Nonnull Material weaponMaterial) { // super(attacker); // // Preconditions.checkNotNull(attacker, "attacker"); // Preconditions.checkNotNull(weaponMaterial, "weapon material"); // // this.weaponMaterial = weaponMaterial; // } // // public @Nonnull LivingEntity getAttacker() { // return this.resolvedDamager; // } // // public @Nonnull Material getWeapon() { // return this.weaponMaterial; // } // // private final @Nonnull Material weaponMaterial; // }
import javax.annotation.Nonnull; import javax.annotation.Nullable; import org.bukkit.Material; import org.bukkit.entity.LivingEntity; import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.inventory.ItemStack; import tc.oc.tracker.DamageInfo; import tc.oc.tracker.DamageResolver; import tc.oc.tracker.Lifetime; import tc.oc.tracker.damage.base.SimpleMeleeDamageInfo;
package tc.oc.tracker.damage.resolvers; public class MeleeDamageResolver implements DamageResolver { public @Nullable DamageInfo resolve(@Nonnull LivingEntity entity, @Nonnull Lifetime lifetime, @Nonnull EntityDamageEvent damageEvent) { if(damageEvent instanceof EntityDamageByEntityEvent && damageEvent.getCause() == DamageCause.ENTITY_ATTACK) { EntityDamageByEntityEvent entityEvent = (EntityDamageByEntityEvent) damageEvent; if(entityEvent.getDamager() instanceof LivingEntity) { LivingEntity attacker = (LivingEntity) entityEvent.getDamager(); Material weaponMaterial; ItemStack held = attacker.getEquipment().getItemInHand(); if(held != null) { weaponMaterial = held.getType(); } else { weaponMaterial = Material.AIR; }
// Path: src/main/java/tc/oc/tracker/DamageInfo.java // public interface DamageInfo { // /** // * Gets the living entity most responsible for this damage. // * // * @return Resolved damager or null if none exists // */ // @Nullable LivingEntity getResolvedDamager(); // } // // Path: src/main/java/tc/oc/tracker/DamageResolver.java // public interface DamageResolver { // @Nullable DamageInfo resolve(@Nonnull LivingEntity entity, @Nonnull Lifetime lifetime, @Nonnull EntityDamageEvent damageEvent); // } // // Path: src/main/java/tc/oc/tracker/Lifetime.java // public interface Lifetime { // @Nullable Instant getStart(); // // void setStart(@Nonnull Instant start); // // @Nullable Instant getEnd(); // // void setEnd(@Nonnull Instant end); // // @Nonnull List<Damage> getDamage(); // // @Nonnull ListIterator<Damage> getDamageFirst(); // // @Nonnull ListIterator<Damage> getDamageLast(); // // @Nullable Damage getFirstDamage(); // // @Nullable Damage getLastDamage(); // // /** // * Gets the last damage instance where the info object is an instance of // * the specified class. Uses {@link Class#isInstance(Object)} to check info // * objects. // * // * @param damageInfoClass DamageInfo class to check for // * @return Last damage that matched or null if none matched // * // * @throws NullPointerException if damageInfoClass is null // */ // @Nullable Damage getLastDamage(@Nonnull Class<? extends DamageInfo> damageInfoClass); // // void addDamage(@Nonnull Damage damage); // } // // Path: src/main/java/tc/oc/tracker/damage/base/SimpleMeleeDamageInfo.java // public class SimpleMeleeDamageInfo extends AbstractDamageInfo implements MeleeDamageInfo { // public SimpleMeleeDamageInfo(@Nonnull LivingEntity attacker, @Nonnull Material weaponMaterial) { // super(attacker); // // Preconditions.checkNotNull(attacker, "attacker"); // Preconditions.checkNotNull(weaponMaterial, "weapon material"); // // this.weaponMaterial = weaponMaterial; // } // // public @Nonnull LivingEntity getAttacker() { // return this.resolvedDamager; // } // // public @Nonnull Material getWeapon() { // return this.weaponMaterial; // } // // private final @Nonnull Material weaponMaterial; // } // Path: src/main/java/tc/oc/tracker/damage/resolvers/MeleeDamageResolver.java import javax.annotation.Nonnull; import javax.annotation.Nullable; import org.bukkit.Material; import org.bukkit.entity.LivingEntity; import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.inventory.ItemStack; import tc.oc.tracker.DamageInfo; import tc.oc.tracker.DamageResolver; import tc.oc.tracker.Lifetime; import tc.oc.tracker.damage.base.SimpleMeleeDamageInfo; package tc.oc.tracker.damage.resolvers; public class MeleeDamageResolver implements DamageResolver { public @Nullable DamageInfo resolve(@Nonnull LivingEntity entity, @Nonnull Lifetime lifetime, @Nonnull EntityDamageEvent damageEvent) { if(damageEvent instanceof EntityDamageByEntityEvent && damageEvent.getCause() == DamageCause.ENTITY_ATTACK) { EntityDamageByEntityEvent entityEvent = (EntityDamageByEntityEvent) damageEvent; if(entityEvent.getDamager() instanceof LivingEntity) { LivingEntity attacker = (LivingEntity) entityEvent.getDamager(); Material weaponMaterial; ItemStack held = attacker.getEquipment().getItemInHand(); if(held != null) { weaponMaterial = held.getType(); } else { weaponMaterial = Material.AIR; }
return new SimpleMeleeDamageInfo(attacker, weaponMaterial);
OvercastNetwork/Tracker
src/main/java/tc/oc/tracker/plugin/DebugListener.java
// Path: src/main/java/tc/oc/tracker/event/EntityDamageEvent.java // public class EntityDamageEvent extends Event implements Cancellable { // private final @Nonnull LivingEntity entity; // private final @Nonnull Lifetime lifetime; // private int damage; // private final @Nonnull Location location; // private final @Nonnull Instant time; // private final @Nonnull DamageInfo info; // private boolean cancelled = false; // // public EntityDamageEvent(@Nonnull LivingEntity entity, @Nonnull Lifetime lifetime, int damage, @Nonnull Location location, @Nonnull Instant time, @Nonnull DamageInfo info) { // Preconditions.checkNotNull(entity, "entity"); // Preconditions.checkNotNull(lifetime, "lifetime"); // Preconditions.checkArgument(damage >= 0, "damage must be greater than or equal to zero"); // Preconditions.checkNotNull(location, "location"); // Preconditions.checkNotNull(time, "time"); // Preconditions.checkNotNull(info, "damage info"); // // this.entity = entity; // this.lifetime = lifetime; // this.damage = damage; // this.location = location.clone(); // this.time = time; // this.info = info; // } // // public @Nonnull LivingEntity getEntity() { // return this.entity; // } // // public @Nonnull Lifetime getLifetime() { // return this.lifetime; // } // // public int getDamage() { // return this.damage; // } // // public void setDamage(int damage) { // Preconditions.checkArgument(damage >= 0, "damage must be greater than or equal to zero"); // // this.damage = damage; // } // // public @Nonnull Location getLocation() { // return this.location; // } // // public @Nonnull Instant getTime() { // return this.time; // } // // public @Nonnull DamageInfo getInfo() { // return this.info; // } // // public @Nonnull Damage toDamageObject() { // return new SimpleDamage(this.damage, this.location, this.time, this.info); // } // // public boolean isCancelled() { // return this.cancelled; // } // // public void setCancelled(boolean cancel) { // this.cancelled = cancel; // } // // // Bukkit event junk // public static final HandlerList handlers = new HandlerList(); // // @Override // public HandlerList getHandlers() { // return handlers; // } // // public static HandlerList getHandlerList() { // return handlers; // } // }
import org.bukkit.Bukkit; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; import tc.oc.tracker.event.EntityDamageEvent;
package tc.oc.tracker.plugin; public class DebugListener implements Listener { @EventHandler(priority = EventPriority.MONITOR)
// Path: src/main/java/tc/oc/tracker/event/EntityDamageEvent.java // public class EntityDamageEvent extends Event implements Cancellable { // private final @Nonnull LivingEntity entity; // private final @Nonnull Lifetime lifetime; // private int damage; // private final @Nonnull Location location; // private final @Nonnull Instant time; // private final @Nonnull DamageInfo info; // private boolean cancelled = false; // // public EntityDamageEvent(@Nonnull LivingEntity entity, @Nonnull Lifetime lifetime, int damage, @Nonnull Location location, @Nonnull Instant time, @Nonnull DamageInfo info) { // Preconditions.checkNotNull(entity, "entity"); // Preconditions.checkNotNull(lifetime, "lifetime"); // Preconditions.checkArgument(damage >= 0, "damage must be greater than or equal to zero"); // Preconditions.checkNotNull(location, "location"); // Preconditions.checkNotNull(time, "time"); // Preconditions.checkNotNull(info, "damage info"); // // this.entity = entity; // this.lifetime = lifetime; // this.damage = damage; // this.location = location.clone(); // this.time = time; // this.info = info; // } // // public @Nonnull LivingEntity getEntity() { // return this.entity; // } // // public @Nonnull Lifetime getLifetime() { // return this.lifetime; // } // // public int getDamage() { // return this.damage; // } // // public void setDamage(int damage) { // Preconditions.checkArgument(damage >= 0, "damage must be greater than or equal to zero"); // // this.damage = damage; // } // // public @Nonnull Location getLocation() { // return this.location; // } // // public @Nonnull Instant getTime() { // return this.time; // } // // public @Nonnull DamageInfo getInfo() { // return this.info; // } // // public @Nonnull Damage toDamageObject() { // return new SimpleDamage(this.damage, this.location, this.time, this.info); // } // // public boolean isCancelled() { // return this.cancelled; // } // // public void setCancelled(boolean cancel) { // this.cancelled = cancel; // } // // // Bukkit event junk // public static final HandlerList handlers = new HandlerList(); // // @Override // public HandlerList getHandlers() { // return handlers; // } // // public static HandlerList getHandlerList() { // return handlers; // } // } // Path: src/main/java/tc/oc/tracker/plugin/DebugListener.java import org.bukkit.Bukkit; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; import tc.oc.tracker.event.EntityDamageEvent; package tc.oc.tracker.plugin; public class DebugListener implements Listener { @EventHandler(priority = EventPriority.MONITOR)
public void onEntityDamage(final EntityDamageEvent event) {
DeskChan/DeskChan
src/main/java/info/deskchan/gui_javafx/skins/SingleImageSkin.java
// Path: src/main/java/info/deskchan/gui_javafx/Main.java // public class Main implements Plugin { // // private static Main instance; // private PluginProxyInterface pluginProxy; // private Semaphore appInitSem = new Semaphore(0); // // @Override // public boolean initialize(PluginProxyInterface pluginProxy) { // this.pluginProxy = pluginProxy; // instance = this; // // getProperties().load(); // // pluginProxy.setResourceBundle("info/deskchan/gui_javafx/strings"); // pluginProxy.setConfigField("name", pluginProxy.getString("plugin-name")); // pluginProxy.getProperties().putIfHasNot("use-tray", true); // pluginProxy.getProperties().putIfHasNot("skin.name", "illia"); // pluginProxy.getProperties().putIfHasNot("sprites-animation-delay", 20); // pluginProxy.getProperties().putIfHasNot("balloon.text-animation-delay", 50); // // new Thread(() -> { // try { // App.run(PluginManager.getInstance().getArgs()); // } catch (NoClassDefFoundError e){ // pluginProxy.log("WARNING! JavaFX is not installed. GUI plugin is now closing. Please, install JavaFX."); // appInitSem.release(); // instance = null; // } // }).start(); // try { // appInitSem.acquire(); // } catch (InterruptedException e) { // log(e); // } // // return instance != null; // } // // @Override // public void unload() { // synchronized (this) { // getProperties().save(); // } // // if (SystemUtils.IS_OS_WINDOWS) { // MouseEventNotificator.disableHooks(); // } // try { // Platform.exit(); // } catch (Exception e){ // log(e); // } // } // // public static Main getInstance() { // return instance; // } // // public static PluginProxyInterface getPluginProxy() { return instance.pluginProxy; } // // Semaphore getAppInitSem() { // return appInitSem; // } // // public void quit() { // pluginProxy.sendMessage("core:quit", null); // } // // public static void log(String text) { // getPluginProxy().log(text); // } // // public static void log(Throwable e) { // getPluginProxy().log(e); // } // // public static String getString(String text){ // return getPluginProxy().getString(text); // } // // public static synchronized PluginProperties getProperties() { // return getPluginProxy().getProperties(); // } // // public static void runLater(Runnable runnable) { // PlatformImpl.runLater(new Runnable() { // @Override // public void run() { // try { // runnable.run(); // } catch (Throwable e){ // getPluginProxy().log(e); // } // } // }); // } // // } // // Path: src/main/java/info/deskchan/gui_javafx/panes/sprite_drawers/ImageSprite.java // public class ImageSprite extends Sprite { // // private String path = null; // // public static boolean canRead(File path){ // try { // Image image = new Image(new FileInputStream(path)); // return image.getHeight() > 0 && image.getWidth() > 0; // } catch (Exception e){ // Main.log(e); // return false; // } // } // // public static ImageSprite create(File path) throws Exception { // Image image = new Image(new FileInputStream(path)); // // Insets margin; // String textStyle; // try { // Document document = getDocument(path + ".config"); // margin = getMarginFromFile(document); // textStyle = getTextStyle(document); // } catch (Exception e){ // margin = getMarginFromFile(null); // textStyle = getTextStyle(null); // } // // ImageView view = new ImageView(); // view.setImage(image); // // return new ImageSprite(view, textStyle, margin, path); // } // // private ImageSprite(Node sprite, String contentStyle, Insets margin, File path) { // super(sprite, contentStyle, margin); // this.path = path != null ? path.toString() : null; // } // // public double getOriginWidth(){ // return toImageView().getImage() != null ? toImageView().getImage().getWidth() : 0; // } // // public double getOriginHeight(){ // return toImageView().getImage() != null ? toImageView().getImage().getHeight() : 0; // } // // public double getFitWidth() { return toImageView().getFitWidth(); } // // public double getFitHeight(){ return toImageView().getFitHeight(); } // // public void setFitWidth(double width) { toImageView().setFitWidth(width); } // // public void setFitHeight(double height){ toImageView().setFitHeight(height); } // // public ImageView toImageView(){ return (ImageView) sprite; } // // public String getSpritePath(){ return path; } // // }
import info.deskchan.core.Path; import info.deskchan.gui_javafx.Main; import info.deskchan.gui_javafx.panes.sprite_drawers.ImageSprite; import info.deskchan.gui_javafx.panes.sprite_drawers.SVGSprite; import info.deskchan.gui_javafx.panes.sprite_drawers.Sprite; import javafx.geometry.Point2D; import javafx.scene.image.Image; import java.io.File; import java.util.Properties;
package info.deskchan.gui_javafx.skins; class SingleImageSkin implements Skin { private final Path path; private final Path propertiesPath; private final Properties properties = new Properties(); private final Sprite sprite; SingleImageSkin(Path path) { this.path = path;
// Path: src/main/java/info/deskchan/gui_javafx/Main.java // public class Main implements Plugin { // // private static Main instance; // private PluginProxyInterface pluginProxy; // private Semaphore appInitSem = new Semaphore(0); // // @Override // public boolean initialize(PluginProxyInterface pluginProxy) { // this.pluginProxy = pluginProxy; // instance = this; // // getProperties().load(); // // pluginProxy.setResourceBundle("info/deskchan/gui_javafx/strings"); // pluginProxy.setConfigField("name", pluginProxy.getString("plugin-name")); // pluginProxy.getProperties().putIfHasNot("use-tray", true); // pluginProxy.getProperties().putIfHasNot("skin.name", "illia"); // pluginProxy.getProperties().putIfHasNot("sprites-animation-delay", 20); // pluginProxy.getProperties().putIfHasNot("balloon.text-animation-delay", 50); // // new Thread(() -> { // try { // App.run(PluginManager.getInstance().getArgs()); // } catch (NoClassDefFoundError e){ // pluginProxy.log("WARNING! JavaFX is not installed. GUI plugin is now closing. Please, install JavaFX."); // appInitSem.release(); // instance = null; // } // }).start(); // try { // appInitSem.acquire(); // } catch (InterruptedException e) { // log(e); // } // // return instance != null; // } // // @Override // public void unload() { // synchronized (this) { // getProperties().save(); // } // // if (SystemUtils.IS_OS_WINDOWS) { // MouseEventNotificator.disableHooks(); // } // try { // Platform.exit(); // } catch (Exception e){ // log(e); // } // } // // public static Main getInstance() { // return instance; // } // // public static PluginProxyInterface getPluginProxy() { return instance.pluginProxy; } // // Semaphore getAppInitSem() { // return appInitSem; // } // // public void quit() { // pluginProxy.sendMessage("core:quit", null); // } // // public static void log(String text) { // getPluginProxy().log(text); // } // // public static void log(Throwable e) { // getPluginProxy().log(e); // } // // public static String getString(String text){ // return getPluginProxy().getString(text); // } // // public static synchronized PluginProperties getProperties() { // return getPluginProxy().getProperties(); // } // // public static void runLater(Runnable runnable) { // PlatformImpl.runLater(new Runnable() { // @Override // public void run() { // try { // runnable.run(); // } catch (Throwable e){ // getPluginProxy().log(e); // } // } // }); // } // // } // // Path: src/main/java/info/deskchan/gui_javafx/panes/sprite_drawers/ImageSprite.java // public class ImageSprite extends Sprite { // // private String path = null; // // public static boolean canRead(File path){ // try { // Image image = new Image(new FileInputStream(path)); // return image.getHeight() > 0 && image.getWidth() > 0; // } catch (Exception e){ // Main.log(e); // return false; // } // } // // public static ImageSprite create(File path) throws Exception { // Image image = new Image(new FileInputStream(path)); // // Insets margin; // String textStyle; // try { // Document document = getDocument(path + ".config"); // margin = getMarginFromFile(document); // textStyle = getTextStyle(document); // } catch (Exception e){ // margin = getMarginFromFile(null); // textStyle = getTextStyle(null); // } // // ImageView view = new ImageView(); // view.setImage(image); // // return new ImageSprite(view, textStyle, margin, path); // } // // private ImageSprite(Node sprite, String contentStyle, Insets margin, File path) { // super(sprite, contentStyle, margin); // this.path = path != null ? path.toString() : null; // } // // public double getOriginWidth(){ // return toImageView().getImage() != null ? toImageView().getImage().getWidth() : 0; // } // // public double getOriginHeight(){ // return toImageView().getImage() != null ? toImageView().getImage().getHeight() : 0; // } // // public double getFitWidth() { return toImageView().getFitWidth(); } // // public double getFitHeight(){ return toImageView().getFitHeight(); } // // public void setFitWidth(double width) { toImageView().setFitWidth(width); } // // public void setFitHeight(double height){ toImageView().setFitHeight(height); } // // public ImageView toImageView(){ return (ImageView) sprite; } // // public String getSpritePath(){ return path; } // // } // Path: src/main/java/info/deskchan/gui_javafx/skins/SingleImageSkin.java import info.deskchan.core.Path; import info.deskchan.gui_javafx.Main; import info.deskchan.gui_javafx.panes.sprite_drawers.ImageSprite; import info.deskchan.gui_javafx.panes.sprite_drawers.SVGSprite; import info.deskchan.gui_javafx.panes.sprite_drawers.Sprite; import javafx.geometry.Point2D; import javafx.scene.image.Image; import java.io.File; import java.util.Properties; package info.deskchan.gui_javafx.skins; class SingleImageSkin implements Skin { private final Path path; private final Path propertiesPath; private final Properties properties = new Properties(); private final Sprite sprite; SingleImageSkin(Path path) { this.path = path;
propertiesPath = Main.getPluginProxy().getDataDirPath().resolve(
DeskChan/DeskChan
src/main/java/info/deskchan/gui_javafx/skins/ImageSetSkin.java
// Path: src/main/java/info/deskchan/gui_javafx/Main.java // public class Main implements Plugin { // // private static Main instance; // private PluginProxyInterface pluginProxy; // private Semaphore appInitSem = new Semaphore(0); // // @Override // public boolean initialize(PluginProxyInterface pluginProxy) { // this.pluginProxy = pluginProxy; // instance = this; // // getProperties().load(); // // pluginProxy.setResourceBundle("info/deskchan/gui_javafx/strings"); // pluginProxy.setConfigField("name", pluginProxy.getString("plugin-name")); // pluginProxy.getProperties().putIfHasNot("use-tray", true); // pluginProxy.getProperties().putIfHasNot("skin.name", "illia"); // pluginProxy.getProperties().putIfHasNot("sprites-animation-delay", 20); // pluginProxy.getProperties().putIfHasNot("balloon.text-animation-delay", 50); // // new Thread(() -> { // try { // App.run(PluginManager.getInstance().getArgs()); // } catch (NoClassDefFoundError e){ // pluginProxy.log("WARNING! JavaFX is not installed. GUI plugin is now closing. Please, install JavaFX."); // appInitSem.release(); // instance = null; // } // }).start(); // try { // appInitSem.acquire(); // } catch (InterruptedException e) { // log(e); // } // // return instance != null; // } // // @Override // public void unload() { // synchronized (this) { // getProperties().save(); // } // // if (SystemUtils.IS_OS_WINDOWS) { // MouseEventNotificator.disableHooks(); // } // try { // Platform.exit(); // } catch (Exception e){ // log(e); // } // } // // public static Main getInstance() { // return instance; // } // // public static PluginProxyInterface getPluginProxy() { return instance.pluginProxy; } // // Semaphore getAppInitSem() { // return appInitSem; // } // // public void quit() { // pluginProxy.sendMessage("core:quit", null); // } // // public static void log(String text) { // getPluginProxy().log(text); // } // // public static void log(Throwable e) { // getPluginProxy().log(e); // } // // public static String getString(String text){ // return getPluginProxy().getString(text); // } // // public static synchronized PluginProperties getProperties() { // return getPluginProxy().getProperties(); // } // // public static void runLater(Runnable runnable) { // PlatformImpl.runLater(new Runnable() { // @Override // public void run() { // try { // runnable.run(); // } catch (Throwable e){ // getPluginProxy().log(e); // } // } // }); // } // // }
import info.deskchan.core.Path; import info.deskchan.gui_javafx.Main; import info.deskchan.gui_javafx.panes.sprite_drawers.SVGSprite; import info.deskchan.gui_javafx.panes.sprite_drawers.Sprite; import javafx.geometry.Point2D; import java.io.File; import java.io.IOException; import java.util.*; import java.util.concurrent.ThreadLocalRandom;
package info.deskchan.gui_javafx.skins; class ImageSetSkin implements Skin { private final String[][] replacing = { {"smile", "happy", "laugh", "love", "bounty"}, {"vulgar", "confident", "excitement", "grin"}, {"angry", "serious", "rage", "cry", "sad"}, {"sceptic", "facepalm", "despair", "disgusted"}, {"shy", "sorry", "tired"}, {"scared", "shocked", "tired", "surprised"}, {"love", "bounty"}, {"waiting", "normal"}, {"mad", "grin", "rage", "scared"} }; protected final Path path; private final String skinName; private final Map<String, List<File>> images = new HashMap<>(); private final Path propertiesPath; private final Properties properties = new Properties(); ImageSetSkin(Path path) { this.path = path; skinName = Skin.getSkinsPath().relativize(path);
// Path: src/main/java/info/deskchan/gui_javafx/Main.java // public class Main implements Plugin { // // private static Main instance; // private PluginProxyInterface pluginProxy; // private Semaphore appInitSem = new Semaphore(0); // // @Override // public boolean initialize(PluginProxyInterface pluginProxy) { // this.pluginProxy = pluginProxy; // instance = this; // // getProperties().load(); // // pluginProxy.setResourceBundle("info/deskchan/gui_javafx/strings"); // pluginProxy.setConfigField("name", pluginProxy.getString("plugin-name")); // pluginProxy.getProperties().putIfHasNot("use-tray", true); // pluginProxy.getProperties().putIfHasNot("skin.name", "illia"); // pluginProxy.getProperties().putIfHasNot("sprites-animation-delay", 20); // pluginProxy.getProperties().putIfHasNot("balloon.text-animation-delay", 50); // // new Thread(() -> { // try { // App.run(PluginManager.getInstance().getArgs()); // } catch (NoClassDefFoundError e){ // pluginProxy.log("WARNING! JavaFX is not installed. GUI plugin is now closing. Please, install JavaFX."); // appInitSem.release(); // instance = null; // } // }).start(); // try { // appInitSem.acquire(); // } catch (InterruptedException e) { // log(e); // } // // return instance != null; // } // // @Override // public void unload() { // synchronized (this) { // getProperties().save(); // } // // if (SystemUtils.IS_OS_WINDOWS) { // MouseEventNotificator.disableHooks(); // } // try { // Platform.exit(); // } catch (Exception e){ // log(e); // } // } // // public static Main getInstance() { // return instance; // } // // public static PluginProxyInterface getPluginProxy() { return instance.pluginProxy; } // // Semaphore getAppInitSem() { // return appInitSem; // } // // public void quit() { // pluginProxy.sendMessage("core:quit", null); // } // // public static void log(String text) { // getPluginProxy().log(text); // } // // public static void log(Throwable e) { // getPluginProxy().log(e); // } // // public static String getString(String text){ // return getPluginProxy().getString(text); // } // // public static synchronized PluginProperties getProperties() { // return getPluginProxy().getProperties(); // } // // public static void runLater(Runnable runnable) { // PlatformImpl.runLater(new Runnable() { // @Override // public void run() { // try { // runnable.run(); // } catch (Throwable e){ // getPluginProxy().log(e); // } // } // }); // } // // } // Path: src/main/java/info/deskchan/gui_javafx/skins/ImageSetSkin.java import info.deskchan.core.Path; import info.deskchan.gui_javafx.Main; import info.deskchan.gui_javafx.panes.sprite_drawers.SVGSprite; import info.deskchan.gui_javafx.panes.sprite_drawers.Sprite; import javafx.geometry.Point2D; import java.io.File; import java.io.IOException; import java.util.*; import java.util.concurrent.ThreadLocalRandom; package info.deskchan.gui_javafx.skins; class ImageSetSkin implements Skin { private final String[][] replacing = { {"smile", "happy", "laugh", "love", "bounty"}, {"vulgar", "confident", "excitement", "grin"}, {"angry", "serious", "rage", "cry", "sad"}, {"sceptic", "facepalm", "despair", "disgusted"}, {"shy", "sorry", "tired"}, {"scared", "shocked", "tired", "surprised"}, {"love", "bounty"}, {"waiting", "normal"}, {"mad", "grin", "rage", "scared"} }; protected final Path path; private final String skinName; private final Map<String, List<File>> images = new HashMap<>(); private final Path propertiesPath; private final Properties properties = new Properties(); ImageSetSkin(Path path) { this.path = path; skinName = Skin.getSkinsPath().relativize(path);
propertiesPath = Main.getPluginProxy().getDataDirPath().resolve(
DeskChan/DeskChan
src/main/java/info/deskchan/gui_javafx/panes/sprite_drawers/ImageSprite.java
// Path: src/main/java/info/deskchan/gui_javafx/Main.java // public class Main implements Plugin { // // private static Main instance; // private PluginProxyInterface pluginProxy; // private Semaphore appInitSem = new Semaphore(0); // // @Override // public boolean initialize(PluginProxyInterface pluginProxy) { // this.pluginProxy = pluginProxy; // instance = this; // // getProperties().load(); // // pluginProxy.setResourceBundle("info/deskchan/gui_javafx/strings"); // pluginProxy.setConfigField("name", pluginProxy.getString("plugin-name")); // pluginProxy.getProperties().putIfHasNot("use-tray", true); // pluginProxy.getProperties().putIfHasNot("skin.name", "illia"); // pluginProxy.getProperties().putIfHasNot("sprites-animation-delay", 20); // pluginProxy.getProperties().putIfHasNot("balloon.text-animation-delay", 50); // // new Thread(() -> { // try { // App.run(PluginManager.getInstance().getArgs()); // } catch (NoClassDefFoundError e){ // pluginProxy.log("WARNING! JavaFX is not installed. GUI plugin is now closing. Please, install JavaFX."); // appInitSem.release(); // instance = null; // } // }).start(); // try { // appInitSem.acquire(); // } catch (InterruptedException e) { // log(e); // } // // return instance != null; // } // // @Override // public void unload() { // synchronized (this) { // getProperties().save(); // } // // if (SystemUtils.IS_OS_WINDOWS) { // MouseEventNotificator.disableHooks(); // } // try { // Platform.exit(); // } catch (Exception e){ // log(e); // } // } // // public static Main getInstance() { // return instance; // } // // public static PluginProxyInterface getPluginProxy() { return instance.pluginProxy; } // // Semaphore getAppInitSem() { // return appInitSem; // } // // public void quit() { // pluginProxy.sendMessage("core:quit", null); // } // // public static void log(String text) { // getPluginProxy().log(text); // } // // public static void log(Throwable e) { // getPluginProxy().log(e); // } // // public static String getString(String text){ // return getPluginProxy().getString(text); // } // // public static synchronized PluginProperties getProperties() { // return getPluginProxy().getProperties(); // } // // public static void runLater(Runnable runnable) { // PlatformImpl.runLater(new Runnable() { // @Override // public void run() { // try { // runnable.run(); // } catch (Throwable e){ // getPluginProxy().log(e); // } // } // }); // } // // }
import info.deskchan.gui_javafx.Main; import javafx.geometry.Insets; import javafx.scene.Node; import javafx.scene.image.Image; import javafx.scene.image.ImageView; import org.w3c.dom.Document; import java.io.File; import java.io.FileInputStream;
package info.deskchan.gui_javafx.panes.sprite_drawers; public class ImageSprite extends Sprite { private String path = null; public static boolean canRead(File path){ try { Image image = new Image(new FileInputStream(path)); return image.getHeight() > 0 && image.getWidth() > 0; } catch (Exception e){
// Path: src/main/java/info/deskchan/gui_javafx/Main.java // public class Main implements Plugin { // // private static Main instance; // private PluginProxyInterface pluginProxy; // private Semaphore appInitSem = new Semaphore(0); // // @Override // public boolean initialize(PluginProxyInterface pluginProxy) { // this.pluginProxy = pluginProxy; // instance = this; // // getProperties().load(); // // pluginProxy.setResourceBundle("info/deskchan/gui_javafx/strings"); // pluginProxy.setConfigField("name", pluginProxy.getString("plugin-name")); // pluginProxy.getProperties().putIfHasNot("use-tray", true); // pluginProxy.getProperties().putIfHasNot("skin.name", "illia"); // pluginProxy.getProperties().putIfHasNot("sprites-animation-delay", 20); // pluginProxy.getProperties().putIfHasNot("balloon.text-animation-delay", 50); // // new Thread(() -> { // try { // App.run(PluginManager.getInstance().getArgs()); // } catch (NoClassDefFoundError e){ // pluginProxy.log("WARNING! JavaFX is not installed. GUI plugin is now closing. Please, install JavaFX."); // appInitSem.release(); // instance = null; // } // }).start(); // try { // appInitSem.acquire(); // } catch (InterruptedException e) { // log(e); // } // // return instance != null; // } // // @Override // public void unload() { // synchronized (this) { // getProperties().save(); // } // // if (SystemUtils.IS_OS_WINDOWS) { // MouseEventNotificator.disableHooks(); // } // try { // Platform.exit(); // } catch (Exception e){ // log(e); // } // } // // public static Main getInstance() { // return instance; // } // // public static PluginProxyInterface getPluginProxy() { return instance.pluginProxy; } // // Semaphore getAppInitSem() { // return appInitSem; // } // // public void quit() { // pluginProxy.sendMessage("core:quit", null); // } // // public static void log(String text) { // getPluginProxy().log(text); // } // // public static void log(Throwable e) { // getPluginProxy().log(e); // } // // public static String getString(String text){ // return getPluginProxy().getString(text); // } // // public static synchronized PluginProperties getProperties() { // return getPluginProxy().getProperties(); // } // // public static void runLater(Runnable runnable) { // PlatformImpl.runLater(new Runnable() { // @Override // public void run() { // try { // runnable.run(); // } catch (Throwable e){ // getPluginProxy().log(e); // } // } // }); // } // // } // Path: src/main/java/info/deskchan/gui_javafx/panes/sprite_drawers/ImageSprite.java import info.deskchan.gui_javafx.Main; import javafx.geometry.Insets; import javafx.scene.Node; import javafx.scene.image.Image; import javafx.scene.image.ImageView; import org.w3c.dom.Document; import java.io.File; import java.io.FileInputStream; package info.deskchan.gui_javafx.panes.sprite_drawers; public class ImageSprite extends Sprite { private String path = null; public static boolean canRead(File path){ try { Image image = new Image(new FileInputStream(path)); return image.getHeight() > 0 && image.getWidth() > 0; } catch (Exception e){
Main.log(e);
DeskChan/DeskChan
src/main/java/info/deskchan/gui_javafx/skins/ImageStackSetSkin.java
// Path: src/main/java/info/deskchan/gui_javafx/Main.java // public class Main implements Plugin { // // private static Main instance; // private PluginProxyInterface pluginProxy; // private Semaphore appInitSem = new Semaphore(0); // // @Override // public boolean initialize(PluginProxyInterface pluginProxy) { // this.pluginProxy = pluginProxy; // instance = this; // // getProperties().load(); // // pluginProxy.setResourceBundle("info/deskchan/gui_javafx/strings"); // pluginProxy.setConfigField("name", pluginProxy.getString("plugin-name")); // pluginProxy.getProperties().putIfHasNot("use-tray", true); // pluginProxy.getProperties().putIfHasNot("skin.name", "illia"); // pluginProxy.getProperties().putIfHasNot("sprites-animation-delay", 20); // pluginProxy.getProperties().putIfHasNot("balloon.text-animation-delay", 50); // // new Thread(() -> { // try { // App.run(PluginManager.getInstance().getArgs()); // } catch (NoClassDefFoundError e){ // pluginProxy.log("WARNING! JavaFX is not installed. GUI plugin is now closing. Please, install JavaFX."); // appInitSem.release(); // instance = null; // } // }).start(); // try { // appInitSem.acquire(); // } catch (InterruptedException e) { // log(e); // } // // return instance != null; // } // // @Override // public void unload() { // synchronized (this) { // getProperties().save(); // } // // if (SystemUtils.IS_OS_WINDOWS) { // MouseEventNotificator.disableHooks(); // } // try { // Platform.exit(); // } catch (Exception e){ // log(e); // } // } // // public static Main getInstance() { // return instance; // } // // public static PluginProxyInterface getPluginProxy() { return instance.pluginProxy; } // // Semaphore getAppInitSem() { // return appInitSem; // } // // public void quit() { // pluginProxy.sendMessage("core:quit", null); // } // // public static void log(String text) { // getPluginProxy().log(text); // } // // public static void log(Throwable e) { // getPluginProxy().log(e); // } // // public static String getString(String text){ // return getPluginProxy().getString(text); // } // // public static synchronized PluginProperties getProperties() { // return getPluginProxy().getProperties(); // } // // public static void runLater(Runnable runnable) { // PlatformImpl.runLater(new Runnable() { // @Override // public void run() { // try { // runnable.run(); // } catch (Throwable e){ // getPluginProxy().log(e); // } // } // }); // } // // }
import info.deskchan.core.Path; import info.deskchan.gui_javafx.Main; import info.deskchan.gui_javafx.panes.sprite_drawers.Sprite; import info.deskchan.gui_javafx.panes.sprite_drawers.StackSprite; import javafx.scene.Node; import java.io.File; import java.util.*; import java.util.concurrent.ThreadLocalRandom;
package info.deskchan.gui_javafx.skins; class ImageStackSetSkin extends ImageSetSkin { ImageStackSetSkin(Path path) { super(path); } @Override protected Sprite getFromFiles(List<File> list){ int i = ThreadLocalRandom.current().nextInt(0, list.size()); File file = list.get(i); try { List<Node> sprites = new LinkedList<>(); for (String image : new Path(file).readAllLines()){ try { Node node = Sprite.getSpriteFromFile(path.resolve(image)).getSpriteNode(); if (node != null) sprites.add(node); } catch (Exception e){
// Path: src/main/java/info/deskchan/gui_javafx/Main.java // public class Main implements Plugin { // // private static Main instance; // private PluginProxyInterface pluginProxy; // private Semaphore appInitSem = new Semaphore(0); // // @Override // public boolean initialize(PluginProxyInterface pluginProxy) { // this.pluginProxy = pluginProxy; // instance = this; // // getProperties().load(); // // pluginProxy.setResourceBundle("info/deskchan/gui_javafx/strings"); // pluginProxy.setConfigField("name", pluginProxy.getString("plugin-name")); // pluginProxy.getProperties().putIfHasNot("use-tray", true); // pluginProxy.getProperties().putIfHasNot("skin.name", "illia"); // pluginProxy.getProperties().putIfHasNot("sprites-animation-delay", 20); // pluginProxy.getProperties().putIfHasNot("balloon.text-animation-delay", 50); // // new Thread(() -> { // try { // App.run(PluginManager.getInstance().getArgs()); // } catch (NoClassDefFoundError e){ // pluginProxy.log("WARNING! JavaFX is not installed. GUI plugin is now closing. Please, install JavaFX."); // appInitSem.release(); // instance = null; // } // }).start(); // try { // appInitSem.acquire(); // } catch (InterruptedException e) { // log(e); // } // // return instance != null; // } // // @Override // public void unload() { // synchronized (this) { // getProperties().save(); // } // // if (SystemUtils.IS_OS_WINDOWS) { // MouseEventNotificator.disableHooks(); // } // try { // Platform.exit(); // } catch (Exception e){ // log(e); // } // } // // public static Main getInstance() { // return instance; // } // // public static PluginProxyInterface getPluginProxy() { return instance.pluginProxy; } // // Semaphore getAppInitSem() { // return appInitSem; // } // // public void quit() { // pluginProxy.sendMessage("core:quit", null); // } // // public static void log(String text) { // getPluginProxy().log(text); // } // // public static void log(Throwable e) { // getPluginProxy().log(e); // } // // public static String getString(String text){ // return getPluginProxy().getString(text); // } // // public static synchronized PluginProperties getProperties() { // return getPluginProxy().getProperties(); // } // // public static void runLater(Runnable runnable) { // PlatformImpl.runLater(new Runnable() { // @Override // public void run() { // try { // runnable.run(); // } catch (Throwable e){ // getPluginProxy().log(e); // } // } // }); // } // // } // Path: src/main/java/info/deskchan/gui_javafx/skins/ImageStackSetSkin.java import info.deskchan.core.Path; import info.deskchan.gui_javafx.Main; import info.deskchan.gui_javafx.panes.sprite_drawers.Sprite; import info.deskchan.gui_javafx.panes.sprite_drawers.StackSprite; import javafx.scene.Node; import java.io.File; import java.util.*; import java.util.concurrent.ThreadLocalRandom; package info.deskchan.gui_javafx.skins; class ImageStackSetSkin extends ImageSetSkin { ImageStackSetSkin(Path path) { super(path); } @Override protected Sprite getFromFiles(List<File> list){ int i = ThreadLocalRandom.current().nextInt(0, list.size()); File file = list.get(i); try { List<Node> sprites = new LinkedList<>(); for (String image : new Path(file).readAllLines()){ try { Node node = Sprite.getSpriteFromFile(path.resolve(image)).getSpriteNode(); if (node != null) sprites.add(node); } catch (Exception e){
Main.log(e.getMessage());
DeskChan/DeskChan
src/main/java/info/deskchan/gui_javafx/panes/Character.java
// Path: src/main/java/info/deskchan/gui_javafx/panes/sprite_drawers/ImageSprite.java // public class ImageSprite extends Sprite { // // private String path = null; // // public static boolean canRead(File path){ // try { // Image image = new Image(new FileInputStream(path)); // return image.getHeight() > 0 && image.getWidth() > 0; // } catch (Exception e){ // Main.log(e); // return false; // } // } // // public static ImageSprite create(File path) throws Exception { // Image image = new Image(new FileInputStream(path)); // // Insets margin; // String textStyle; // try { // Document document = getDocument(path + ".config"); // margin = getMarginFromFile(document); // textStyle = getTextStyle(document); // } catch (Exception e){ // margin = getMarginFromFile(null); // textStyle = getTextStyle(null); // } // // ImageView view = new ImageView(); // view.setImage(image); // // return new ImageSprite(view, textStyle, margin, path); // } // // private ImageSprite(Node sprite, String contentStyle, Insets margin, File path) { // super(sprite, contentStyle, margin); // this.path = path != null ? path.toString() : null; // } // // public double getOriginWidth(){ // return toImageView().getImage() != null ? toImageView().getImage().getWidth() : 0; // } // // public double getOriginHeight(){ // return toImageView().getImage() != null ? toImageView().getImage().getHeight() : 0; // } // // public double getFitWidth() { return toImageView().getFitWidth(); } // // public double getFitHeight(){ return toImageView().getFitHeight(); } // // public void setFitWidth(double width) { toImageView().setFitWidth(width); } // // public void setFitHeight(double height){ toImageView().setFitHeight(height); } // // public ImageView toImageView(){ return (ImageView) sprite; } // // public String getSpritePath(){ return path; } // // }
import info.deskchan.gui_javafx.*; import info.deskchan.gui_javafx.panes.sprite_drawers.AnimatedSprite; import info.deskchan.gui_javafx.panes.sprite_drawers.ImageSprite; import info.deskchan.gui_javafx.panes.sprite_drawers.Sprite; import info.deskchan.gui_javafx.skins.Skin; import javafx.geometry.Point2D; import javafx.geometry.Rectangle2D; import javafx.scene.control.ContextMenu; import javafx.scene.effect.DropShadow; import javafx.scene.effect.Light; import javafx.scene.effect.Lighting; import javafx.scene.image.Image; import javafx.scene.image.ImageView; import javafx.scene.image.PixelReader; import javafx.scene.input.MouseButton; import javafx.scene.input.MouseEvent; import javafx.scene.paint.Color; import javafx.stage.Screen; import java.io.File; import java.util.*;
boolean enabled = Main.getProperties().getBoolean("character.enable_context_menu", true); ContextMenu contextMenu = Menu.getInstance().getContextMenu(); // We need to hide menu manually in both cases to avoid showing the menu with incorrect width. contextMenu.hide(); if (enabled && event.getButton() == MouseButton.SECONDARY && event.isStillSincePress()) { contextMenu.show(this, event.getScreenX(), event.getScreenY()); } }); MouseEventNotificator mouseEventNotificator = new MouseEventNotificator(this, "character"); mouseEventNotificator .setOnClickListener() .setOnMovedListener() .setOnScrollListener(event -> { Point2D characterPosition = getPosition(); double charX = characterPosition.getX(); double charY = characterPosition.getY(); double x = event.getX(); double y = event.getY(); double x0 = x - charX; double y0 = y - charY; // just in case if (scaleFactor == 0) { Main.log("The scale factor of the image is equal to zero!"); return false; } x0 /= scaleFactor; y0 /= scaleFactor;
// Path: src/main/java/info/deskchan/gui_javafx/panes/sprite_drawers/ImageSprite.java // public class ImageSprite extends Sprite { // // private String path = null; // // public static boolean canRead(File path){ // try { // Image image = new Image(new FileInputStream(path)); // return image.getHeight() > 0 && image.getWidth() > 0; // } catch (Exception e){ // Main.log(e); // return false; // } // } // // public static ImageSprite create(File path) throws Exception { // Image image = new Image(new FileInputStream(path)); // // Insets margin; // String textStyle; // try { // Document document = getDocument(path + ".config"); // margin = getMarginFromFile(document); // textStyle = getTextStyle(document); // } catch (Exception e){ // margin = getMarginFromFile(null); // textStyle = getTextStyle(null); // } // // ImageView view = new ImageView(); // view.setImage(image); // // return new ImageSprite(view, textStyle, margin, path); // } // // private ImageSprite(Node sprite, String contentStyle, Insets margin, File path) { // super(sprite, contentStyle, margin); // this.path = path != null ? path.toString() : null; // } // // public double getOriginWidth(){ // return toImageView().getImage() != null ? toImageView().getImage().getWidth() : 0; // } // // public double getOriginHeight(){ // return toImageView().getImage() != null ? toImageView().getImage().getHeight() : 0; // } // // public double getFitWidth() { return toImageView().getFitWidth(); } // // public double getFitHeight(){ return toImageView().getFitHeight(); } // // public void setFitWidth(double width) { toImageView().setFitWidth(width); } // // public void setFitHeight(double height){ toImageView().setFitHeight(height); } // // public ImageView toImageView(){ return (ImageView) sprite; } // // public String getSpritePath(){ return path; } // // } // Path: src/main/java/info/deskchan/gui_javafx/panes/Character.java import info.deskchan.gui_javafx.*; import info.deskchan.gui_javafx.panes.sprite_drawers.AnimatedSprite; import info.deskchan.gui_javafx.panes.sprite_drawers.ImageSprite; import info.deskchan.gui_javafx.panes.sprite_drawers.Sprite; import info.deskchan.gui_javafx.skins.Skin; import javafx.geometry.Point2D; import javafx.geometry.Rectangle2D; import javafx.scene.control.ContextMenu; import javafx.scene.effect.DropShadow; import javafx.scene.effect.Light; import javafx.scene.effect.Lighting; import javafx.scene.image.Image; import javafx.scene.image.ImageView; import javafx.scene.image.PixelReader; import javafx.scene.input.MouseButton; import javafx.scene.input.MouseEvent; import javafx.scene.paint.Color; import javafx.stage.Screen; import java.io.File; import java.util.*; boolean enabled = Main.getProperties().getBoolean("character.enable_context_menu", true); ContextMenu contextMenu = Menu.getInstance().getContextMenu(); // We need to hide menu manually in both cases to avoid showing the menu with incorrect width. contextMenu.hide(); if (enabled && event.getButton() == MouseButton.SECONDARY && event.isStillSincePress()) { contextMenu.show(this, event.getScreenX(), event.getScreenY()); } }); MouseEventNotificator mouseEventNotificator = new MouseEventNotificator(this, "character"); mouseEventNotificator .setOnClickListener() .setOnMovedListener() .setOnScrollListener(event -> { Point2D characterPosition = getPosition(); double charX = characterPosition.getX(); double charY = characterPosition.getY(); double x = event.getX(); double y = event.getY(); double x0 = x - charX; double y0 = y - charY; // just in case if (scaleFactor == 0) { Main.log("The scale factor of the image is equal to zero!"); return false; } x0 /= scaleFactor; y0 /= scaleFactor;
if (!(sprite.getCurrentSprite() instanceof ImageSprite))
DeskChan/DeskChan
src/main/java/info/deskchan/groovy_support/Scenario.java
// Path: src/main/java/info/deskchan/core/ResponseListener.java // public interface ResponseListener { // // void handle(String sender, Object data); // // }
import groovy.lang.Closure; import groovy.lang.Script; import info.deskchan.core.Path; import info.deskchan.core.PluginProperties; import info.deskchan.core.PluginProxyInterface; import info.deskchan.core.ResponseListener; import java.util.*; import java.util.concurrent.atomic.AtomicReference; import java.util.function.Function;
package info.deskchan.groovy_support; public abstract class Scenario extends Script{ /** Object containing last user input. * It has complex map structure, so we store it here instead of giving it right to user. */ private Answer answer; /** Default help message in answer dialog. */ private static final String DEFAULT_HELP = ScenarioPlugin.pluginProxy.getString("write-anything"); /** Variable containing is current thread was interrupted. **/ private volatile boolean interrupted = false; /** Thread locking object. **/ private final Locker lock = new Locker(); private PluginProxyInterface pluginProxy = null; private Object data = null; /** Get data passed by owner of plugin. **/ public Object getPassedData(){ return data; } /** Sets Plugin Proxy for this scenario. Should be called only from scenario initializer. **/ protected void initialize(PluginProxyInterface proxy, Object data){ if (pluginProxy != null) throw new RuntimeException("This method should be called only once and from scenario initializer, it's not accessable anymore."); this.pluginProxy = proxy; this.data = data; } // Standard plugin API protected void sendMessage(String tag) { pluginProxy.sendMessage(tag, null); } protected void sendMessage(String tag, Object data) { pluginProxy.sendMessage(tag, data); } protected String getString(String key){ return pluginProxy.getString(key); } protected Path getDataDirPath() { return pluginProxy.getDataDirPath(); } protected Path getPluginDirPath() { return pluginProxy.getPluginDirPath(); } protected Path getRootDirPath() { return pluginProxy.getRootDirPath(); } protected Path getAssetsDirPath() { return pluginProxy.getAssetsDirPath(); } protected void log(Object text) { pluginProxy.log(text.toString()); } protected void log(Throwable e) { pluginProxy.log(e); } protected PluginProperties getProperties() { return pluginProxy.getProperties(); } protected void alert(String text) { pluginProxy.sendMessage("DeskChan:show-technical", new HashMap(){{ put("text", text); }}); } protected void alert(String name, String text) { pluginProxy.sendMessage("DeskChan:show-technical", new HashMap(){{ put("name", name); put("text", text); put("priority", messagePriority); }}); } protected void say(String text){ pluginProxy.sendMessage("DeskChan:request-say", new HashMap(){{ put("text", text); put("characterImage", currentSprite); put("priority", messagePriority); put("skippable", false); }}, (sender, data) -> { pluginProxy.sendMessage("DeskChan:say", data, (sender1, data1) -> { lock.unlock(); }); }); lock.lock(); } protected void requestPhrase(String intent){ pluginProxy.sendMessage("DeskChan:request-say", new HashMap(){{ put("intent", intent); put("priority", messagePriority); put("skippable", false); }}); } /** Current sprite forced by this scenario. **/ private String currentSprite = "normal"; protected void sprite(String text){ currentSprite = text; pluginProxy.sendMessage("gui:set-image", text); } /** Priority of all messages sent by this scenario. All messages with lower priority will be skipped. **/ private int messagePriority = 2500; protected int setMessagePriority(int val){ return (messagePriority = val); } public int getMessagePriority(){ return messagePriority; }
// Path: src/main/java/info/deskchan/core/ResponseListener.java // public interface ResponseListener { // // void handle(String sender, Object data); // // } // Path: src/main/java/info/deskchan/groovy_support/Scenario.java import groovy.lang.Closure; import groovy.lang.Script; import info.deskchan.core.Path; import info.deskchan.core.PluginProperties; import info.deskchan.core.PluginProxyInterface; import info.deskchan.core.ResponseListener; import java.util.*; import java.util.concurrent.atomic.AtomicReference; import java.util.function.Function; package info.deskchan.groovy_support; public abstract class Scenario extends Script{ /** Object containing last user input. * It has complex map structure, so we store it here instead of giving it right to user. */ private Answer answer; /** Default help message in answer dialog. */ private static final String DEFAULT_HELP = ScenarioPlugin.pluginProxy.getString("write-anything"); /** Variable containing is current thread was interrupted. **/ private volatile boolean interrupted = false; /** Thread locking object. **/ private final Locker lock = new Locker(); private PluginProxyInterface pluginProxy = null; private Object data = null; /** Get data passed by owner of plugin. **/ public Object getPassedData(){ return data; } /** Sets Plugin Proxy for this scenario. Should be called only from scenario initializer. **/ protected void initialize(PluginProxyInterface proxy, Object data){ if (pluginProxy != null) throw new RuntimeException("This method should be called only once and from scenario initializer, it's not accessable anymore."); this.pluginProxy = proxy; this.data = data; } // Standard plugin API protected void sendMessage(String tag) { pluginProxy.sendMessage(tag, null); } protected void sendMessage(String tag, Object data) { pluginProxy.sendMessage(tag, data); } protected String getString(String key){ return pluginProxy.getString(key); } protected Path getDataDirPath() { return pluginProxy.getDataDirPath(); } protected Path getPluginDirPath() { return pluginProxy.getPluginDirPath(); } protected Path getRootDirPath() { return pluginProxy.getRootDirPath(); } protected Path getAssetsDirPath() { return pluginProxy.getAssetsDirPath(); } protected void log(Object text) { pluginProxy.log(text.toString()); } protected void log(Throwable e) { pluginProxy.log(e); } protected PluginProperties getProperties() { return pluginProxy.getProperties(); } protected void alert(String text) { pluginProxy.sendMessage("DeskChan:show-technical", new HashMap(){{ put("text", text); }}); } protected void alert(String name, String text) { pluginProxy.sendMessage("DeskChan:show-technical", new HashMap(){{ put("name", name); put("text", text); put("priority", messagePriority); }}); } protected void say(String text){ pluginProxy.sendMessage("DeskChan:request-say", new HashMap(){{ put("text", text); put("characterImage", currentSprite); put("priority", messagePriority); put("skippable", false); }}, (sender, data) -> { pluginProxy.sendMessage("DeskChan:say", data, (sender1, data1) -> { lock.unlock(); }); }); lock.lock(); } protected void requestPhrase(String intent){ pluginProxy.sendMessage("DeskChan:request-say", new HashMap(){{ put("intent", intent); put("priority", messagePriority); put("skippable", false); }}); } /** Current sprite forced by this scenario. **/ private String currentSprite = "normal"; protected void sprite(String text){ currentSprite = text; pluginProxy.sendMessage("gui:set-image", text); } /** Priority of all messages sent by this scenario. All messages with lower priority will be skipped. **/ private int messagePriority = 2500; protected int setMessagePriority(int val){ return (messagePriority = val); } public int getMessagePriority(){ return messagePriority; }
public ResponseListener interruptListener = new ResponseListener() {
alexbirkett/android-cassowary-layout
library/src/main/java/no/agens/cassowarylayout/CassowaryLayout.java
// Path: library/src/main/java/no/agens/cassowarylayout/util/MeasureSpecUtils.java // public class MeasureSpecUtils { // public static String getModeAsString(int modeOrSpec) { // String modeAsString; // int mode = View.MeasureSpec.getMode(modeOrSpec); // if (mode == View.MeasureSpec.EXACTLY) { // modeAsString = "EXACTLY"; // } else if (mode == View.MeasureSpec.AT_MOST) { // modeAsString = "AT_MOST"; // } else if (mode == View.MeasureSpec.UNSPECIFIED) { // modeAsString = "UNSPECIFIED"; // } else { // modeAsString = "unknown mode " + modeOrSpec; // } // // return modeAsString; // } // } // // Path: library/src/main/java/no/agens/cassowarylayout/util/TimerUtil.java // public class TimerUtil { // public static long since(long since) { // return (System.nanoTime() - since) / 1000000; // } // }
import java.util.Map; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import no.agens.cassowarylayout.util.MeasureSpecUtils; import no.agens.cassowarylayout.util.TimerUtil; import android.content.Context; import android.content.res.TypedArray; import android.os.Handler; import android.os.Looper; import android.util.AttributeSet; import android.util.Log; import android.view.View; import android.view.ViewGroup; import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator;
this.aspectRatioWidthFactor = aspectRatioWidthFactor; } public float getAspectRatioHeightFactor() { return aspectRatioHeightFactor; } public void setAspectRatioHeightFactor(float aspectRatioHeightFactor) { this.aspectRatioHeightFactor = aspectRatioHeightFactor; } public void setChildPositionsFromCassowaryModel() { long timeBeforeSolve = System.nanoTime(); int count = getChildCount(); for (int i = 0; i < count; i++) { View child = getChildAt(i); if (child.getVisibility() != GONE) { int childId = child.getId(); Node node = getNodeById(childId); int x = (int) node.getLeft().value() + getPaddingLeft(); int y = (int) node.getTop().value() + getPaddingTop(); child.setX(x); child.setY(y); } }
// Path: library/src/main/java/no/agens/cassowarylayout/util/MeasureSpecUtils.java // public class MeasureSpecUtils { // public static String getModeAsString(int modeOrSpec) { // String modeAsString; // int mode = View.MeasureSpec.getMode(modeOrSpec); // if (mode == View.MeasureSpec.EXACTLY) { // modeAsString = "EXACTLY"; // } else if (mode == View.MeasureSpec.AT_MOST) { // modeAsString = "AT_MOST"; // } else if (mode == View.MeasureSpec.UNSPECIFIED) { // modeAsString = "UNSPECIFIED"; // } else { // modeAsString = "unknown mode " + modeOrSpec; // } // // return modeAsString; // } // } // // Path: library/src/main/java/no/agens/cassowarylayout/util/TimerUtil.java // public class TimerUtil { // public static long since(long since) { // return (System.nanoTime() - since) / 1000000; // } // } // Path: library/src/main/java/no/agens/cassowarylayout/CassowaryLayout.java import java.util.Map; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import no.agens.cassowarylayout.util.MeasureSpecUtils; import no.agens.cassowarylayout.util.TimerUtil; import android.content.Context; import android.content.res.TypedArray; import android.os.Handler; import android.os.Looper; import android.util.AttributeSet; import android.util.Log; import android.view.View; import android.view.ViewGroup; import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; this.aspectRatioWidthFactor = aspectRatioWidthFactor; } public float getAspectRatioHeightFactor() { return aspectRatioHeightFactor; } public void setAspectRatioHeightFactor(float aspectRatioHeightFactor) { this.aspectRatioHeightFactor = aspectRatioHeightFactor; } public void setChildPositionsFromCassowaryModel() { long timeBeforeSolve = System.nanoTime(); int count = getChildCount(); for (int i = 0; i < count; i++) { View child = getChildAt(i); if (child.getVisibility() != GONE) { int childId = child.getId(); Node node = getNodeById(childId); int x = (int) node.getLeft().value() + getPaddingLeft(); int y = (int) node.getTop().value() + getPaddingTop(); child.setX(x); child.setY(y); } }
log("setChildPositionsFromCassowaryModel - took " + TimerUtil.since(timeBeforeSolve));