Commit 45b45c4b authored by Akka's avatar Akka
Browse files

Merge remote-tracking branch 'fork/tower' into tower

parents 722e710c 47ea4660
......@@ -74,14 +74,6 @@ public class HandlerCombatInvocationsNotify extends PacketHandler {
session.getPlayer().getCombatInvokeHandler().addEntry(entry.getForwardType(), entry);
}
if (notif.getInvokeListList().size() > 0) {
session.getPlayer().getCombatInvokeHandler().update(session.getPlayer());
}
// Handle attack results last
while (!session.getPlayer().getAttackResults().isEmpty()) {
session.getPlayer().getScene().handleAttack(session.getPlayer().getAttackResults().poll());
}
}
private void handleFallOnGround(GameSession session, GameEntity entity, MotionState motionState) {
......
......@@ -14,11 +14,6 @@ public class HandlerEvtCreateGadgetNotify extends PacketHandler {
public void handle(GameSession session, byte[] header, byte[] payload) throws Exception {
EvtCreateGadgetNotify notify = EvtCreateGadgetNotify.parseFrom(payload);
// Dont handle in singleplayer
if (!session.getPlayer().getWorld().isMultiplayer()) {
return;
}
// Sanity check - dont add duplicate entities
if (session.getPlayer().getScene().getEntityById(notify.getEntityId()) != null) {
return;
......
......@@ -12,11 +12,6 @@ public class HandlerEvtDestroyGadgetNotify extends PacketHandler {
@Override
public void handle(GameSession session, byte[] header, byte[] payload) throws Exception {
EvtDestroyGadgetNotify notify = EvtDestroyGadgetNotify.parseFrom(payload);
// Dont handle in singleplayer
if (!session.getPlayer().getWorld().isMultiplayer()) {
return;
}
session.getPlayer().getScene().onPlayerDestroyGadget(notify.getEntityId());
}
......
......@@ -23,7 +23,7 @@ public class HandlerSetEntityClientDataNotify extends PacketHandler {
BasePacket packet = new BasePacket(PacketOpcodes.SetEntityClientDataNotify, true);
packet.setData(notif);
session.getPlayer().getScene().broadcastPacketToOthers(session.getPlayer(), packet);
session.getPlayer().getScene().broadcastPacket(packet);
}
}
......@@ -62,7 +62,7 @@ public class HandlerSetPlayerBornDataReq extends PacketHandler {
// Create avatar
if (player.getAvatars().getAvatarCount() == 0) {
Avatar mainCharacter = new Avatar(avatarId);
mainCharacter.setSkillDepot(GameData.getAvatarSkillDepotDataMap().get(startingSkillDepot));
mainCharacter.setSkillDepotData(GameData.getAvatarSkillDepotDataMap().get(startingSkillDepot));
player.addAvatar(mainCharacter);
player.setMainCharacterId(avatarId);
player.setHeadImage(avatarId);
......
......@@ -15,5 +15,14 @@ public class HandlerUnionCmdNotify extends PacketHandler {
for (UnionCmd cmd : req.getCmdListList()) {
session.getServer().getPacketHandler().handle(session, cmd.getMessageId(), EMPTY_BYTE_ARRAY, cmd.getBody().toByteArray());
}
// Update
session.getPlayer().getCombatInvokeHandler().update(session.getPlayer());
session.getPlayer().getAbilityInvokeHandler().update(session.getPlayer());
// Handle attack results last
while (!session.getPlayer().getAttackResults().isEmpty()) {
session.getPlayer().getScene().handleAttack(session.getPlayer().getAttackResults().poll());
}
}
}
......@@ -11,21 +11,27 @@ import emu.grasscutter.net.proto.PropChangeReasonOuterClass.PropChangeReason;
import java.util.List;
public class PacketEntityFightPropChangeReasonNotify extends BasePacket {
public PacketEntityFightPropChangeReasonNotify(GameEntity entity, FightProperty prop, Float value, List<Integer> param, PropChangeReason reason, ChangeHpReason changeHpReason) {
super(PacketOpcodes.EntityFightPropChangeReasonNotify);
EntityFightPropChangeReasonNotify.Builder proto = EntityFightPropChangeReasonNotify.newBuilder()
.setEntityId(entity.getId())
.setPropType(prop.getId())
.setPropDelta(value)
.setReason(reason)
.setChangeHpReason(changeHpReason);
for(int p: param){
for(int p : param){
proto.addParamList(p);
}
this.setData(proto);
}
public PacketEntityFightPropChangeReasonNotify(GameEntity entity, FightProperty prop, Float value, PropChangeReason reason, ChangeHpReason changeHpReason) {
super(PacketOpcodes.EntityFightPropChangeReasonNotify);
EntityFightPropChangeReasonNotify proto = EntityFightPropChangeReasonNotify.newBuilder()
.setEntityId(entity.getId())
.setPropType(prop.getId())
......@@ -33,6 +39,20 @@ public class PacketEntityFightPropChangeReasonNotify extends BasePacket {
.setReason(reason)
.setChangeHpReason(changeHpReason)
.build();
this.setData(proto);
}
public PacketEntityFightPropChangeReasonNotify(GameEntity entity, FightProperty prop, Float value, PropChangeReason reason) {
super(PacketOpcodes.EntityFightPropChangeReasonNotify);
EntityFightPropChangeReasonNotify proto = EntityFightPropChangeReasonNotify.newBuilder()
.setEntityId(entity.getId())
.setPropType(prop.getId())
.setPropDelta(value)
.setReason(reason)
.build();
this.setData(proto);
}
}
package emu.grasscutter.task;
import org.quartz.JobDataMap;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
......
......@@ -67,6 +67,40 @@ public final class TaskMap {
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) {
Task annotation = task.getClass().getAnnotation(Task.class);
this.annotations.put(taskName, annotation);
......@@ -116,7 +150,7 @@ public final class TaskMap {
classes.forEach(annotated -> {
try {
Task taskData = annotated.getAnnotation(Task.class);
Object object = annotated.newInstance();
Object object = annotated.getDeclaredConstructor().newInstance();
if (object instanceof TaskHandler) {
this.registerTask(taskData.taskName(), (TaskHandler) object);
if (taskData.executeImmediatelyAfterReset()) {
......
......@@ -19,7 +19,7 @@ public final class Language {
* @return A language instance.
*/
public static Language getLanguage(String langCode) {
return new Language(langCode + ".json", Grasscutter.getConfig().DefaultLanguage.toLanguageTag());
return new Language(langCode + ".json", Grasscutter.getConfig().DefaultLanguage.toLanguageTag() + ".json");
}
/**
......@@ -46,15 +46,20 @@ public final class Language {
private Language(String fileName, String fallback) {
@Nullable JsonObject languageData = null;
InputStream file = Grasscutter.class.getResourceAsStream("/languages/" + fileName);
if (file == null) { // Provided fallback language.
file = Grasscutter.class.getResourceAsStream("/languages/" + fallback);
Grasscutter.getLogger().warn("Failed to load language file: " + fileName + ", falling back to: " + fallback);
}
if(file == null) { // Fallback the fallback language.
file = Grasscutter.class.getResourceAsStream("/languages/en-US.json");
Grasscutter.getLogger().warn("Failed to load language file: " + fallback + ", falling back to: en-US.json");
}
if(file == null)
throw new RuntimeException("Unable to load the primary, fallback, and 'en-US' language files.");
try {
InputStream file = Grasscutter.class.getResourceAsStream("/languages/" + fileName);
String translationContents = Utils.readFromInputStream(file);
if(translationContents.equals("empty")) {
file = Grasscutter.class.getResourceAsStream("/languages/" + fallback);
translationContents = Utils.readFromInputStream(file);
}
languageData = Grasscutter.getGsonFactory().fromJson(translationContents, JsonObject.class);
languageData = Grasscutter.getGsonFactory().fromJson(Utils.readFromInputStream(file), JsonObject.class);
} catch (Exception exception) {
Grasscutter.getLogger().warn("Failed to load language file: " + fileName, exception);
}
......
......@@ -36,7 +36,7 @@
}
},
"status": {
"free_software": "Grasscutter 是免费开源软件,遵循Apache-2.0 license。如果您是付费购买的,那您已经被骗了。项目地址:Github:https://github.com/Grasscutters/Grasscutter",
"free_software": "Grasscutter 是免费开源软件,遵循AGPL-3.0 license。如果您是付费购买的,那您已经被骗了。项目地址:Github:https://github.com/Grasscutters/Grasscutter",
"starting": "正在启动 Grasscutter...",
"shutdown": "正在关闭...",
"done": "加载完成!输入 \"help\" 查看命令列表",
......
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