mirror of
https://github.com/Grasscutters/Grasscutter.git
synced 2026-05-20 19:59:57 +08:00
Run IntelliJ IDEA code formatter
This commit is contained in:
@@ -13,7 +13,6 @@ import lombok.ToString;
|
||||
import javax.script.Bindings;
|
||||
import javax.script.CompiledScript;
|
||||
import javax.script.ScriptException;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@@ -25,7 +24,7 @@ public class SceneBlock {
|
||||
public Position min;
|
||||
|
||||
public int sceneId;
|
||||
public Map<Integer,SceneGroup> groups;
|
||||
public Map<Integer, SceneGroup> groups;
|
||||
public RTree<SceneGroup, Geometry> sceneGroupIndex;
|
||||
|
||||
private transient boolean loaded; // Not an actual variable in the scripts either
|
||||
@@ -39,8 +38,8 @@ public class SceneBlock {
|
||||
}
|
||||
|
||||
public boolean contains(Position pos) {
|
||||
return pos.getX() <= this.max.getX() && pos.getX() >= this.min.getX() &&
|
||||
pos.getZ() <= this.max.getZ() && pos.getZ() >= this.min.getZ();
|
||||
return pos.getX() <= this.max.getX() && pos.getX() >= this.min.getX() &&
|
||||
pos.getZ() <= this.max.getZ() && pos.getZ() >= this.min.getZ();
|
||||
}
|
||||
|
||||
public SceneBlock load(int sceneId, Bindings bindings) {
|
||||
@@ -62,7 +61,7 @@ public class SceneBlock {
|
||||
|
||||
// Set groups
|
||||
this.groups = ScriptLoader.getSerializer().toList(SceneGroup.class, bindings.get("groups")).stream()
|
||||
.collect(Collectors.toMap(x -> x.id, y -> y, (a, b) -> a));
|
||||
.collect(Collectors.toMap(x -> x.id, y -> y, (a, b) -> a));
|
||||
|
||||
this.groups.values().forEach(g -> g.block_id = this.id);
|
||||
this.sceneGroupIndex = SceneIndexManager.buildIndex(3, this.groups.values(), g -> g.pos.toPoint());
|
||||
|
||||
@@ -6,5 +6,5 @@ import lombok.ToString;
|
||||
@ToString
|
||||
@Setter
|
||||
public class SceneBusiness {
|
||||
public int type;
|
||||
public int type;
|
||||
}
|
||||
|
||||
@@ -7,9 +7,9 @@ import lombok.ToString;
|
||||
@ToString
|
||||
@Setter
|
||||
public class SceneConfig {
|
||||
public Position vision_anchor;
|
||||
public Position born_pos;
|
||||
public Position born_rot;
|
||||
public Position begin_pos;
|
||||
public Position size;
|
||||
public Position vision_anchor;
|
||||
public Position born_pos;
|
||||
public Position born_rot;
|
||||
public Position begin_pos;
|
||||
public Position size;
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ import lombok.ToString;
|
||||
|
||||
@ToString
|
||||
@Setter
|
||||
public class SceneGadget extends SceneObject{
|
||||
public class SceneGadget extends SceneObject {
|
||||
public int gadget_id;
|
||||
public int state;
|
||||
public int point_type;
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
package emu.grasscutter.scripts.data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@ToString
|
||||
@Setter
|
||||
public class SceneGarbage {
|
||||
public List<SceneGadget> gadgets;
|
||||
public List<SceneGadget> gadgets;
|
||||
}
|
||||
|
||||
@@ -10,7 +10,6 @@ import org.luaj.vm2.LuaValue;
|
||||
import javax.script.Bindings;
|
||||
import javax.script.CompiledScript;
|
||||
import javax.script.ScriptException;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
@@ -25,7 +24,7 @@ public class SceneGroup {
|
||||
public int refresh_id;
|
||||
public Position pos;
|
||||
|
||||
public Map<Integer,SceneMonster> monsters; // <ConfigId, Monster>
|
||||
public Map<Integer, SceneMonster> monsters; // <ConfigId, Monster>
|
||||
public Map<Integer, SceneGadget> gadgets; // <ConfigId, Gadgets>
|
||||
public Map<String, SceneTrigger> triggers;
|
||||
public Map<Integer, SceneRegion> regions;
|
||||
@@ -39,6 +38,7 @@ public class SceneGroup {
|
||||
private transient boolean loaded; // Not an actual variable in the scripts either
|
||||
private transient CompiledScript script;
|
||||
private transient Bindings bindings;
|
||||
|
||||
public static SceneGroup of(int groupId) {
|
||||
var group = new SceneGroup();
|
||||
group.id = groupId;
|
||||
@@ -96,15 +96,15 @@ public class SceneGroup {
|
||||
|
||||
// Set
|
||||
this.monsters = ScriptLoader.getSerializer().toList(SceneMonster.class, this.bindings.get("monsters")).stream()
|
||||
.collect(Collectors.toMap(x -> x.config_id, y -> y, (a, b) -> a));
|
||||
.collect(Collectors.toMap(x -> x.config_id, y -> y, (a, b) -> a));
|
||||
this.monsters.values().forEach(m -> m.group = this);
|
||||
|
||||
this.gadgets = ScriptLoader.getSerializer().toList(SceneGadget.class, this.bindings.get("gadgets")).stream()
|
||||
.collect(Collectors.toMap(x -> x.config_id, y -> y, (a, b) -> a));
|
||||
.collect(Collectors.toMap(x -> x.config_id, y -> y, (a, b) -> a));
|
||||
this.gadgets.values().forEach(m -> m.group = this);
|
||||
|
||||
this.triggers = ScriptLoader.getSerializer().toList(SceneTrigger.class, this.bindings.get("triggers")).stream()
|
||||
.collect(Collectors.toMap(x -> x.name, y -> y, (a, b) -> a));
|
||||
.collect(Collectors.toMap(x -> x.name, y -> y, (a, b) -> a));
|
||||
this.triggers.values().forEach(t -> t.currentGroup = this);
|
||||
|
||||
this.suites = ScriptLoader.getSerializer().toList(SceneSuite.class, this.bindings.get("suites"));
|
||||
@@ -140,9 +140,9 @@ public class SceneGroup {
|
||||
|
||||
public Optional<SceneBossChest> searchBossChestInGroup() {
|
||||
return this.gadgets.values().stream()
|
||||
.filter(g -> g.boss_chest != null && g.boss_chest.monster_config_id > 0)
|
||||
.map(g -> g.boss_chest)
|
||||
.findFirst();
|
||||
.filter(g -> g.boss_chest != null && g.boss_chest.monster_config_id > 0)
|
||||
.map(g -> g.boss_chest)
|
||||
.findFirst();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ import lombok.ToString;
|
||||
@ToString
|
||||
@Setter
|
||||
public class SceneInitConfig {
|
||||
public int suite;
|
||||
public int end_suite;
|
||||
public boolean rand_suite;
|
||||
public int suite;
|
||||
public int end_suite;
|
||||
public boolean rand_suite;
|
||||
}
|
||||
|
||||
@@ -11,7 +11,6 @@ import lombok.ToString;
|
||||
import javax.script.Bindings;
|
||||
import javax.script.CompiledScript;
|
||||
import javax.script.ScriptException;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@@ -5,10 +5,10 @@ import lombok.ToString;
|
||||
|
||||
@ToString
|
||||
@Setter
|
||||
public class SceneMonster extends SceneObject{
|
||||
public int monster_id;
|
||||
public int pose_id;
|
||||
public int drop_id;
|
||||
public class SceneMonster extends SceneObject {
|
||||
public int monster_id;
|
||||
public int pose_id;
|
||||
public int drop_id;
|
||||
public int special_name_id;
|
||||
public String drop_tag;
|
||||
public int climate_area_id;
|
||||
|
||||
@@ -5,6 +5,6 @@ import lombok.ToString;
|
||||
|
||||
@ToString
|
||||
@Setter
|
||||
public class SceneNPC extends SceneObject{
|
||||
public int npc_id;
|
||||
}
|
||||
public class SceneNPC extends SceneObject {
|
||||
public int npc_id;
|
||||
}
|
||||
|
||||
@@ -21,18 +21,19 @@ public class SceneRegion {
|
||||
public List<Position> point_array;
|
||||
|
||||
public transient SceneGroup group;
|
||||
|
||||
public boolean contains(Position position) {
|
||||
switch (shape) {
|
||||
case ScriptRegionShape.CUBIC:
|
||||
return (Math.abs(pos.getX() - position.getX()) <= size.getX()) &&
|
||||
(Math.abs(pos.getY() - position.getY()) <= size.getY()) &&
|
||||
(Math.abs(pos.getZ() - position.getZ()) <= size.getZ());
|
||||
(Math.abs(pos.getY() - position.getY()) <= size.getY()) &&
|
||||
(Math.abs(pos.getZ() - position.getZ()) <= size.getZ());
|
||||
case ScriptRegionShape.SPHERE:
|
||||
var x = Math.pow(pos.getX() - position.getX(), 2);
|
||||
var y = Math.pow(pos.getY() - position.getY(), 2);
|
||||
var z = Math.pow(pos.getZ() - position.getZ(), 2);
|
||||
// ^ means XOR in java!
|
||||
return x + y + z <= (radius*radius);
|
||||
return x + y + z <= (radius * radius);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1,29 +1,29 @@
|
||||
package emu.grasscutter.scripts.data;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@ToString
|
||||
@Setter
|
||||
public class SceneSuite {
|
||||
// make it refer the default empty list to avoid NPE caused by some group
|
||||
public List<Integer> monsters = List.of();
|
||||
public List<Integer> gadgets = List.of();
|
||||
public List<String> triggers = List.of();
|
||||
public List<Integer> monsters = List.of();
|
||||
public List<Integer> gadgets = List.of();
|
||||
public List<String> triggers = List.of();
|
||||
public List<Integer> regions = List.of();
|
||||
public int rand_weight;
|
||||
public int[] npcs;
|
||||
|
||||
public transient List<SceneMonster> sceneMonsters = List.of();
|
||||
public transient List<SceneGadget> sceneGadgets = List.of();
|
||||
public transient List<SceneTrigger> sceneTriggers = List.of();
|
||||
public transient List<SceneMonster> sceneMonsters = List.of();
|
||||
public transient List<SceneGadget> sceneGadgets = List.of();
|
||||
public transient List<SceneTrigger> sceneTriggers = List.of();
|
||||
public transient List<SceneRegion> sceneRegions = List.of();
|
||||
|
||||
public void init(SceneGroup sceneGroup) {
|
||||
if(sceneGroup.monsters != null && this.monsters != null){
|
||||
if (sceneGroup.monsters != null && this.monsters != null) {
|
||||
this.sceneMonsters = new ArrayList<>(
|
||||
this.monsters.stream()
|
||||
.filter(sceneGroup.monsters::containsKey)
|
||||
@@ -32,7 +32,7 @@ public class SceneSuite {
|
||||
);
|
||||
}
|
||||
|
||||
if(sceneGroup.gadgets != null && this.gadgets != null){
|
||||
if (sceneGroup.gadgets != null && this.gadgets != null) {
|
||||
this.sceneGadgets = new ArrayList<>(
|
||||
this.gadgets.stream()
|
||||
.filter(sceneGroup.gadgets::containsKey)
|
||||
@@ -41,7 +41,7 @@ public class SceneSuite {
|
||||
);
|
||||
}
|
||||
|
||||
if(sceneGroup.triggers != null && this.triggers != null) {
|
||||
if (sceneGroup.triggers != null && this.triggers != null) {
|
||||
this.sceneTriggers = new ArrayList<>(
|
||||
this.triggers.stream()
|
||||
.filter(sceneGroup.triggers::containsKey)
|
||||
@@ -49,7 +49,7 @@ public class SceneSuite {
|
||||
.toList()
|
||||
);
|
||||
}
|
||||
if(sceneGroup.regions != null && this.regions != null) {
|
||||
if (sceneGroup.regions != null && this.regions != null) {
|
||||
this.sceneRegions = new ArrayList<>(
|
||||
this.regions.stream()
|
||||
.filter(sceneGroup.regions::containsKey)
|
||||
|
||||
@@ -4,41 +4,42 @@ import lombok.Setter;
|
||||
|
||||
@Setter
|
||||
public class SceneTrigger {
|
||||
public String name;
|
||||
public int config_id;
|
||||
public int event;
|
||||
public String source;
|
||||
public String condition;
|
||||
public String action;
|
||||
public String name;
|
||||
public int config_id;
|
||||
public int event;
|
||||
public String source;
|
||||
public String condition;
|
||||
public String action;
|
||||
public boolean forbid_guest;
|
||||
public int trigger_count;
|
||||
public String tlog_tag;
|
||||
|
||||
public transient SceneGroup currentGroup;
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if(obj instanceof SceneTrigger sceneTrigger){
|
||||
return this.name.equals(sceneTrigger.name);
|
||||
}
|
||||
return super.equals(obj);
|
||||
}
|
||||
public transient SceneGroup currentGroup;
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return name.hashCode();
|
||||
}
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj instanceof SceneTrigger sceneTrigger) {
|
||||
return this.name.equals(sceneTrigger.name);
|
||||
}
|
||||
return super.equals(obj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "SceneTrigger{" +
|
||||
"name='" + name + '\'' +
|
||||
", config_id=" + config_id +
|
||||
", event=" + event +
|
||||
", source='" + source + '\'' +
|
||||
", condition='" + condition + '\'' +
|
||||
", action='" + action + '\'' +
|
||||
", forbid_guest='" + forbid_guest + '\'' +
|
||||
", trigger_count='" + trigger_count + '\'' +
|
||||
'}';
|
||||
}
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return name.hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "SceneTrigger{" +
|
||||
"name='" + name + '\'' +
|
||||
", config_id=" + config_id +
|
||||
", event=" + event +
|
||||
", source='" + source + '\'' +
|
||||
", condition='" + condition + '\'' +
|
||||
", action='" + action + '\'' +
|
||||
", forbid_guest='" + forbid_guest + '\'' +
|
||||
", trigger_count='" + trigger_count + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,8 +6,8 @@ import lombok.ToString;
|
||||
@ToString
|
||||
@Setter
|
||||
public class SceneVar {
|
||||
public String name;
|
||||
public int value;
|
||||
public boolean no_refresh;
|
||||
public String name;
|
||||
public int value;
|
||||
public boolean no_refresh;
|
||||
public int configId;
|
||||
}
|
||||
|
||||
@@ -1,59 +1,60 @@
|
||||
package emu.grasscutter.scripts.data;
|
||||
|
||||
public class ScriptArgs {
|
||||
public int param1;
|
||||
public int param2;
|
||||
public int param3;
|
||||
public int source_eid; // Source entity
|
||||
public int param1;
|
||||
public int param2;
|
||||
public int param3;
|
||||
public int source_eid; // Source entity
|
||||
public int target_eid;
|
||||
public ScriptArgs() {
|
||||
|
||||
}
|
||||
public ScriptArgs() {
|
||||
|
||||
public ScriptArgs(int param1) {
|
||||
this.param1 = param1;
|
||||
}
|
||||
}
|
||||
|
||||
public ScriptArgs(int param1, int param2) {
|
||||
this.param1 = param1;
|
||||
this.param2 = param2;
|
||||
}
|
||||
public ScriptArgs(int param1) {
|
||||
this.param1 = param1;
|
||||
}
|
||||
|
||||
public int getParam1() {
|
||||
return param1;
|
||||
}
|
||||
public ScriptArgs(int param1, int param2) {
|
||||
this.param1 = param1;
|
||||
this.param2 = param2;
|
||||
}
|
||||
|
||||
public ScriptArgs setParam1(int param1) {
|
||||
this.param1 = param1;
|
||||
return this;
|
||||
}
|
||||
public int getParam1() {
|
||||
return param1;
|
||||
}
|
||||
|
||||
public int getParam2() {
|
||||
return param2;
|
||||
}
|
||||
public ScriptArgs setParam1(int param1) {
|
||||
this.param1 = param1;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ScriptArgs setParam2(int param2) {
|
||||
this.param2 = param2;
|
||||
return this;
|
||||
}
|
||||
public int getParam2() {
|
||||
return param2;
|
||||
}
|
||||
|
||||
public int getParam3() {
|
||||
return param3;
|
||||
}
|
||||
public ScriptArgs setParam2(int param2) {
|
||||
this.param2 = param2;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ScriptArgs setParam3(int param3) {
|
||||
this.param3 = param3;
|
||||
return this;
|
||||
}
|
||||
public int getParam3() {
|
||||
return param3;
|
||||
}
|
||||
|
||||
public int getSourceEntityId() {
|
||||
return source_eid;
|
||||
}
|
||||
public ScriptArgs setParam3(int param3) {
|
||||
this.param3 = param3;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ScriptArgs setSourceEntityId(int source_eid) {
|
||||
this.source_eid = source_eid;
|
||||
return this;
|
||||
}
|
||||
public int getSourceEntityId() {
|
||||
return source_eid;
|
||||
}
|
||||
|
||||
public ScriptArgs setSourceEntityId(int source_eid) {
|
||||
this.source_eid = source_eid;
|
||||
return this;
|
||||
}
|
||||
|
||||
public int getTargetEntityId() {
|
||||
return target_eid;
|
||||
|
||||
Reference in New Issue
Block a user