Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
M
Mirai
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
MyCard
Mirai
Commits
db77227d
Commit
db77227d
authored
Oct 03, 2019
by
Him188
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rewrite in kotlin
parent
1e3db169
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
13 additions
and
366 deletions
+13
-366
mirai-core/src/jvmMain/kotlin/net/mamoe/mirai/network/protocol/tim/handler/PacketHandler.kt
...mamoe/mirai/network/protocol/tim/handler/PacketHandler.kt
+1
-2
mirai-core/src/jvmMain/kotlin/net/mamoe/mirai/network/protocol/tim/packet/PacketId.kt
...n/net/mamoe/mirai/network/protocol/tim/packet/PacketId.kt
+9
-14
mirai-core/src/jvmMain/kotlin/net/mamoe/mirai/utils/ContactList.kt
...e/src/jvmMain/kotlin/net/mamoe/mirai/utils/ContactList.kt
+1
-1
mirai-core/src/jvmMain/kotlin/net/mamoe/mirai/utils/MiraiSynchronizedLinkedHashMap.java
...net/mamoe/mirai/utils/MiraiSynchronizedLinkedHashMap.java
+0
-158
mirai-core/src/jvmMain/kotlin/net/mamoe/mirai/utils/MiraiSynchronizedLinkedList.java
...in/net/mamoe/mirai/utils/MiraiSynchronizedLinkedList.java
+0
-187
mirai-core/src/jvmMain/kotlin/net/mamoe/mirai/utils/config/MiraiConfig.kt
...vmMain/kotlin/net/mamoe/mirai/utils/config/MiraiConfig.kt
+1
-1
mirai-core/src/jvmMain/kotlin/net/mamoe/mirai/utils/config/MiraiConfigSection.java
...tlin/net/mamoe/mirai/utils/config/MiraiConfigSection.java
+1
-3
No files found.
mirai-core/src/jvmMain/kotlin/net/mamoe/mirai/network/protocol/tim/handler/PacketHandler.kt
View file @
db77227d
...
...
@@ -2,7 +2,6 @@ package net.mamoe.mirai.network.protocol.tim.handler
import
net.mamoe.mirai.network.LoginSession
import
net.mamoe.mirai.network.protocol.tim.packet.ServerPacket
import
net.mamoe.mirai.utils.MiraiSynchronizedLinkedList
import
java.io.Closeable
/**
...
...
@@ -27,7 +26,7 @@ fun PacketHandler.asNode(): PacketHandlerNode<PacketHandler> {
return
PacketHandlerNode
(
this
.
javaClass
,
this
)
}
class
PacketHandlerList
:
M
iraiSynchronizedLinkedList
<
PacketHandlerNode
<
*
>>
()
{
class
PacketHandlerList
:
M
utableList
<
PacketHandlerNode
<
*
>>
by
mutableListOf
()
{
fun
<
T
:
PacketHandler
>
get
(
clazz
:
Class
<
T
>):
T
{
this
.
forEach
{
...
...
mirai-core/src/jvmMain/kotlin/net/mamoe/mirai/network/protocol/tim/packet/PacketId.kt
View file @
db77227d
package
net.mamoe.mirai.network.protocol.tim.packet;
import
java.lang.annotation.ElementType;
import
java.lang.annotation.Retention;
import
java.lang.annotation.RetentionPolicy;
import
java.lang.annotation.Target;
package
net.mamoe.mirai.network.protocol.tim.packet
/**
* @author Him188moe
*/
@Retention
(
RetentionPolicy
.
RUNTIME
)
@Target
(
ElementType
.
TYP
E
)
public
@
interface
PacketId
{
/**
* 获取
用于识别的包 ID
*/
String
value
();
}
@Retention
(
AnnotationRetention
.
RUNTIME
)
@Target
(
AnnotationTarget
.
CLASS
,
AnnotationTarget
.
FIL
E
)
annotation
class
PacketId
(
/**
*
用于识别的包 ID
*/
val
value
:
String
)
mirai-core/src/jvmMain/kotlin/net/mamoe/mirai/utils/ContactList.kt
View file @
db77227d
...
...
@@ -5,4 +5,4 @@ import net.mamoe.mirai.contact.Contact
/**
* @author Him188moe
*/
class
ContactList
<
C
:
Contact
>
:
MiraiSynchronizedLinkedHashMap
<
Long
,
C
>()
\ No newline at end of file
class
ContactList
<
C
:
Contact
>
:
MutableMap
<
Long
,
C
>
by
mutableMapOf
()
\ No newline at end of file
mirai-core/src/jvmMain/kotlin/net/mamoe/mirai/utils/MiraiSynchronizedLinkedHashMap.java
deleted
100644 → 0
View file @
1e3db169
package
net.mamoe.mirai.utils
;
import
java.util.*
;
import
java.util.function.BiConsumer
;
import
java.util.function.BiFunction
;
import
java.util.function.Function
;
/**
* 实现了可以直接被继承的 SynchronizedLinkedListMap<K,V>
*
* @param <K> the type of key
* @param <V> the type of value
*
* @author NaturalHG
*/
public
class
MiraiSynchronizedLinkedHashMap
<
K
,
V
>
extends
AbstractMap
<
K
,
V
>
{
public
MiraiSynchronizedLinkedHashMap
()
{
this
.
sortedMap
=
Collections
.
synchronizedMap
(
new
LinkedHashMap
<>());
}
protected
final
Map
<
K
,
V
>
sortedMap
;
public
MiraiSynchronizedLinkedHashMap
(
LinkedHashMap
<
K
,
V
>
map
)
{
this
.
sortedMap
=
Collections
.
synchronizedMap
(
map
);
}
@Override
public
int
size
()
{
return
sortedMap
.
size
();
}
@Override
public
boolean
isEmpty
()
{
return
sortedMap
.
isEmpty
();
}
@Override
public
boolean
containsKey
(
Object
key
)
{
return
sortedMap
.
containsKey
(
key
);
}
@Override
public
boolean
containsValue
(
Object
value
)
{
return
sortedMap
.
containsValue
(
value
);
}
@Override
public
V
get
(
Object
key
)
{
return
sortedMap
.
get
(
key
);
}
@Override
public
V
put
(
K
key
,
V
value
)
{
return
sortedMap
.
put
(
key
,
value
);
}
@Override
public
V
remove
(
Object
key
)
{
return
sortedMap
.
remove
(
key
);
}
@Override
public
void
putAll
(
Map
<?
extends
K
,
?
extends
V
>
m
)
{
sortedMap
.
putAll
(
m
);
}
@Override
public
void
clear
()
{
sortedMap
.
clear
();
}
@Override
public
Set
<
K
>
keySet
()
{
return
sortedMap
.
keySet
();
}
@Override
public
Collection
<
V
>
values
()
{
return
sortedMap
.
values
();
}
@Override
public
Set
<
Entry
<
K
,
V
>>
entrySet
()
{
return
sortedMap
.
entrySet
();
}
@Override
public
String
toString
()
{
return
this
.
sortedMap
.
toString
();
}
@Override
public
V
getOrDefault
(
Object
key
,
V
defaultValue
)
{
return
this
.
sortedMap
.
getOrDefault
(
key
,
defaultValue
);
}
@Override
public
void
forEach
(
BiConsumer
<?
super
K
,
?
super
V
>
action
)
{
this
.
sortedMap
.
forEach
(
action
);
}
@Override
public
boolean
replace
(
K
key
,
V
oldValue
,
V
newValue
)
{
return
this
.
sortedMap
.
replace
(
key
,
oldValue
,
newValue
);
}
@Override
public
V
replace
(
K
key
,
V
value
)
{
return
this
.
sortedMap
.
replace
(
key
,
value
);
}
@Override
public
void
replaceAll
(
BiFunction
<?
super
K
,
?
super
V
,
?
extends
V
>
function
)
{
this
.
sortedMap
.
replaceAll
(
function
);
}
@Override
public
V
compute
(
K
key
,
BiFunction
<?
super
K
,
?
super
V
,
?
extends
V
>
remappingFunction
)
{
return
this
.
sortedMap
.
compute
(
key
,
remappingFunction
);
}
@Override
public
V
computeIfAbsent
(
K
key
,
Function
<?
super
K
,
?
extends
V
>
mappingFunction
)
{
return
this
.
sortedMap
.
computeIfAbsent
(
key
,
mappingFunction
);
}
@Override
public
V
computeIfPresent
(
K
key
,
BiFunction
<?
super
K
,
?
super
V
,
?
extends
V
>
remappingFunction
)
{
return
this
.
sortedMap
.
computeIfPresent
(
key
,
remappingFunction
);
}
@Override
public
int
hashCode
()
{
return
this
.
sortedMap
.
hashCode
();
}
@Override
public
V
putIfAbsent
(
K
key
,
V
value
)
{
return
this
.
sortedMap
.
putIfAbsent
(
key
,
value
);
}
@Override
public
V
merge
(
K
key
,
V
value
,
BiFunction
<?
super
V
,
?
super
V
,
?
extends
V
>
remappingFunction
)
{
return
this
.
sortedMap
.
merge
(
key
,
value
,
remappingFunction
);
}
public
boolean
equals
(
MiraiSynchronizedLinkedHashMap
o
)
{
return
this
.
sortedMap
.
equals
(
o
.
sortedMap
);
}
@Override
public
boolean
equals
(
Object
o
)
{
return
o
instanceof
MiraiSynchronizedLinkedHashMap
?
this
.
equals
((
MiraiSynchronizedLinkedHashMap
)
o
)
:
super
.
equals
(
o
);
}
}
mirai-core/src/jvmMain/kotlin/net/mamoe/mirai/utils/MiraiSynchronizedLinkedList.java
deleted
100644 → 0
View file @
1e3db169
package
net.mamoe.mirai.utils
;
import
java.util.*
;
import
java.util.function.Consumer
;
import
java.util.function.IntFunction
;
import
java.util.function.Predicate
;
import
java.util.function.UnaryOperator
;
import
java.util.stream.Stream
;
/**
* @author Him188moe
*/
public
class
MiraiSynchronizedLinkedList
<
E
>
extends
AbstractList
<
E
>
{
@SuppressWarnings
(
"WeakerAccess"
)
protected
final
List
<
E
>
syncList
;
public
MiraiSynchronizedLinkedList
()
{
this
.
syncList
=
Collections
.
synchronizedList
(
new
LinkedList
<>());
}
public
MiraiSynchronizedLinkedList
(
Collection
<
E
>
collection
)
{
this
.
syncList
=
Collections
.
synchronizedList
(
new
LinkedList
<>(
collection
));
}
@Override
public
E
get
(
int
index
)
{
return
this
.
syncList
.
get
(
index
);
}
@Override
public
void
forEach
(
Consumer
<?
super
E
>
action
)
{
this
.
syncList
.
forEach
(
action
);
}
@Override
public
Spliterator
<
E
>
spliterator
()
{
return
this
.
syncList
.
spliterator
();
}
@Override
public
Stream
<
E
>
stream
()
{
return
this
.
syncList
.
stream
();
}
@Override
public
Stream
<
E
>
parallelStream
()
{
return
this
.
syncList
.
parallelStream
();
}
@Override
public
int
size
()
{
return
this
.
syncList
.
size
();
}
@SuppressWarnings
(
"SuspiciousToArrayCall"
)
@Override
public
<
T
>
T
[]
toArray
(
IntFunction
<
T
[]>
generator
)
{
return
this
.
syncList
.
toArray
(
generator
);
}
@Override
public
boolean
removeIf
(
Predicate
<?
super
E
>
filter
)
{
return
this
.
syncList
.
removeIf
(
filter
);
}
@Override
public
void
replaceAll
(
UnaryOperator
<
E
>
operator
)
{
this
.
syncList
.
replaceAll
(
operator
);
}
@Override
public
void
sort
(
Comparator
<?
super
E
>
c
)
{
this
.
syncList
.
sort
(
c
);
}
@Override
public
boolean
add
(
E
e
)
{
return
this
.
syncList
.
add
(
e
);
}
@Override
public
E
set
(
int
index
,
E
element
)
{
return
this
.
syncList
.
set
(
index
,
element
);
}
@Override
public
void
add
(
int
index
,
E
element
)
{
this
.
syncList
.
add
(
index
,
element
);
}
@Override
public
E
remove
(
int
index
)
{
return
this
.
syncList
.
remove
(
index
);
}
@Override
public
int
indexOf
(
Object
o
)
{
return
this
.
syncList
.
indexOf
(
o
);
}
@Override
public
int
lastIndexOf
(
Object
o
)
{
return
this
.
syncList
.
lastIndexOf
(
o
);
}
@Override
public
void
clear
()
{
this
.
syncList
.
clear
();
}
@Override
public
boolean
addAll
(
int
index
,
Collection
<?
extends
E
>
c
)
{
return
this
.
syncList
.
addAll
(
index
,
c
);
}
@Override
public
Iterator
<
E
>
iterator
()
{
return
this
.
syncList
.
iterator
();
}
@Override
public
ListIterator
<
E
>
listIterator
()
{
return
this
.
syncList
.
listIterator
();
}
@Override
public
ListIterator
<
E
>
listIterator
(
int
index
)
{
return
this
.
syncList
.
listIterator
(
index
);
}
@Override
public
List
<
E
>
subList
(
int
fromIndex
,
int
toIndex
)
{
return
this
.
syncList
.
subList
(
fromIndex
,
toIndex
);
}
@Override
public
int
hashCode
()
{
return
this
.
syncList
.
hashCode
();
}
@Override
public
boolean
isEmpty
()
{
return
this
.
syncList
.
isEmpty
();
}
@Override
public
boolean
contains
(
Object
o
)
{
return
this
.
syncList
.
contains
(
o
);
}
@Override
public
Object
[]
toArray
()
{
return
this
.
syncList
.
toArray
();
}
@SuppressWarnings
(
"SuspiciousToArrayCall"
)
@Override
public
<
T
>
T
[]
toArray
(
T
[]
a
)
{
return
this
.
syncList
.
toArray
(
a
);
}
@Override
public
boolean
remove
(
Object
o
)
{
return
this
.
syncList
.
remove
(
o
);
}
@Override
public
boolean
containsAll
(
Collection
<?>
c
)
{
return
this
.
syncList
.
containsAll
(
c
);
}
@Override
public
boolean
addAll
(
Collection
<?
extends
E
>
c
)
{
return
this
.
syncList
.
addAll
(
c
);
}
@Override
public
boolean
removeAll
(
Collection
<?>
c
)
{
return
this
.
syncList
.
removeAll
(
c
);
}
@Override
public
boolean
retainAll
(
Collection
<?>
c
)
{
return
this
.
syncList
.
retainAll
(
c
);
}
}
mirai-core/src/jvmMain/kotlin/net/mamoe/mirai/utils/config/MiraiConfig.kt
View file @
db77227d
...
...
@@ -22,7 +22,7 @@ class MiraiConfig(private val root: File) : MiraiConfigSection<Any>(parse(Object
val
dumperOptions
=
DumperOptions
()
dumperOptions
.
defaultFlowStyle
=
DumperOptions
.
FlowStyle
.
BLOCK
val
yaml
=
Yaml
(
dumperOptions
)
val
content
=
yaml
.
dump
(
this
.
sortedMap
)
val
content
=
yaml
.
dump
(
this
)
try
{
ByteArrayInputStream
(
content
.
toByteArray
()).
transferTo
(
FileOutputStream
(
this
.
root
))
}
catch
(
e
:
IOException
)
{
...
...
mirai-core/src/jvmMain/kotlin/net/mamoe/mirai/utils/config/MiraiConfigSection.java
View file @
db77227d
package
net.mamoe.mirai.utils.config
;
import
net.mamoe.mirai.utils.MiraiSynchronizedLinkedHashMap
;
import
java.util.LinkedHashMap
;
import
java.util.Map
;
import
java.util.concurrent.Callable
;
...
...
@@ -10,7 +8,7 @@ import java.util.function.Supplier;
/**
* @author NaturalHG
*/
public
class
MiraiConfigSection
<
T
>
extends
MiraiSynchronized
LinkedHashMap
<
String
,
T
>
{
public
class
MiraiConfigSection
<
T
>
extends
LinkedHashMap
<
String
,
T
>
{
public
MiraiConfigSection
(){
super
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment