Skip to content

Commit a86d65f

Browse files
author
magiclu550
committed
[commit] player : add getName
1 parent e000665 commit a86d65f

File tree

9 files changed

+223
-224
lines changed

9 files changed

+223
-224
lines changed

.idea/libraries/Maven__cn_jsmod2_jsmod2_core_1_0_3.xml

Lines changed: 0 additions & 13 deletions
This file was deleted.

JPLS/src/main/java/cn/jsmod2/api/player/Player.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import cn.jsmod2.api.team.TeamRole;
1717
import cn.jsmod2.api.user.UserGroup;
1818
import cn.jsmod2.core.CommandSender;
19+
import cn.jsmod2.core.Powers;
1920
import cn.jsmod2.core.Server;
2021
import cn.jsmod2.core.math.Vector;
2122
import cn.jsmod2.network.*;
@@ -46,7 +47,13 @@ public class Player extends CommandSender implements IPlayer, Serializable,Clone
4647
private Scp079Data scp079Data = new Scp079Data();
4748

4849
public Player(String name){
49-
super(name,"all","cn.jsmod2.player");
50+
super(name, Powers.ALL,Powers.PLAYER);
51+
}
52+
53+
@Override
54+
public String getName() {
55+
SimpleGetStream stream = new SimpleGetStream(String.class);
56+
return stream.read(playerName,"Name",String.class);
5057
}
5158

5259
public ITeamRole getTeamRole() {

JPLS/src/main/java/cn/jsmod2/core/Console.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
public class Console extends CommandSender{
3333

3434
private Console(){
35-
super("CONSOLE","all","console","cn.jsmod2.admin","cn.jsmod2.player","nobody");
35+
super("CONSOLE","all","console","admin","player","nobody");
3636
}
3737

3838
private static Console console;

JPLS/src/main/java/cn/jsmod2/core/command/PowerPool.scala

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ object PowerPool {
3434
for(i <- 0 until ops.size()){
3535
val powers = poolMapping.get(ops.get(i))
3636
if(powers != null){
37-
powers.get.add("cn.jsmod2.admin")
37+
powers.get.add("admin")
3838
}
3939
}
4040

@@ -49,18 +49,18 @@ object PowerPool {
4949
def addAdminMemory(name:String): Unit ={
5050
val find = poolMapping.get(name)
5151
if(find==null){
52-
throw new NoSuchPlayerException("no such cn.jsmod2.player name")
52+
throw new NoSuchPlayerException("no such player name")
5353
}
54-
if(!find.get.contains("cn.jsmod2.admin"))
55-
find.get.add("cn.jsmod2.admin")
54+
if(!find.get.contains("admin"))
55+
find.get.add("admin")
5656
}
5757

5858
def removeAdminMemory(name:String): Boolean ={
5959
val find = poolMapping.get(name)
6060
if(find==null){
61-
throw new NoSuchPlayerException("no such cn.jsmod2.player name")
61+
throw new NoSuchPlayerException("no such player name")
6262
}
63-
find.get.remove("cn.jsmod2.admin")
63+
find.get.remove("admin")
6464
}
6565

6666
}

JPLS/src/main/java/cn/jsmod2/core/protocol/BinaryStream.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
package cn.jsmod2.core.protocol;
1212

13+
import cn.jsmod2.core.CommandSender;
1314
import cn.jsmod2.core.RegisterTemplate;
1415
import cn.jsmod2.core.Server;
1516
import cn.jsmod2.core.ex.ProtocolException;
@@ -152,6 +153,9 @@ public <T> T dataObjectDecode(byte[] data,Class<T> clz){
152153
System.arraycopy(props, 1, fields, 0, fields.length);
153154
insertField(fields, o);
154155
}
156+
if(o instanceof CommandSender){
157+
((CommandSender) o).setName(((CommandSender) o).getName());
158+
}
155159
return clz.cast(o);
156160
}catch (Exception e){
157161
throw new ProtocolException("The jsmod2 protocol is error",e);

jsmod2/src/main/java/cn/jsmod2/core/Powers.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ public interface Powers {
99
String CONSOLE = "console";
1010

1111
//管理员
12-
String ADMIN = "cn.jsmod2.admin";
12+
String ADMIN = "admin";
1313

1414
//普通玩家
15-
String PLAYER = "cn.jsmod2.player";
15+
String PLAYER = "player";
1616

1717
//任何人不能,控制台可以
1818
String NOBODY = "nobody";
-155 KB
Binary file not shown.
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#Generated by Maven
2-
#Fri Aug 16 16:35:36 CST 2019
2+
#Fri Aug 23 21:16:43 CST 2019
33
version=1.0-SNAPSHOT
44
groupId=cn.jsmod2
5-
artifactId=JSMod2-DevelopKit
5+
artifactId=jsmod2

jsmod2/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst

Lines changed: 200 additions & 199 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)