From c0558964aa430f63f96eaabb6a75e18d1ca9795d Mon Sep 17 00:00:00 2001 From: Szymon Uglis Date: Fri, 6 Jul 2018 17:10:00 +0200 Subject: [PATCH] Increment version to 0.21.2. Implemented hashCode, added @overrides and fixed type error for delay method in Command class --- CHANGELOG.md | 11 ++++++++++- analysis_options.yaml | 1 - lib/src/commands/Command.dart | 5 ++++- lib/src/objects/Snowflake.dart | 15 +++++++++++++++ lib/src/objects/message/Emoji.dart | 2 ++ lib/src/objects/message/GuildEmoji.dart | 6 ++++++ lib/src/objects/message/UnicodeEmoji.dart | 9 ++++++++- pubspec.yaml | 2 +- 8 files changed, 46 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7a08620a6..45b33b7fc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,13 @@ -## [0.21.1](https://github.com/l7ssha/nyxx/compare/0.20.0...0.21.1) +## [0.21.2](https://github.com/l7ssha/nyxx/compare/0.21.1...0.21.2) +_Fri 06.07.2018_ + +- **Bug fixes** + * Added overrides + * Implemented hashCode + * Fixed return type for `delay()` in Command class + + +## [0.21.1](https://github.com/l7ssha/nyxx/compare/0.21.0...0.21.1) _Fri 06.07.2018_ - **Bug fixes** diff --git a/analysis_options.yaml b/analysis_options.yaml index 03152a3ec..9f94baca0 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -30,7 +30,6 @@ linter: - package_api_docs - package_prefixed_library_names - prefer_is_not_empty - - public_member_api_docs - slash_for_doc_comments - sort_constructors_first - sort_unnamed_constructors_first diff --git a/lib/src/commands/Command.dart b/lib/src/commands/Command.dart index 9d006565a..17a5f6d86 100644 --- a/lib/src/commands/Command.dart +++ b/lib/src/commands/Command.dart @@ -57,6 +57,9 @@ abstract class Command { return true; }).timeout(const Duration(seconds: 30), - onTimeout: () => print("Timed out")); + onTimeout: () { + print("Timed out"); + return null; + }); } } diff --git a/lib/src/objects/Snowflake.dart b/lib/src/objects/Snowflake.dart index 72962c0a1..5428dd34c 100644 --- a/lib/src/objects/Snowflake.dart +++ b/lib/src/objects/Snowflake.dart @@ -55,8 +55,10 @@ class Snowflake { return (-1 << lb) ^ (-1 << rb); } + @override String toString() => id; + @override bool operator ==(other) { if (other is Snowflake) return other.id == id; @@ -64,4 +66,17 @@ class Snowflake { return false; } + + @override + int get hashCode { + int result = 17; + result = 37 * result + id.hashCode; + result = 37 * result + timestamp.hashCode; + result = 37 * result + timestamp.hashCode; + result = 37 * result + workerId.hashCode; + result = 37 * result + processId.hashCode; + result = 37 * result + sequence.hashCode; + + return result; + } } diff --git a/lib/src/objects/message/Emoji.dart b/lib/src/objects/message/Emoji.dart index fdf6ffdd2..afa198f14 100644 --- a/lib/src/objects/message/Emoji.dart +++ b/lib/src/objects/message/Emoji.dart @@ -10,4 +10,6 @@ abstract class Emoji { String encode(); bool operator ==(other) => other is Emoji && other.name == this.name; + + int get hashCode => 17 * 37 + name.hashCode; } diff --git a/lib/src/objects/message/GuildEmoji.dart b/lib/src/objects/message/GuildEmoji.dart index 175142eba..588ef719a 100644 --- a/lib/src/objects/message/GuildEmoji.dart +++ b/lib/src/objects/message/GuildEmoji.dart @@ -15,6 +15,7 @@ class GuildEmoji extends Emoji { Snowflake id; /// Name of emoji + @override String name; /// Roles this emoji is whitelisted to @@ -52,7 +53,12 @@ class GuildEmoji extends Emoji { String encode() => "$name:$id"; /// Returns encoded string ready to send via message. + @override String toString() => encode(); + @override bool operator ==(other) => other is Emoji && other.name == this.name; + + @override + int get hashCode => ((super.hashCode * 37 + id.hashCode) * 37 + name.hashCode); } diff --git a/lib/src/objects/message/UnicodeEmoji.dart b/lib/src/objects/message/UnicodeEmoji.dart index 612c6aee9..5c2f46aa0 100644 --- a/lib/src/objects/message/UnicodeEmoji.dart +++ b/lib/src/objects/message/UnicodeEmoji.dart @@ -9,9 +9,16 @@ class UnicodeEmoji extends Emoji { UnicodeEmoji._partial(this.code) : super(""); /// Encodes Emoji so that can be used in messages. + @override String encode() => new String.fromCharCode(int.parse(code, radix: 16)); /// Returns encoded string ready to send via message. + @override String toString() => encode(); + + @override bool operator ==(other) => other is Emoji && other.name == this.name; -} + + @override + int get hashCode => super.hashCode * 37 + code.hashCode; +} \ No newline at end of file diff --git a/pubspec.yaml b/pubspec.yaml index 46addb410..9a61b06d7 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,5 +1,5 @@ name: nyxx -version: 0.21.1 +version: 0.21.2 description: A Discord library for Dart. For of hackzzila's nyx. authors: - Szymon 'l7ssha' Uglis