mirror of
https://github.com/Grasscutters/Grasscutter.git
synced 2025-12-22 20:04:56 +01:00
Cleanup package names
This commit is contained in:
@@ -0,0 +1,66 @@
|
||||
package emu.grasscutter.game.managers.mapmark;
|
||||
|
||||
import dev.morphia.annotations.Entity;
|
||||
import emu.grasscutter.net.proto.MapMarkFromTypeOuterClass.MapMarkFromType;
|
||||
import emu.grasscutter.net.proto.MapMarkPointOuterClass.MapMarkPoint;
|
||||
import emu.grasscutter.net.proto.MapMarkPointTypeOuterClass.MapMarkPointType;
|
||||
import emu.grasscutter.utils.Position;
|
||||
|
||||
@Entity
|
||||
public class MapMark {
|
||||
private int sceneId;
|
||||
private String name;
|
||||
private Position position;
|
||||
private MapMarkPointType mapMarkPointType;
|
||||
private int monsterId;
|
||||
private MapMarkFromType mapMarkFromType;
|
||||
private int questId;
|
||||
|
||||
@Deprecated // Morhpia
|
||||
public MapMark() {
|
||||
this.mapMarkPointType = MapMarkPointType.MAP_MARK_POINT_TYPE_MONSTER;
|
||||
this.mapMarkFromType = MapMarkFromType.MAP_MARK_FROM_TYPE_MONSTER;
|
||||
}
|
||||
|
||||
public MapMark(MapMarkPoint mapMarkPoint) {
|
||||
this.sceneId = mapMarkPoint.getSceneId();
|
||||
this.name = mapMarkPoint.getName();
|
||||
this.position = new Position(
|
||||
mapMarkPoint.getPos().getX(),
|
||||
mapMarkPoint.getPos().getY(),
|
||||
mapMarkPoint.getPos().getZ()
|
||||
);
|
||||
this.mapMarkPointType = mapMarkPoint.getPointType();
|
||||
this.monsterId = mapMarkPoint.getMonsterId();
|
||||
this.mapMarkFromType = mapMarkPoint.getFromType();
|
||||
this.questId = mapMarkPoint.getQuestId();
|
||||
}
|
||||
|
||||
public int getSceneId() {
|
||||
return this.sceneId;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public Position getPosition() {
|
||||
return this.position;
|
||||
}
|
||||
|
||||
public MapMarkPointType getMapMarkPointType() {
|
||||
return this.mapMarkPointType;
|
||||
}
|
||||
|
||||
public int getMonsterId() {
|
||||
return this.monsterId;
|
||||
}
|
||||
|
||||
public MapMarkFromType getMapMarkFromType() {
|
||||
return this.mapMarkFromType;
|
||||
}
|
||||
|
||||
public int getQuestId() {
|
||||
return this.questId;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
package emu.grasscutter.game.managers.mapmark;
|
||||
|
||||
import emu.grasscutter.game.player.Player;
|
||||
import emu.grasscutter.net.proto.MapMarkPointTypeOuterClass.MapMarkPointType;
|
||||
import emu.grasscutter.net.proto.MarkMapReqOuterClass.MarkMapReq;
|
||||
import emu.grasscutter.net.proto.MarkMapReqOuterClass.MarkMapReq.Operation;
|
||||
import emu.grasscutter.server.packet.send.PacketMarkMapRsp;
|
||||
import emu.grasscutter.server.packet.send.PacketSceneEntityAppearNotify;
|
||||
import emu.grasscutter.utils.Position;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
public class MapMarksManager {
|
||||
public static final int mapMarkMaxCount = 150;
|
||||
private HashMap<String, MapMark> mapMarks;
|
||||
private final Player player;
|
||||
|
||||
public MapMarksManager(Player player) {
|
||||
this.player = player;
|
||||
this.mapMarks = player.getMapMarks();
|
||||
if (this.mapMarks == null) { this.mapMarks = new HashMap<>(); }
|
||||
}
|
||||
|
||||
public void handleMapMarkReq(MarkMapReq req) {
|
||||
Operation op = req.getOp();
|
||||
switch (op) {
|
||||
case OPERATION_ADD -> {
|
||||
MapMark createMark = new MapMark(req.getMark());
|
||||
// keep teleporting functionality on fishhook mark.
|
||||
if (createMark.getMapMarkPointType() == MapMarkPointType.MAP_MARK_POINT_TYPE_FISH_POOL) {
|
||||
teleport(player, createMark);
|
||||
return;
|
||||
}
|
||||
addMapMark(createMark);
|
||||
}
|
||||
case OPERATION_MOD -> {
|
||||
MapMark oldMark = new MapMark(req.getOld());
|
||||
removeMapMark(oldMark.getPosition());
|
||||
MapMark newMark = new MapMark(req.getMark());
|
||||
addMapMark(newMark);
|
||||
}
|
||||
case OPERATION_DEL -> {
|
||||
MapMark deleteMark = new MapMark(req.getMark());
|
||||
removeMapMark(deleteMark.getPosition());
|
||||
}
|
||||
}
|
||||
if (op != Operation.OPERATION_GET) {
|
||||
saveMapMarks();
|
||||
}
|
||||
player.getSession().send(new PacketMarkMapRsp(getMapMarks()));
|
||||
}
|
||||
|
||||
public HashMap<String, MapMark> getMapMarks() {
|
||||
return mapMarks;
|
||||
}
|
||||
|
||||
public String getMapMarkKey(Position position) {
|
||||
return "x" + (int)position.getX()+ "z" + (int)position.getZ();
|
||||
}
|
||||
|
||||
public void removeMapMark(Position position) {
|
||||
mapMarks.remove(getMapMarkKey(position));
|
||||
}
|
||||
|
||||
public void addMapMark(MapMark mapMark) {
|
||||
if (mapMarks.size() < mapMarkMaxCount) {
|
||||
mapMarks.put(getMapMarkKey(mapMark.getPosition()), mapMark);
|
||||
}
|
||||
}
|
||||
|
||||
private void saveMapMarks() {
|
||||
player.setMapMarks(mapMarks);
|
||||
player.save();
|
||||
}
|
||||
|
||||
private void teleport(Player player, MapMark mapMark) {
|
||||
float y;
|
||||
try {
|
||||
y = (float)Integer.parseInt(mapMark.getName());
|
||||
} catch (Exception e) {
|
||||
y = 300;
|
||||
}
|
||||
Position pos = mapMark.getPosition();
|
||||
player.getPos().set(pos.getX(), y, pos.getZ());
|
||||
if (mapMark.getSceneId() != player.getSceneId()) {
|
||||
player.getWorld().transferPlayerToScene(player, mapMark.getSceneId(), player.getPos());
|
||||
}
|
||||
player.getScene().broadcastPacket(new PacketSceneEntityAppearNotify(player));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user