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
99cf7e2f
Commit
99cf7e2f
authored
Sep 04, 2019
by
Him188moe
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Updated robot & network structure
parent
39330e45
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
38 additions
and
47 deletions
+38
-47
mirai-core/src/main/java/net/mamoe/mirai/network/packet/ClientPacket.kt
.../main/java/net/mamoe/mirai/network/packet/ClientPacket.kt
+0
-1
mirai-core/src/main/java/net/mamoe/mirai/network/packet/VerificationCode.kt
...n/java/net/mamoe/mirai/network/packet/VerificationCode.kt
+0
-1
mirai-core/src/main/java/net/mamoe/mirai/network/packet/login/ClientLogin.kt
.../java/net/mamoe/mirai/network/packet/login/ClientLogin.kt
+1
-5
mirai-core/src/main/java/net/mamoe/mirai/network/packet/login/ServerLoginResponsePasswordVerifiedPacket.kt
...packet/login/ServerLoginResponsePasswordVerifiedPacket.kt
+1
-1
mirai-core/src/main/java/net/mamoe/mirai/network/packet/login/ServerLoginResponseResendPacket.kt
...i/network/packet/login/ServerLoginResponseResendPacket.kt
+1
-1
mirai-core/src/main/java/net/mamoe/mirai/network/packet/login/ServerLoginResponseVerificationCodeInitPacket.kt
...et/login/ServerLoginResponseVerificationCodeInitPacket.kt
+1
-1
mirai-core/src/main/java/net/mamoe/mirai/task/MiraiTaskExceptionHandler.java
.../java/net/mamoe/mirai/task/MiraiTaskExceptionHandler.java
+5
-8
mirai-core/src/main/java/net/mamoe/mirai/task/MiraiTaskManager.java
.../src/main/java/net/mamoe/mirai/task/MiraiTaskManager.java
+5
-5
mirai-core/src/main/java/net/mamoe/mirai/utils/TEA.java
mirai-core/src/main/java/net/mamoe/mirai/utils/TEA.java
+15
-15
mirai-core/src/main/java/net/mamoe/mirai/utils/Tested.kt
mirai-core/src/main/java/net/mamoe/mirai/utils/Tested.kt
+1
-1
mirai-core/src/main/java/net/mamoe/mirai/utils/setting/MiraiSetting.java
...main/java/net/mamoe/mirai/utils/setting/MiraiSetting.java
+8
-8
No files found.
mirai-core/src/main/java/net/mamoe/mirai/network/packet/ClientPacket.kt
View file @
99cf7e2f
...
@@ -2,7 +2,6 @@ package net.mamoe.mirai.network.packet
...
@@ -2,7 +2,6 @@ package net.mamoe.mirai.network.packet
import
lombok.Getter
import
lombok.Getter
import
net.mamoe.mirai.network.Protocol
import
net.mamoe.mirai.network.Protocol
import
net.mamoe.mirai.util.TestedSuccessfully
import
net.mamoe.mirai.utils.*
import
net.mamoe.mirai.utils.*
import
java.io.DataOutputStream
import
java.io.DataOutputStream
import
java.io.IOException
import
java.io.IOException
...
...
mirai-core/src/main/java/net/mamoe/mirai/network/packet/VerificationCode.kt
View file @
99cf7e2f
package
net.mamoe.mirai.network.packet
package
net.mamoe.mirai.network.packet
import
net.mamoe.mirai.network.Protocol
import
net.mamoe.mirai.network.Protocol
import
net.mamoe.mirai.util.TestedSuccessfully
import
net.mamoe.mirai.utils.*
import
net.mamoe.mirai.utils.*
import
java.io.DataInputStream
import
java.io.DataInputStream
...
...
mirai-core/src/main/java/net/mamoe/mirai/network/packet/login/ClientLogin.kt
View file @
99cf7e2f
...
@@ -2,11 +2,7 @@ package net.mamoe.mirai.network.packet.login
...
@@ -2,11 +2,7 @@ package net.mamoe.mirai.network.packet.login
import
net.mamoe.mirai.network.Protocol
import
net.mamoe.mirai.network.Protocol
import
net.mamoe.mirai.network.packet.*
import
net.mamoe.mirai.network.packet.*
import
net.mamoe.mirai.util.TestedSuccessfully
import
net.mamoe.mirai.utils.*
import
net.mamoe.mirai.utils.ByteArrayDataOutputStream
import
net.mamoe.mirai.utils.TEA
import
net.mamoe.mirai.utils.hexToBytes
import
net.mamoe.mirai.utils.toUHexString
import
java.io.DataOutputStream
import
java.io.DataOutputStream
/**
/**
...
...
mirai-core/src/main/java/net/mamoe/mirai/network/packet/login/ServerLoginResponsePasswordVerifiedPacket.kt
View file @
99cf7e2f
...
@@ -2,8 +2,8 @@ package net.mamoe.mirai.network.packet.login
...
@@ -2,8 +2,8 @@ package net.mamoe.mirai.network.packet.login
import
net.mamoe.mirai.network.Protocol
import
net.mamoe.mirai.network.Protocol
import
net.mamoe.mirai.network.packet.*
import
net.mamoe.mirai.network.packet.*
import
net.mamoe.mirai.util.TestedSuccessfully
import
net.mamoe.mirai.utils.TEA
import
net.mamoe.mirai.utils.TEA
import
net.mamoe.mirai.utils.TestedSuccessfully
import
net.mamoe.mirai.utils.toUHexString
import
net.mamoe.mirai.utils.toUHexString
import
java.io.DataInputStream
import
java.io.DataInputStream
...
...
mirai-core/src/main/java/net/mamoe/mirai/network/packet/login/ServerLoginResponseResendPacket.kt
View file @
99cf7e2f
...
@@ -3,7 +3,7 @@ package net.mamoe.mirai.network.packet.login
...
@@ -3,7 +3,7 @@ package net.mamoe.mirai.network.packet.login
import
net.mamoe.mirai.network.packet.PacketId
import
net.mamoe.mirai.network.packet.PacketId
import
net.mamoe.mirai.network.packet.ServerPacket
import
net.mamoe.mirai.network.packet.ServerPacket
import
net.mamoe.mirai.network.packet.goto
import
net.mamoe.mirai.network.packet.goto
import
net.mamoe.mirai.util.TestedSuccessfully
import
net.mamoe.mirai.util
s
.TestedSuccessfully
import
java.io.DataInputStream
import
java.io.DataInputStream
/**
/**
...
...
mirai-core/src/main/java/net/mamoe/mirai/network/packet/login/ServerLoginResponseVerificationCodeInitPacket.kt
View file @
99cf7e2f
...
@@ -4,8 +4,8 @@ import net.mamoe.mirai.network.packet.ServerPacket
...
@@ -4,8 +4,8 @@ import net.mamoe.mirai.network.packet.ServerPacket
import
net.mamoe.mirai.network.packet.cutTail
import
net.mamoe.mirai.network.packet.cutTail
import
net.mamoe.mirai.network.packet.dataInputStream
import
net.mamoe.mirai.network.packet.dataInputStream
import
net.mamoe.mirai.network.packet.goto
import
net.mamoe.mirai.network.packet.goto
import
net.mamoe.mirai.util.TestedSuccessfully
import
net.mamoe.mirai.utils.TEA
import
net.mamoe.mirai.utils.TEA
import
net.mamoe.mirai.utils.TestedSuccessfully
import
net.mamoe.mirai.utils.hexToUBytes
import
net.mamoe.mirai.utils.hexToUBytes
import
java.io.DataInputStream
import
java.io.DataInputStream
...
...
mirai-core/src/main/java/net/mamoe/mirai/task/MiraiTaskExceptionHandler.java
View file @
99cf7e2f
...
@@ -4,15 +4,12 @@ package net.mamoe.mirai.task;
...
@@ -4,15 +4,12 @@ package net.mamoe.mirai.task;
public
interface
MiraiTaskExceptionHandler
{
public
interface
MiraiTaskExceptionHandler
{
void
onHandle
(
Throwable
e
);
void
onHandle
(
Throwable
e
);
static
MiraiTaskExceptionHandler
byDefault
(){
static
MiraiTaskExceptionHandler
printing
()
{
return
byPrint
();
return
Throwable:
:
printStackTrace
;
}
static
MiraiTaskExceptionHandler
byIgnore
(){
return
a
->
{};
}
}
static
MiraiTaskExceptionHandler
byPrint
(){
static
MiraiTaskExceptionHandler
ignoring
()
{
return
Throwable:
:
printStackTrace
;
return
a
->
{
};
}
}
}
}
mirai-core/src/main/java/net/mamoe/mirai/task/MiraiTaskManager.java
View file @
99cf7e2f
...
@@ -35,7 +35,7 @@ public final class MiraiTaskManager {
...
@@ -35,7 +35,7 @@ public final class MiraiTaskManager {
*/
*/
public
void
execute
(
Runnable
runnable
)
{
public
void
execute
(
Runnable
runnable
)
{
this
.
execute
(
runnable
,
MiraiTaskExceptionHandler
.
byDefault
());
this
.
execute
(
runnable
,
MiraiTaskExceptionHandler
.
printing
());
}
}
public
void
execute
(
Runnable
runnable
,
MiraiTaskExceptionHandler
handler
)
{
public
void
execute
(
Runnable
runnable
,
MiraiTaskExceptionHandler
handler
)
{
...
@@ -51,7 +51,7 @@ public final class MiraiTaskManager {
...
@@ -51,7 +51,7 @@ public final class MiraiTaskManager {
public
<
D
>
Future
<
D
>
submit
(
Callable
<
D
>
callable
)
{
public
<
D
>
Future
<
D
>
submit
(
Callable
<
D
>
callable
)
{
return
this
.
submit
(
callable
,
MiraiTaskExceptionHandler
.
byDefault
());
return
this
.
submit
(
callable
,
MiraiTaskExceptionHandler
.
printing
());
}
}
public
<
D
>
Future
<
D
>
submit
(
Callable
<
D
>
callable
,
MiraiTaskExceptionHandler
handler
)
{
public
<
D
>
Future
<
D
>
submit
(
Callable
<
D
>
callable
,
MiraiTaskExceptionHandler
handler
)
{
...
@@ -69,7 +69,7 @@ public final class MiraiTaskManager {
...
@@ -69,7 +69,7 @@ public final class MiraiTaskManager {
* 异步任务
* 异步任务
*/
*/
public
<
D
>
void
ansycTask
(
Callable
<
D
>
callable
,
Consumer
<
D
>
callback
)
{
public
<
D
>
void
ansycTask
(
Callable
<
D
>
callable
,
Consumer
<
D
>
callback
)
{
this
.
ansycTask
(
callable
,
callback
,
MiraiTaskExceptionHandler
.
byDefault
());
this
.
ansycTask
(
callable
,
callback
,
MiraiTaskExceptionHandler
.
printing
());
}
}
public
<
D
>
void
ansycTask
(
Callable
<
D
>
callable
,
Consumer
<
D
>
callback
,
MiraiTaskExceptionHandler
handler
)
{
public
<
D
>
void
ansycTask
(
Callable
<
D
>
callable
,
Consumer
<
D
>
callback
,
MiraiTaskExceptionHandler
handler
)
{
...
@@ -87,7 +87,7 @@ public final class MiraiTaskManager {
...
@@ -87,7 +87,7 @@ public final class MiraiTaskManager {
*/
*/
public
void
repeatingTask
(
Runnable
runnable
,
long
intervalMillis
)
{
public
void
repeatingTask
(
Runnable
runnable
,
long
intervalMillis
)
{
this
.
repeatingTask
(
runnable
,
intervalMillis
,
MiraiTaskExceptionHandler
.
byDefault
());
this
.
repeatingTask
(
runnable
,
intervalMillis
,
MiraiTaskExceptionHandler
.
printing
());
}
}
public
void
repeatingTask
(
Runnable
runnable
,
long
intervalMillis
,
MiraiTaskExceptionHandler
handler
)
{
public
void
repeatingTask
(
Runnable
runnable
,
long
intervalMillis
,
MiraiTaskExceptionHandler
handler
)
{
...
@@ -95,7 +95,7 @@ public final class MiraiTaskManager {
...
@@ -95,7 +95,7 @@ public final class MiraiTaskManager {
}
}
public
void
repeatingTask
(
Runnable
runnable
,
long
intervalMillis
,
int
times
)
{
public
void
repeatingTask
(
Runnable
runnable
,
long
intervalMillis
,
int
times
)
{
this
.
repeatingTask
(
runnable
,
intervalMillis
,
times
,
MiraiTaskExceptionHandler
.
byDefault
());
this
.
repeatingTask
(
runnable
,
intervalMillis
,
times
,
MiraiTaskExceptionHandler
.
printing
());
}
}
public
void
repeatingTask
(
Runnable
runnable
,
long
intervalMillis
,
int
times
,
MiraiTaskExceptionHandler
handler
)
{
public
void
repeatingTask
(
Runnable
runnable
,
long
intervalMillis
,
int
times
,
MiraiTaskExceptionHandler
handler
)
{
...
...
mirai-core/src/main/java/net/mamoe/mirai/utils/TEA.java
View file @
99cf7e2f
...
@@ -6,9 +6,11 @@ import java.nio.ByteBuffer;
...
@@ -6,9 +6,11 @@ import java.nio.ByteBuffer;
import
java.util.Random
;
import
java.util.Random
;
/**
/**
* TEA 加密
*
* @author iweiz https://github.com/iweizime/StepChanger/blob/master/app/src/main/java/me/iweizi/stepchanger/qq/Cryptor.java
* @author iweiz https://github.com/iweizime/StepChanger/blob/master/app/src/main/java/me/iweizi/stepchanger/qq/Cryptor.java
*/
*/
public
class
TEA
{
public
final
class
TEA
{
public
static
final
TEA
CRYPTOR_SHARE_KEY
=
new
TEA
(
Protocol
.
Companion
.
hexToBytes
(
Protocol
.
shareKey
));
public
static
final
TEA
CRYPTOR_SHARE_KEY
=
new
TEA
(
Protocol
.
Companion
.
hexToBytes
(
Protocol
.
shareKey
));
public
static
final
TEA
CRYPTOR_0825KEY
=
new
TEA
(
Protocol
.
Companion
.
hexToBytes
(
Protocol
.
key0825
));
public
static
final
TEA
CRYPTOR_0825KEY
=
new
TEA
(
Protocol
.
Companion
.
hexToBytes
(
Protocol
.
key0825
));
public
static
final
TEA
CRYPTOR_00BAKEY
=
new
TEA
(
Protocol
.
Companion
.
hexToBytes
(
Protocol
.
key00BA
));
public
static
final
TEA
CRYPTOR_00BAKEY
=
new
TEA
(
Protocol
.
Companion
.
hexToBytes
(
Protocol
.
key00BA
));
...
@@ -23,14 +25,12 @@ public class TEA {
...
@@ -23,14 +25,12 @@ public class TEA {
private
int
mOutPos
;
private
int
mOutPos
;
private
int
mPreOutPos
;
private
int
mPreOutPos
;
private
boolean
isFirstBlock
;
private
boolean
isFirstBlock
;
private
boolean
isRand
;
public
TEA
(
byte
[]
key
)
{
public
TEA
(
byte
[]
key
)
{
mKey
=
new
long
[
4
];
mKey
=
new
long
[
4
];
for
(
int
i
=
0
;
i
<
4
;
i
++)
{
for
(
int
i
=
0
;
i
<
4
;
i
++)
{
mKey
[
i
]
=
pack
(
key
,
i
*
4
,
4
);
mKey
[
i
]
=
pack
(
key
,
i
*
4
,
4
);
}
}
isRand
=
true
;
mRandom
=
new
Random
();
mRandom
=
new
Random
();
isFirstBlock
=
true
;
isFirstBlock
=
true
;
}
}
...
@@ -51,6 +51,7 @@ public class TEA {
...
@@ -51,6 +51,7 @@ public class TEA {
return
decrypt
(
source
,
UtilsKt
.
hexToBytes
(
keyHex
));
return
decrypt
(
source
,
UtilsKt
.
hexToBytes
(
keyHex
));
}
}
@SuppressWarnings
(
"SameParameterValue"
)
private
static
long
pack
(
byte
[]
bytes
,
int
offset
,
int
len
)
{
private
static
long
pack
(
byte
[]
bytes
,
int
offset
,
int
len
)
{
long
result
=
0
;
long
result
=
0
;
int
max_offset
=
len
>
8
?
offset
+
8
:
offset
+
len
;
int
max_offset
=
len
>
8
?
offset
+
8
:
offset
+
len
;
...
@@ -61,11 +62,7 @@ public class TEA {
...
@@ -61,11 +62,7 @@ public class TEA {
}
}
private
int
rand
()
{
private
int
rand
()
{
return
isRand
?
mRandom
.
nextInt
()
:
0xff00ff
;
return
mRandom
.
nextInt
();
}
public
void
enableRandom
(
boolean
rand
)
{
isRand
=
rand
;
}
}
private
byte
[]
encode
(
byte
[]
bytes
)
{
private
byte
[]
encode
(
byte
[]
bytes
)
{
...
@@ -117,6 +114,7 @@ public class TEA {
...
@@ -117,6 +114,7 @@ public class TEA {
isFirstBlock
=
false
;
isFirstBlock
=
false
;
}
}
@SuppressWarnings
(
"BooleanMethodIsAlwaysInverted"
)
private
boolean
decodeOneBlock
(
byte
[]
ciphertext
,
int
offset
,
int
len
)
{
private
boolean
decodeOneBlock
(
byte
[]
ciphertext
,
int
offset
,
int
len
)
{
for
(
mIndexPos
=
0
;
mIndexPos
<
8
;
mIndexPos
++)
{
for
(
mIndexPos
=
0
;
mIndexPos
<
8
;
mIndexPos
++)
{
if
(
mOutPos
+
mIndexPos
<
len
)
{
if
(
mOutPos
+
mIndexPos
<
len
)
{
...
@@ -133,6 +131,7 @@ public class TEA {
...
@@ -133,6 +131,7 @@ public class TEA {
}
}
@SuppressWarnings
(
"SameParameterValue"
)
private
byte
[]
encrypt
(
byte
[]
plaintext
,
int
offset
,
int
len
)
{
private
byte
[]
encrypt
(
byte
[]
plaintext
,
int
offset
,
int
len
)
{
mInBlock
=
new
byte
[
8
];
mInBlock
=
new
byte
[
8
];
mIV
=
new
byte
[
8
];
mIV
=
new
byte
[
8
];
...
@@ -183,11 +182,12 @@ public class TEA {
...
@@ -183,11 +182,12 @@ public class TEA {
return
mOutput
;
return
mOutput
;
}
}
private
byte
[]
decrypt
(
byte
[]
ciphertext
,
int
offset
,
int
len
)
{
@SuppressWarnings
(
"SameParameterValue"
)
private
byte
[]
decrypt
(
byte
[]
cipherText
,
int
offset
,
int
len
)
{
if
(
len
%
8
!=
0
||
len
<
16
)
{
if
(
len
%
8
!=
0
||
len
<
16
)
{
throw
new
IllegalArgumentException
(
"must len % 8 == 0 && len >= 16"
);
throw
new
IllegalArgumentException
(
"must len % 8 == 0 && len >= 16"
);
}
}
mIV
=
decode
(
cipher
t
ext
,
offset
);
mIV
=
decode
(
cipher
T
ext
,
offset
);
mIndexPos
=
mIV
[
0
]
&
7
;
mIndexPos
=
mIV
[
0
]
&
7
;
int
plen
=
len
-
mIndexPos
-
10
;
int
plen
=
len
-
mIndexPos
-
10
;
isFirstBlock
=
true
;
isFirstBlock
=
true
;
...
@@ -206,7 +206,7 @@ public class TEA {
...
@@ -206,7 +206,7 @@ public class TEA {
}
}
if
(
mIndexPos
==
8
)
{
if
(
mIndexPos
==
8
)
{
isFirstBlock
=
false
;
isFirstBlock
=
false
;
if
(!
decodeOneBlock
(
cipher
t
ext
,
offset
,
len
))
{
if
(!
decodeOneBlock
(
cipher
T
ext
,
offset
,
len
))
{
throw
new
RuntimeException
(
"Unable to decode"
);
throw
new
RuntimeException
(
"Unable to decode"
);
}
}
}
}
...
@@ -216,20 +216,20 @@ public class TEA {
...
@@ -216,20 +216,20 @@ public class TEA {
if
(
mIndexPos
<
8
)
{
if
(
mIndexPos
<
8
)
{
mOutput
[
outpos
++]
=
isFirstBlock
?
mOutput
[
outpos
++]
=
isFirstBlock
?
mIV
[
mIndexPos
]
:
mIV
[
mIndexPos
]
:
(
byte
)
(
cipher
t
ext
[
mPreOutPos
+
offset
+
mIndexPos
]
^
mIV
[
mIndexPos
]);
(
byte
)
(
cipher
T
ext
[
mPreOutPos
+
offset
+
mIndexPos
]
^
mIV
[
mIndexPos
]);
++
mIndexPos
;
++
mIndexPos
;
}
}
if
(
mIndexPos
==
8
)
{
if
(
mIndexPos
==
8
)
{
mPreOutPos
=
mOutPos
-
8
;
mPreOutPos
=
mOutPos
-
8
;
isFirstBlock
=
false
;
isFirstBlock
=
false
;
if
(!
decodeOneBlock
(
cipher
t
ext
,
offset
,
len
))
{
if
(!
decodeOneBlock
(
cipher
T
ext
,
offset
,
len
))
{
throw
new
RuntimeException
(
"Unable to decode"
);
throw
new
RuntimeException
(
"Unable to decode"
);
}
}
}
}
}
}
for
(
g
=
0
;
g
<
7
;
g
++)
{
for
(
g
=
0
;
g
<
7
;
g
++)
{
if
(
mIndexPos
<
8
)
{
if
(
mIndexPos
<
8
)
{
if
((
cipher
t
ext
[
mPreOutPos
+
offset
+
mIndexPos
]
^
mIV
[
mIndexPos
])
!=
0
)
{
if
((
cipher
T
ext
[
mPreOutPos
+
offset
+
mIndexPos
]
^
mIV
[
mIndexPos
])
!=
0
)
{
throw
new
RuntimeException
();
throw
new
RuntimeException
();
}
else
{
}
else
{
++
mIndexPos
;
++
mIndexPos
;
...
@@ -238,7 +238,7 @@ public class TEA {
...
@@ -238,7 +238,7 @@ public class TEA {
if
(
mIndexPos
==
8
)
{
if
(
mIndexPos
==
8
)
{
mPreOutPos
=
mOutPos
;
mPreOutPos
=
mOutPos
;
if
(!
decodeOneBlock
(
cipher
t
ext
,
offset
,
len
))
{
if
(!
decodeOneBlock
(
cipher
T
ext
,
offset
,
len
))
{
throw
new
RuntimeException
(
"Unable to decode"
);
throw
new
RuntimeException
(
"Unable to decode"
);
}
}
}
}
...
...
mirai-core/src/main/java/net/mamoe/mirai/utils/Tested.kt
View file @
99cf7e2f
package
net.mamoe.mirai.util
package
net.mamoe.mirai.util
s
/**
/**
* @author Him188moe
* @author Him188moe
...
...
mirai-core/src/main/java/net/mamoe/mirai/utils/setting/MiraiSetting.java
View file @
99cf7e2f
...
@@ -6,14 +6,14 @@ import org.ini4j.Ini;
...
@@ -6,14 +6,14 @@ import org.ini4j.Ini;
import
java.io.File
;
import
java.io.File
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
import
java.util.concurrent.ConcurrentHashMap
;
import
java.util.concurrent.ConcurrentHashMap
;
/**
/**
* Mirai Config
* Thread-safe Mirai Config <br>
* Only support {INI} format
* Only supports <code>INI</code> format <br>
* Support MAP and LIST
* Supports {@link Map} and {@link List}
* Thread safe
*/
*/
public
class
MiraiSetting
{
public
class
MiraiSetting
{
...
@@ -42,12 +42,12 @@ public class MiraiSetting {
...
@@ -42,12 +42,12 @@ public class MiraiSetting {
}
}
}
}
public
void
setSection
(
String
key
,
MiraiSettingSection
section
)
{
public
synchronized
void
setSection
(
String
key
,
MiraiSettingSection
section
)
{
cacheSection
.
put
(
key
,
section
);
cacheSection
.
put
(
key
,
section
);
}
}
public
MiraiSettingMapSection
getMapSection
(
String
key
)
{
public
synchronized
MiraiSettingMapSection
getMapSection
(
String
key
)
{
if
(!
cacheSection
.
containsKey
(
key
))
{
if
(!
cacheSection
.
containsKey
(
key
))
{
MiraiSettingMapSection
section
=
new
MiraiSettingMapSection
();
MiraiSettingMapSection
section
=
new
MiraiSettingMapSection
();
if
(
ini
.
containsKey
(
key
)){
if
(
ini
.
containsKey
(
key
)){
...
@@ -58,7 +58,7 @@ public class MiraiSetting {
...
@@ -58,7 +58,7 @@ public class MiraiSetting {
return
(
MiraiSettingMapSection
)
cacheSection
.
get
(
key
);
return
(
MiraiSettingMapSection
)
cacheSection
.
get
(
key
);
}
}
public
MiraiSettingListSection
getListSection
(
String
key
)
{
public
synchronized
MiraiSettingListSection
getListSection
(
String
key
)
{
if
(!
cacheSection
.
containsKey
(
key
))
{
if
(!
cacheSection
.
containsKey
(
key
))
{
MiraiSettingListSection
section
=
new
MiraiSettingListSection
();
MiraiSettingListSection
section
=
new
MiraiSettingListSection
();
if
(
ini
.
containsKey
(
key
)){
if
(
ini
.
containsKey
(
key
)){
...
@@ -85,7 +85,7 @@ public class MiraiSetting {
...
@@ -85,7 +85,7 @@ public class MiraiSetting {
}
}
}
}
public
void
clearCache
()
{
public
synchronized
void
clearCache
()
{
cacheSection
.
clear
();
cacheSection
.
clear
();
}
}
}
}
...
...
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