mirror of
https://github.com/Grasscutters/Grasscutter.git
synced 2025-12-16 08:56:04 +01:00
Fix whitespace [skip actions]
This commit is contained in:
@@ -17,81 +17,81 @@ import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public class QuestSystem extends BaseGameSystem {
|
||||
private final Int2ObjectMap<QuestBaseHandler> condHandlers;
|
||||
private final Int2ObjectMap<QuestBaseHandler> contHandlers;
|
||||
private final Int2ObjectMap<QuestExecHandler> execHandlers;
|
||||
private final Int2ObjectMap<QuestBaseHandler> condHandlers;
|
||||
private final Int2ObjectMap<QuestBaseHandler> contHandlers;
|
||||
private final Int2ObjectMap<QuestExecHandler> execHandlers;
|
||||
|
||||
public QuestSystem(GameServer server) {
|
||||
super(server);
|
||||
|
||||
this.condHandlers = new Int2ObjectOpenHashMap<>();
|
||||
this.contHandlers = new Int2ObjectOpenHashMap<>();
|
||||
this.execHandlers = new Int2ObjectOpenHashMap<>();
|
||||
public QuestSystem(GameServer server) {
|
||||
super(server);
|
||||
|
||||
this.registerHandlers();
|
||||
}
|
||||
this.condHandlers = new Int2ObjectOpenHashMap<>();
|
||||
this.contHandlers = new Int2ObjectOpenHashMap<>();
|
||||
this.execHandlers = new Int2ObjectOpenHashMap<>();
|
||||
|
||||
public void registerHandlers() {
|
||||
this.registerHandlers(this.condHandlers, "emu.grasscutter.game.quest.conditions", QuestBaseHandler.class);
|
||||
this.registerHandlers(this.contHandlers, "emu.grasscutter.game.quest.content", QuestBaseHandler.class);
|
||||
this.registerHandlers(this.execHandlers, "emu.grasscutter.game.quest.exec", QuestExecHandler.class);
|
||||
}
|
||||
this.registerHandlers();
|
||||
}
|
||||
|
||||
public <T> void registerHandlers(Int2ObjectMap<T> map, String packageName, Class<T> clazz) {
|
||||
Reflections reflections = new Reflections(packageName);
|
||||
var handlerClasses = reflections.getSubTypesOf(clazz);
|
||||
public void registerHandlers() {
|
||||
this.registerHandlers(this.condHandlers, "emu.grasscutter.game.quest.conditions", QuestBaseHandler.class);
|
||||
this.registerHandlers(this.contHandlers, "emu.grasscutter.game.quest.content", QuestBaseHandler.class);
|
||||
this.registerHandlers(this.execHandlers, "emu.grasscutter.game.quest.exec", QuestExecHandler.class);
|
||||
}
|
||||
|
||||
for (var obj : handlerClasses) {
|
||||
this.registerPacketHandler(map, obj);
|
||||
}
|
||||
}
|
||||
public <T> void registerHandlers(Int2ObjectMap<T> map, String packageName, Class<T> clazz) {
|
||||
Reflections reflections = new Reflections(packageName);
|
||||
var handlerClasses = reflections.getSubTypesOf(clazz);
|
||||
|
||||
public <T> void registerPacketHandler(Int2ObjectMap<T> map, Class<? extends T> handlerClass) {
|
||||
try {
|
||||
QuestValue opcode = handlerClass.getAnnotation(QuestValue.class);
|
||||
for (var obj : handlerClasses) {
|
||||
this.registerPacketHandler(map, obj);
|
||||
}
|
||||
}
|
||||
|
||||
if (opcode == null || opcode.value().getValue() <= 0) {
|
||||
return;
|
||||
}
|
||||
public <T> void registerPacketHandler(Int2ObjectMap<T> map, Class<? extends T> handlerClass) {
|
||||
try {
|
||||
QuestValue opcode = handlerClass.getAnnotation(QuestValue.class);
|
||||
|
||||
map.put(opcode.value().getValue(), handlerClass.newInstance());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
if (opcode == null || opcode.value().getValue() <= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
// TODO make cleaner
|
||||
map.put(opcode.value().getValue(), handlerClass.newInstance());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean triggerCondition(GameQuest quest, QuestCondition condition, String paramStr, int... params) {
|
||||
QuestBaseHandler handler = condHandlers.get(condition.getType().getValue());
|
||||
// TODO make cleaner
|
||||
|
||||
if (handler == null || quest.getData() == null) {
|
||||
public boolean triggerCondition(GameQuest quest, QuestCondition condition, String paramStr, int... params) {
|
||||
QuestBaseHandler handler = condHandlers.get(condition.getType().getValue());
|
||||
|
||||
if (handler == null || quest.getData() == null) {
|
||||
Grasscutter.getLogger().debug("Could not trigger condition {} at {}", condition.getType().getValue(), quest.getData());
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
return handler.execute(quest, condition, paramStr, params);
|
||||
}
|
||||
return handler.execute(quest, condition, paramStr, params);
|
||||
}
|
||||
|
||||
public boolean triggerContent(GameQuest quest, QuestCondition condition, String paramStr, int... params) {
|
||||
QuestBaseHandler handler = contHandlers.get(condition.getType().getValue());
|
||||
public boolean triggerContent(GameQuest quest, QuestCondition condition, String paramStr, int... params) {
|
||||
QuestBaseHandler handler = contHandlers.get(condition.getType().getValue());
|
||||
|
||||
if (handler == null || quest.getData() == null) {
|
||||
if (handler == null || quest.getData() == null) {
|
||||
Grasscutter.getLogger().debug("Could not trigger content {} at {}", condition.getType().getValue(), quest.getData());
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
return handler.execute(quest, condition, paramStr, params);
|
||||
}
|
||||
return handler.execute(quest, condition, paramStr, params);
|
||||
}
|
||||
|
||||
public boolean triggerExec(GameQuest quest, QuestExecParam execParam, String... params) {
|
||||
QuestExecHandler handler = execHandlers.get(execParam.getType().getValue());
|
||||
public boolean triggerExec(GameQuest quest, QuestExecParam execParam, String... params) {
|
||||
QuestExecHandler handler = execHandlers.get(execParam.getType().getValue());
|
||||
|
||||
if (handler == null || quest.getData() == null) {
|
||||
if (handler == null || quest.getData() == null) {
|
||||
Grasscutter.getLogger().debug("Could not trigger exec {} at {}", execParam.getType().getValue(), quest.getData());
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
return handler.execute(quest, execParam, params);
|
||||
}
|
||||
return handler.execute(quest, execParam, params);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user