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
23663e58
Commit
23663e58
authored
Aug 21, 2019
by
liujiahua123123
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
YAML supported
parent
d27f6b85
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
113 additions
and
23 deletions
+113
-23
mirai-core/src/main/java/net/mamoe/mirai/MiraiServer.java
mirai-core/src/main/java/net/mamoe/mirai/MiraiServer.java
+18
-0
mirai-core/src/main/java/net/mamoe/mirai/utils/config/MiraiAbstractConfigSection.java
.../mamoe/mirai/utils/config/MiraiAbstractConfigSection.java
+82
-0
mirai-core/src/main/java/net/mamoe/mirai/utils/config/MiraiConfig.java
...c/main/java/net/mamoe/mirai/utils/config/MiraiConfig.java
+1
-0
mirai-core/src/main/java/net/mamoe/mirai/utils/config/MiraiConfigSection.java
...java/net/mamoe/mirai/utils/config/MiraiConfigSection.java
+12
-23
No files found.
mirai-core/src/main/java/net/mamoe/mirai/MiraiServer.java
View file @
23663e58
...
@@ -114,6 +114,24 @@ public class MiraiServer {
...
@@ -114,6 +114,24 @@ public class MiraiServer {
getLogger
().
info
(
"ready to connect"
);
getLogger
().
info
(
"ready to connect"
);
/*
this.qqs.put("test",new MiraiConfigSection<String>(){{
put("1","2");
put("11","2");
put("111","2");
put("1111","2");
}});
this.qqs.save();
*/
System
.
out
.
println
(
this
.
qqs
.
get
());
/*
System.out.println(v);
System.out.println(v.get("1111"));
*/
System
.
exit
(
0
);
Robot
robot
=
new
Robot
(
1994701021
,
"xiaoqqq"
);
Robot
robot
=
new
Robot
(
1994701021
,
"xiaoqqq"
);
try
{
try
{
//System.out.println(Protocol.Companion.getSERVER_IP().get(3));
//System.out.println(Protocol.Companion.getSERVER_IP().get(3));
...
...
mirai-core/src/main/java/net/mamoe/mirai/utils/config/MiraiAbstractConfigSection.java
0 → 100644
View file @
23663e58
package
net.mamoe.mirai.utils.config
;
import
lombok.Setter
;
import
org.jetbrains.annotations.NotNull
;
import
org.jetbrains.annotations.Nullable
;
import
java.util.*
;
public
class
MiraiAbstractConfigSection
<
K
,
V
>
implements
Map
<
K
,
V
>
{
private
SortedMap
<
K
,
V
>
sortedMap
;
protected
void
setContent
(
SortedMap
<
K
,
V
>
map
){
this
.
sortedMap
=
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
);
}
@Nullable
@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
(
@NotNull
Map
<?
extends
K
,
?
extends
V
>
m
)
{
sortedMap
.
putAll
(
m
);
}
@Override
public
void
clear
()
{
sortedMap
.
clear
();
}
@NotNull
@Override
public
Set
<
K
>
keySet
()
{
return
sortedMap
.
keySet
();
}
@NotNull
@Override
public
Collection
<
V
>
values
()
{
return
sortedMap
.
values
();
}
@NotNull
@Override
public
Set
<
Entry
<
K
,
V
>>
entrySet
()
{
return
sortedMap
.
entrySet
();
}
}
mirai-core/src/main/java/net/mamoe/mirai/utils/config/MiraiConfig.java
View file @
23663e58
...
@@ -69,6 +69,7 @@ public class MiraiConfig extends MiraiConfigSection<Object> {
...
@@ -69,6 +69,7 @@ public class MiraiConfig extends MiraiConfigSection<Object> {
Map
<
String
,
Object
>
content
=
yaml
.
loadAs
(
Utils
.
readFile
(
this
.
root
),
LinkedHashMap
.
class
);
Map
<
String
,
Object
>
content
=
yaml
.
loadAs
(
Utils
.
readFile
(
this
.
root
),
LinkedHashMap
.
class
);
if
(
content
!=
null
)
{
if
(
content
!=
null
)
{
this
.
putAll
(
content
);
this
.
putAll
(
content
);
System
.
out
.
println
(
this
.
keySet
().
toString
());
}
}
}
catch
(
IOException
e
)
{
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
...
...
mirai-core/src/main/java/net/mamoe/mirai/utils/config/MiraiConfigSection.java
View file @
23663e58
package
net.mamoe.mirai.utils.config
;
package
net.mamoe.mirai.utils.config
;
import
java.util.Collections
;
import
org.jetbrains.annotations.NotNull
;
import
java.util.Map
;
import
java.util.SortedMap
;
import
java.util.*
;
import
java.util.concurrent.ConcurrentHashMap
;
import
java.util.concurrent.ConcurrentSkipListMap
;
import
java.util.concurrent.ConcurrentSkipListMap
;
import
java.util.concurrent.locks.Lock
;
import
java.util.concurrent.locks.ReentrantLock
;
public
class
MiraiConfigSection
<
T
>
extends
ConcurrentSkipListMap
<
String
,
T
>
{
public
class
MiraiConfigSection
<
T
>
extends
MiraiAbstractConfigSection
<
String
,
T
>
{
public
MiraiConfigSection
(){
public
MiraiConfigSection
(){
/*
* Ensure the key will be in order
* */
super
((
a
,
b
)
->
1
);
}
@SuppressWarnings
(
"unchecked"
)
public
<
D
extends
T
>
D
getAs
(
String
key
){
return
(
D
)
this
.
get
(
key
);
}
}
@SuppressWarnings
(
"unchecked"
)
public
<
D
extends
T
>
D
getAs
(
String
key
,
D
defaultV
){
return
(
D
)(
this
.
getOrDefault
(
key
,
defaultV
));
}
public
Integer
getInt
(
String
key
){
public
Integer
getInt
(
String
key
){
return
Integer
.
valueOf
(
this
.
get
(
key
).
toString
());
return
Integer
.
valueOf
(
this
.
get
(
key
).
toString
());
...
@@ -45,13 +29,18 @@ public class MiraiConfigSection<T> extends ConcurrentSkipListMap<String, T> {
...
@@ -45,13 +29,18 @@ public class MiraiConfigSection<T> extends ConcurrentSkipListMap<String, T> {
@SuppressWarnings
(
"unchecked"
)
@SuppressWarnings
(
"unchecked"
)
public
<
D
extends
T
>
MiraiConfigSection
<
D
>
getTypedSection
(
String
key
){
public
<
D
extends
T
>
MiraiConfigSection
<
D
>
getTypedSection
(
String
key
){
return
(
MiraiConfigSection
<
D
>)
this
.
getAs
(
key
);
var
content
=
(
SortedMap
<
String
,
D
>)
this
.
get
(
key
);
return
new
MiraiConfigSection
<>(){{
setContent
(
Collections
.
synchronizedSortedMap
(
content
));
}};
}
}
@SuppressWarnings
(
"unchecked"
)
@SuppressWarnings
(
"unchecked"
)
public
MiraiConfigSection
<
Object
>
getSection
(
String
key
){
public
MiraiConfigSection
<
Object
>
getSection
(
String
key
){
return
(
MiraiConfigSection
<
Object
>)
this
.
getAs
(
key
);
var
content
=
(
SortedMap
<
String
,
Object
>)
this
.
get
(
key
);
return
new
MiraiConfigSection
<>(){{
setContent
(
Collections
.
synchronizedSortedMap
(
content
));
}};
}
}
}
}
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