Commit a8293102 authored by Melledy's avatar Melledy Committed by GitHub
Browse files

Merge branch 'development' into stable

parents 304b9cb8 ecf7a81a
package emu.grasscutter.server.packet.send;
import emu.grasscutter.net.packet.BasePacket;
import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.proto.SceneUnlockInfoNotifyOuterClass.SceneUnlockInfoNotify;
import emu.grasscutter.net.proto.SceneUnlockInfoOuterClass.SceneUnlockInfo;
public class PacketSceneUnlockInfoNotify extends BasePacket {
public PacketSceneUnlockInfoNotify() {
super(PacketOpcodes.SceneUnlockInfoNotify); // Rename opcode later
SceneUnlockInfoNotify proto = SceneUnlockInfoNotify.newBuilder()
.addUnlockInfos(SceneUnlockInfo.newBuilder().setSceneId(1))
.addUnlockInfos(SceneUnlockInfo.newBuilder().setSceneId(3).addSceneTagIdList(102).addSceneTagIdList(113).addSceneTagIdList(117))
.addUnlockInfos(SceneUnlockInfo.newBuilder().setSceneId(4).addSceneTagIdList(106).addSceneTagIdList(109))
.addUnlockInfos(SceneUnlockInfo.newBuilder().setSceneId(5))
.addUnlockInfos(SceneUnlockInfo.newBuilder().setSceneId(6))
.addUnlockInfos(SceneUnlockInfo.newBuilder().setSceneId(7))
.build();
this.setData(proto);
}
}
package emu.grasscutter.server.packet.send;
import emu.grasscutter.game.player.Player;
import emu.grasscutter.game.quest.GameQuest;
import emu.grasscutter.net.packet.BasePacket;
import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.proto.ServerCondMeetQuestListUpdateNotifyOuterClass.ServerCondMeetQuestListUpdateNotify;
public class PacketServerCondMeetQuestListUpdateNotify extends BasePacket {
public PacketServerCondMeetQuestListUpdateNotify(Player player) {
super(PacketOpcodes.ServerCondMeetQuestListUpdateNotify);
ServerCondMeetQuestListUpdateNotify.Builder proto = ServerCondMeetQuestListUpdateNotify.newBuilder();
/*
player.getQuestManager().forEachQuest(quest -> {
if (quest.getState().getValue() <= 2) {
proto.addAddQuestIdList(quest.getQuestId());
}
});
*/
this.setData(proto);
}
public PacketServerCondMeetQuestListUpdateNotify(GameQuest quest) {
super(PacketOpcodes.ServerCondMeetQuestListUpdateNotify);
ServerCondMeetQuestListUpdateNotify proto = ServerCondMeetQuestListUpdateNotify.newBuilder()
//.addAddQuestIdList(quest.getQuestId())
.build();
this.setData(proto);
}
}
package emu.grasscutter.server.packet.send;
import emu.grasscutter.net.packet.BasePacket;
import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.proto.SetWidgetSlotRspOuterClass;
public class PacketSetWidgetSlotRsp extends BasePacket {
public PacketSetWidgetSlotRsp(int materialId) {
super(PacketOpcodes.SetWidgetSlotRsp);
SetWidgetSlotRspOuterClass.SetWidgetSlotRsp proto = SetWidgetSlotRspOuterClass.SetWidgetSlotRsp.newBuilder()
.setMaterialId(materialId)
.build();
this.setData(proto);
}
}
...@@ -18,7 +18,7 @@ public class PacketStoreItemChangeNotify extends BasePacket { ...@@ -18,7 +18,7 @@ public class PacketStoreItemChangeNotify extends BasePacket {
this(); this();
StoreItemChangeNotify.Builder proto = StoreItemChangeNotify.newBuilder() StoreItemChangeNotify.Builder proto = StoreItemChangeNotify.newBuilder()
.setStoreType(StoreType.STORE_PACK) .setStoreType(StoreType.STORE_TYPE_PACK)
.addItemList(item.toProto()); .addItemList(item.toProto());
this.setData(proto); this.setData(proto);
...@@ -28,7 +28,7 @@ public class PacketStoreItemChangeNotify extends BasePacket { ...@@ -28,7 +28,7 @@ public class PacketStoreItemChangeNotify extends BasePacket {
this(); this();
StoreItemChangeNotify.Builder proto = StoreItemChangeNotify.newBuilder() StoreItemChangeNotify.Builder proto = StoreItemChangeNotify.newBuilder()
.setStoreType(StoreType.STORE_PACK); .setStoreType(StoreType.STORE_TYPE_PACK);
items.forEach(item -> proto.addItemList(item.toProto())); items.forEach(item -> proto.addItemList(item.toProto()));
......
...@@ -18,7 +18,7 @@ public class PacketStoreItemDelNotify extends BasePacket { ...@@ -18,7 +18,7 @@ public class PacketStoreItemDelNotify extends BasePacket {
this(); this();
StoreItemDelNotify.Builder proto = StoreItemDelNotify.newBuilder() StoreItemDelNotify.Builder proto = StoreItemDelNotify.newBuilder()
.setStoreType(StoreType.STORE_PACK) .setStoreType(StoreType.STORE_TYPE_PACK)
.addGuidList(item.getGuid()); .addGuidList(item.getGuid());
this.setData(proto); this.setData(proto);
...@@ -28,7 +28,7 @@ public class PacketStoreItemDelNotify extends BasePacket { ...@@ -28,7 +28,7 @@ public class PacketStoreItemDelNotify extends BasePacket {
this(); this();
StoreItemDelNotify.Builder proto = StoreItemDelNotify.newBuilder() StoreItemDelNotify.Builder proto = StoreItemDelNotify.newBuilder()
.setStoreType(StoreType.STORE_PACK); .setStoreType(StoreType.STORE_TYPE_PACK);
items.stream().forEach(item -> proto.addGuidList(item.getGuid())); items.stream().forEach(item -> proto.addGuidList(item.getGuid()));
......
package emu.grasscutter.server.packet.send; package emu.grasscutter.server.packet.send;
import emu.grasscutter.Grasscutter;
import emu.grasscutter.net.packet.BasePacket; import emu.grasscutter.net.packet.BasePacket;
import emu.grasscutter.net.packet.PacketOpcodes; import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.proto.StoreTypeOuterClass.StoreType; import emu.grasscutter.net.proto.StoreTypeOuterClass.StoreType;
import emu.grasscutter.net.proto.StoreWeightLimitNotifyOuterClass.StoreWeightLimitNotify; import emu.grasscutter.net.proto.StoreWeightLimitNotifyOuterClass.StoreWeightLimitNotify;
import static emu.grasscutter.Configuration.*;
public class PacketStoreWeightLimitNotify extends BasePacket { public class PacketStoreWeightLimitNotify extends BasePacket {
public PacketStoreWeightLimitNotify() { public PacketStoreWeightLimitNotify() {
super(PacketOpcodes.StoreWeightLimitNotify); super(PacketOpcodes.StoreWeightLimitNotify);
StoreWeightLimitNotify p = StoreWeightLimitNotify.newBuilder() StoreWeightLimitNotify p = StoreWeightLimitNotify.newBuilder()
.setStoreType(StoreType.STORE_PACK) .setStoreType(StoreType.STORE_TYPE_PACK)
.setWeightLimit(Grasscutter.getConfig().getGameServerOptions().InventoryLimitAll) .setWeightLimit(INVENTORY_LIMITS.all)
.setWeaponCountLimit(Grasscutter.getConfig().getGameServerOptions().InventoryLimitWeapon) .setWeaponCountLimit(INVENTORY_LIMITS.weapons)
.setReliquaryCountLimit(Grasscutter.getConfig().getGameServerOptions().InventoryLimitRelic) .setReliquaryCountLimit(INVENTORY_LIMITS.relics)
.setMaterialCountLimit(Grasscutter.getConfig().getGameServerOptions().InventoryLimitMaterial) .setMaterialCountLimit(INVENTORY_LIMITS.materials)
.setFurnitureCountLimit(Grasscutter.getConfig().getGameServerOptions().InventoryLimitFurniture) .setFurnitureCountLimit(INVENTORY_LIMITS.furniture)
.build(); .build();
this.setData(p); this.setData(p);
......
package emu.grasscutter.server.packet.send; package emu.grasscutter.server.packet.send;
import emu.grasscutter.data.GameData; import emu.grasscutter.game.tower.TowerManager;
import emu.grasscutter.data.def.TowerFloorData; import emu.grasscutter.game.tower.TowerScheduleManager;
import emu.grasscutter.net.packet.BasePacket; import emu.grasscutter.net.packet.BasePacket;
import emu.grasscutter.net.packet.PacketOpcodes; import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.proto.TowerAllDataRspOuterClass.TowerAllDataRsp; import emu.grasscutter.net.proto.TowerAllDataRspOuterClass.TowerAllDataRsp;
import emu.grasscutter.net.proto.TowerCurLevelRecordOuterClass.TowerCurLevelRecord; import emu.grasscutter.net.proto.TowerCurLevelRecordOuterClass.TowerCurLevelRecord;
import emu.grasscutter.net.proto.TowerFloorRecordOuterClass.TowerFloorRecord; import emu.grasscutter.net.proto.TowerFloorRecordOuterClass.TowerFloorRecord;
import emu.grasscutter.net.proto.TowerLevelRecordOuterClass;
import emu.grasscutter.utils.DateHelper;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.stream.IntStream;
public class PacketTowerAllDataRsp extends BasePacket { public class PacketTowerAllDataRsp extends BasePacket {
public PacketTowerAllDataRsp() { public PacketTowerAllDataRsp(TowerScheduleManager towerScheduleManager, TowerManager towerManager) {
super(PacketOpcodes.TowerAllDataRsp); super(PacketOpcodes.TowerAllDataRsp);
var list = GameData.getTowerFloorDataMap().values().stream() var recordList = towerManager.getRecordMap().values().stream()
.map(TowerFloorData::getFloorId) .map(rec -> TowerFloorRecord.newBuilder()
.map(id -> TowerFloorRecord.newBuilder().setFloorId(id).build()) .setFloorId(rec.getFloorId())
.collect(Collectors.toList()); .setFloorStarRewardProgress(rec.getFloorStarRewardProgress())
.putAllPassedLevelMap(rec.getPassedLevelMap())
.addAllPassedLevelRecordList(buildFromPassedLevelMap(rec.getPassedLevelMap()))
.build()
)
.toList();
var openTimeMap = towerScheduleManager.getScheduleFloors().stream()
.collect(Collectors.toMap(x -> x,
y -> DateHelper.getUnixTime(towerScheduleManager.getTowerScheduleConfig()
.getScheduleStartTime()))
);
TowerAllDataRsp proto = TowerAllDataRsp.newBuilder() TowerAllDataRsp proto = TowerAllDataRsp.newBuilder()
.setTowerScheduleId(29) .setTowerScheduleId(towerScheduleManager.getCurrentTowerScheduleData().getScheduleId())
.addAllTowerFloorRecordList(list) .addAllTowerFloorRecordList(recordList)
.setCurLevelRecord(TowerCurLevelRecord.newBuilder().setIsEmpty(true)) .setCurLevelRecord(TowerCurLevelRecord.newBuilder().setIsEmpty(true))
.setNextScheduleChangeTime(Integer.MAX_VALUE) .setScheduleStartTime(DateHelper.getUnixTime(towerScheduleManager.getTowerScheduleConfig()
.putFloorOpenTimeMap(1024, 1630486800) .getScheduleStartTime()))
.putFloorOpenTimeMap(1025, 1630486800) .setNextScheduleChangeTime(DateHelper.getUnixTime(towerScheduleManager.getTowerScheduleConfig()
.putFloorOpenTimeMap(1026, 1630486800) .getNextScheduleChangeTime()))
.putFloorOpenTimeMap(1027, 1630486800) .putAllFloorOpenTimeMap(openTimeMap)
.setScheduleStartTime(1630486800) .setIsFinishedEntranceFloor(towerManager.canEnterScheduleFloor())
.build(); .build();
this.setData(proto); this.setData(proto);
} }
private List<TowerLevelRecordOuterClass.TowerLevelRecord> buildFromPassedLevelMap(Map<Integer, Integer> map){
return map.entrySet().stream()
.map(item -> TowerLevelRecordOuterClass.TowerLevelRecord.newBuilder()
.setLevelId(item.getKey())
.addAllSatisfiedCondList(IntStream.range(1, item.getValue() + 1).boxed().toList())
.build())
.toList();
}
} }
...@@ -8,13 +8,13 @@ import emu.grasscutter.net.proto.TowerLevelRecordOuterClass.TowerLevelRecord; ...@@ -8,13 +8,13 @@ import emu.grasscutter.net.proto.TowerLevelRecordOuterClass.TowerLevelRecord;
public class PacketTowerFloorRecordChangeNotify extends BasePacket { public class PacketTowerFloorRecordChangeNotify extends BasePacket {
public PacketTowerFloorRecordChangeNotify(int floorId) { public PacketTowerFloorRecordChangeNotify(int floorId, int stars, boolean canEnterScheduleFloor) {
super(PacketOpcodes.TowerFloorRecordChangeNotify); super(PacketOpcodes.TowerFloorRecordChangeNotify);
TowerFloorRecordChangeNotify proto = TowerFloorRecordChangeNotify.newBuilder() TowerFloorRecordChangeNotify proto = TowerFloorRecordChangeNotify.newBuilder()
.addTowerFloorRecordList(TowerFloorRecord.newBuilder() .addTowerFloorRecordList(TowerFloorRecord.newBuilder()
.setFloorId(floorId) .setFloorId(floorId)
.setFloorStarRewardProgress(3) .setFloorStarRewardProgress(stars)
.addPassedLevelRecordList(TowerLevelRecord.newBuilder() .addPassedLevelRecordList(TowerLevelRecord.newBuilder()
.setLevelId(1) .setLevelId(1)
.addSatisfiedCondList(1) .addSatisfiedCondList(1)
...@@ -22,7 +22,7 @@ public class PacketTowerFloorRecordChangeNotify extends BasePacket { ...@@ -22,7 +22,7 @@ public class PacketTowerFloorRecordChangeNotify extends BasePacket {
.addSatisfiedCondList(3) .addSatisfiedCondList(3)
.build()) .build())
.build()) .build())
.setIsFinishedEntranceFloor(true) .setIsFinishedEntranceFloor(canEnterScheduleFloor)
.build(); .build();
this.setData(proto); this.setData(proto);
......
package emu.grasscutter.server.packet.send;
import emu.grasscutter.net.packet.BasePacket;
import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.proto.TowerLevelStarCondDataOuterClass.TowerLevelStarCondData;
import emu.grasscutter.net.proto.TowerLevelStarCondNotifyOuterClass.TowerLevelStarCondNotify;
public class PacketTowerLevelStarCondNotify extends BasePacket {
public PacketTowerLevelStarCondNotify(int floorId, int levelIndex) {
super(PacketOpcodes.TowerLevelStarCondNotify);
TowerLevelStarCondNotify proto = TowerLevelStarCondNotify.newBuilder()
.setFloorId(floorId)
.setLevelIndex(levelIndex)
.addCondDataList(TowerLevelStarCondData.newBuilder()
.setCondValue(1)
.build()
)
.addCondDataList(TowerLevelStarCondData.newBuilder()
.setCondValue(2)
.build()
)
.addCondDataList(TowerLevelStarCondData.newBuilder()
.setCondValue(3)
.build()
)
.build();
this.setData(proto);
}
}
package emu.grasscutter.server.packet.send;
import emu.grasscutter.net.packet.BasePacket;
import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.proto.TowerMiddleLevelChangeTeamNotifyOuterClass;
public class PacketTowerMiddleLevelChangeTeamNotify extends BasePacket {
public PacketTowerMiddleLevelChangeTeamNotify() {
super(PacketOpcodes.TowerMiddleLevelChangeTeamNotify);
TowerMiddleLevelChangeTeamNotifyOuterClass.TowerMiddleLevelChangeTeamNotify proto =
TowerMiddleLevelChangeTeamNotifyOuterClass.TowerMiddleLevelChangeTeamNotify.newBuilder()
.build();
this.setData(proto);
}
}
package emu.grasscutter.server.packet.send;
import emu.grasscutter.net.packet.BasePacket;
import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.proto.RetcodeOuterClass;
import emu.grasscutter.net.proto.TryEnterHomeRspOuterClass;
public class PacketTryEnterHomeRsp extends BasePacket {
public PacketTryEnterHomeRsp() {
super(PacketOpcodes.TryEnterHomeRsp);
TryEnterHomeRspOuterClass.TryEnterHomeRsp proto = TryEnterHomeRspOuterClass.TryEnterHomeRsp.newBuilder()
.setRetcode(RetcodeOuterClass.Retcode.RET_SVR_ERROR_VALUE)
.build();
this.setData(proto);
}
public PacketTryEnterHomeRsp(int uid) {
super(PacketOpcodes.TryEnterHomeRsp);
TryEnterHomeRspOuterClass.TryEnterHomeRsp proto = TryEnterHomeRspOuterClass.TryEnterHomeRsp.newBuilder()
.setRetcode(0)
.setTargetUid(uid)
.build();
this.setData(proto);
}
}
...@@ -31,10 +31,10 @@ public class PacketVehicleInteractRsp extends BasePacket { ...@@ -31,10 +31,10 @@ public class PacketVehicleInteractRsp extends BasePacket {
proto.setMember(vehicleMember); proto.setMember(vehicleMember);
switch(interactType){ switch(interactType){
case VEHICLE_INTERACT_IN -> { case VEHICLE_INTERACT_TYPE_IN -> {
((EntityVehicle) vehicle).getVehicleMembers().add(vehicleMember); ((EntityVehicle) vehicle).getVehicleMembers().add(vehicleMember);
} }
case VEHICLE_INTERACT_OUT -> { case VEHICLE_INTERACT_TYPE_OUT -> {
((EntityVehicle) vehicle).getVehicleMembers().remove(vehicleMember); ((EntityVehicle) vehicle).getVehicleMembers().remove(vehicleMember);
} }
default -> {} default -> {}
...@@ -53,10 +53,10 @@ public class PacketVehicleInteractRsp extends BasePacket { ...@@ -53,10 +53,10 @@ public class PacketVehicleInteractRsp extends BasePacket {
proto.setMember(vehicleMember); proto.setMember(vehicleMember);
switch(interactType){ switch(interactType){
case VEHICLE_INTERACT_IN -> { case VEHICLE_INTERACT_TYPE_IN -> {
vehicle.getVehicleMembers().add(vehicleMember); vehicle.getVehicleMembers().add(vehicleMember);
} }
case VEHICLE_INTERACT_OUT -> { case VEHICLE_INTERACT_TYPE_OUT -> {
vehicle.getVehicleMembers().remove(vehicleMember); vehicle.getVehicleMembers().remove(vehicleMember);
} }
default -> {} default -> {}
......
package emu.grasscutter.server.packet.send;
import emu.grasscutter.net.packet.BasePacket;
import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.proto.VehicleStaminaNotifyOuterClass.VehicleStaminaNotify;
public class PacketVehicleStaminaNotify extends BasePacket {
public PacketVehicleStaminaNotify(int vehicleId, float newStamina) {
super(PacketOpcodes.VehicleStaminaNotify);
VehicleStaminaNotify.Builder proto = VehicleStaminaNotify.newBuilder();
proto.setEntityId(vehicleId);
proto.setCurStamina(newStamina);
this.setData(proto.build());
}
}
package emu.grasscutter.server.packet.send;
import emu.grasscutter.net.packet.BasePacket;
import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.proto.WidgetCoolDownDataOuterClass;
import emu.grasscutter.net.proto.WidgetCoolDownNotifyOuterClass;
public class PacketWidgetCoolDownNotify extends BasePacket {
public PacketWidgetCoolDownNotify(int id, long coolDownTime, boolean isSuccess) {
super(PacketOpcodes.WidgetCoolDownNotify);
WidgetCoolDownNotifyOuterClass.WidgetCoolDownNotify proto = WidgetCoolDownNotifyOuterClass.WidgetCoolDownNotify.newBuilder()
.addGroupCoolDownDataList(
WidgetCoolDownDataOuterClass.WidgetCoolDownData.newBuilder()
.setId(id)
.setCoolDownTime(coolDownTime)
.setIsSuccess(isSuccess)
.build()
)
.build();
this.setData(proto);
}
}
package emu.grasscutter.server.packet.send;
import emu.grasscutter.net.packet.BasePacket;
import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.proto.WidgetDoBagRspOuterClass;
public class PacketWidgetDoBagRsp extends BasePacket {
public PacketWidgetDoBagRsp(int materialId) {
super(PacketOpcodes.WidgetDoBagRsp);
WidgetDoBagRspOuterClass.WidgetDoBagRsp proto = WidgetDoBagRspOuterClass.WidgetDoBagRsp.newBuilder()
.setMaterialId(materialId)
.setRetcode(0)
.build();
this.setData(proto);
}
public PacketWidgetDoBagRsp() {
super(PacketOpcodes.WidgetDoBagRsp);
WidgetDoBagRspOuterClass.WidgetDoBagRsp proto = WidgetDoBagRspOuterClass.WidgetDoBagRsp.newBuilder()
.build();
this.setData(proto);
}
}
package emu.grasscutter.server.packet.send;
import emu.grasscutter.net.packet.BasePacket;
import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.proto.WidgetGadgetAllDataNotifyOuterClass.WidgetGadgetAllDataNotify;
public class PacketWidgetGadgetAllDataNotify extends BasePacket {
public PacketWidgetGadgetAllDataNotify() {
super(PacketOpcodes.AllWidgetDataNotify);
WidgetGadgetAllDataNotify proto = WidgetGadgetAllDataNotify.newBuilder().build();
this.setData(proto);
}
}
package emu.grasscutter.server.packet.send;
import emu.grasscutter.net.packet.BasePacket;
import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.proto.WidgetGadgetDataNotifyOuterClass;
import emu.grasscutter.net.proto.WidgetGadgetDataOuterClass;
import java.io.IOException;
import java.util.List;
public class PacketWidgetGadgetDataNotify extends BasePacket {
public PacketWidgetGadgetDataNotify(int gadgetId, List<Integer> gadgetEntityIdList) throws IOException {
super(PacketOpcodes.WidgetGadgetDataNotify);
WidgetGadgetDataNotifyOuterClass.WidgetGadgetDataNotify proto = WidgetGadgetDataNotifyOuterClass.WidgetGadgetDataNotify.newBuilder()
.setWidgetGadgetData(
WidgetGadgetDataOuterClass.WidgetGadgetData.newBuilder()
.setGadgetId(gadgetId)
.addAllGadgetEntityIdList(gadgetEntityIdList)
.build()
)
.build();
this.setData(proto);
}
}
package emu.grasscutter.server.packet.send;
import emu.grasscutter.net.packet.BasePacket;
import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.proto.WidgetSlotChangeNotifyOuterClass;
import emu.grasscutter.net.proto.WidgetSlotDataOuterClass;
import emu.grasscutter.net.proto.WidgetSlotOpOuterClass;
public class PacketWidgetSlotChangeNotify extends BasePacket {
public PacketWidgetSlotChangeNotify(WidgetSlotChangeNotifyOuterClass.WidgetSlotChangeNotify proto) {
super(PacketOpcodes.WidgetSlotChangeNotify);
this.setData(proto);
}
public PacketWidgetSlotChangeNotify(WidgetSlotOpOuterClass.WidgetSlotOp op) {
super(PacketOpcodes.WidgetSlotChangeNotify);
WidgetSlotChangeNotifyOuterClass.WidgetSlotChangeNotify proto = WidgetSlotChangeNotifyOuterClass.WidgetSlotChangeNotify.newBuilder()
.setOp(op)
.setSlot(
WidgetSlotDataOuterClass.WidgetSlotData.newBuilder()
.setIsActive(true)
.build()
)
.build();
this.setData(proto);
}
public PacketWidgetSlotChangeNotify(int materialId) {
super(PacketOpcodes.WidgetSlotChangeNotify);
WidgetSlotChangeNotifyOuterClass.WidgetSlotChangeNotify proto = WidgetSlotChangeNotifyOuterClass.WidgetSlotChangeNotify.newBuilder()
.setSlot(
WidgetSlotDataOuterClass.WidgetSlotData.newBuilder()
.setIsActive(true)
.setMaterialId(materialId)
.build()
)
.build();
this.setData(proto);
}
}
package emu.grasscutter.task; package emu.grasscutter.task;
import org.quartz.JobDataMap;
import java.lang.annotation.Retention; import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy; import java.lang.annotation.RetentionPolicy;
......
...@@ -67,6 +67,40 @@ public final class TaskMap { ...@@ -67,6 +67,40 @@ public final class TaskMap {
return this; return this;
} }
public boolean pauseTask(String taskName) {
try {
Scheduler scheduler = schedulerFactory.getScheduler();
scheduler.pauseJob(new JobKey(taskName));
} catch (SchedulerException e) {
e.printStackTrace();
return false;
}
return true;
}
public boolean resumeTask(String taskName) {
try {
Scheduler scheduler = schedulerFactory.getScheduler();
scheduler.resumeJob(new JobKey(taskName));
} catch (SchedulerException e) {
e.printStackTrace();
return false;
}
return true;
}
public boolean cancelTask(String taskName) {
Task task = this.annotations.get(taskName);
if (task == null) return false;
try {
this.unregisterTask(this.tasks.get(taskName));
} catch (Exception e) {
e.printStackTrace();
return false;
}
return true;
}
public TaskMap registerTask(String taskName, TaskHandler task) { public TaskMap registerTask(String taskName, TaskHandler task) {
Task annotation = task.getClass().getAnnotation(Task.class); Task annotation = task.getClass().getAnnotation(Task.class);
this.annotations.put(taskName, annotation); this.annotations.put(taskName, annotation);
...@@ -116,7 +150,7 @@ public final class TaskMap { ...@@ -116,7 +150,7 @@ public final class TaskMap {
classes.forEach(annotated -> { classes.forEach(annotated -> {
try { try {
Task taskData = annotated.getAnnotation(Task.class); Task taskData = annotated.getAnnotation(Task.class);
Object object = annotated.newInstance(); Object object = annotated.getDeclaredConstructor().newInstance();
if (object instanceof TaskHandler) { if (object instanceof TaskHandler) {
this.registerTask(taskData.taskName(), (TaskHandler) object); this.registerTask(taskData.taskName(), (TaskHandler) object);
if (taskData.executeImmediatelyAfterReset()) { if (taskData.executeImmediatelyAfterReset()) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment