mirror of
https://github.com/Grasscutters/Grasscutter.git
synced 2025-01-24 15:42:53 +08:00
Format code [skip actions]
This commit is contained in:
parent
ac3ccf93f3
commit
b050337216
@ -1,5 +1,8 @@
|
|||||||
package emu.grasscutter;
|
package emu.grasscutter;
|
||||||
|
|
||||||
|
import static emu.grasscutter.config.Configuration.SERVER;
|
||||||
|
import static emu.grasscutter.utils.lang.Language.translate;
|
||||||
|
|
||||||
import ch.qos.logback.classic.*;
|
import ch.qos.logback.classic.*;
|
||||||
import emu.grasscutter.auth.*;
|
import emu.grasscutter.auth.*;
|
||||||
import emu.grasscutter.command.*;
|
import emu.grasscutter.command.*;
|
||||||
@ -18,20 +21,16 @@ import emu.grasscutter.tools.Tools;
|
|||||||
import emu.grasscutter.utils.*;
|
import emu.grasscutter.utils.*;
|
||||||
import emu.grasscutter.utils.lang.Language;
|
import emu.grasscutter.utils.lang.Language;
|
||||||
import io.netty.util.concurrent.FastThreadLocalThread;
|
import io.netty.util.concurrent.FastThreadLocalThread;
|
||||||
|
import java.io.*;
|
||||||
|
import java.util.Calendar;
|
||||||
|
import java.util.concurrent.*;
|
||||||
|
import javax.annotation.Nullable;
|
||||||
import lombok.*;
|
import lombok.*;
|
||||||
import org.jline.reader.*;
|
import org.jline.reader.*;
|
||||||
import org.jline.terminal.*;
|
import org.jline.terminal.*;
|
||||||
import org.reflections.Reflections;
|
import org.reflections.Reflections;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
import java.io.*;
|
|
||||||
import java.util.Calendar;
|
|
||||||
import java.util.concurrent.*;
|
|
||||||
|
|
||||||
import static emu.grasscutter.config.Configuration.SERVER;
|
|
||||||
import static emu.grasscutter.utils.lang.Language.translate;
|
|
||||||
|
|
||||||
public final class Grasscutter {
|
public final class Grasscutter {
|
||||||
public static final File configFile = new File("./config.json");
|
public static final File configFile = new File("./config.json");
|
||||||
public static final Reflections reflector = new Reflections("emu.grasscutter");
|
public static final Reflections reflector = new Reflections("emu.grasscutter");
|
||||||
|
@ -1,14 +1,13 @@
|
|||||||
package emu.grasscutter.command;
|
package emu.grasscutter.command;
|
||||||
|
|
||||||
|
import static emu.grasscutter.config.Configuration.SERVER;
|
||||||
|
|
||||||
import emu.grasscutter.Grasscutter;
|
import emu.grasscutter.Grasscutter;
|
||||||
import emu.grasscutter.database.DatabaseHelper;
|
import emu.grasscutter.database.DatabaseHelper;
|
||||||
import emu.grasscutter.game.player.Player;
|
import emu.grasscutter.game.player.Player;
|
||||||
import it.unimi.dsi.fastutil.objects.*;
|
import it.unimi.dsi.fastutil.objects.*;
|
||||||
import org.reflections.Reflections;
|
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import org.reflections.Reflections;
|
||||||
import static emu.grasscutter.config.Configuration.SERVER;
|
|
||||||
|
|
||||||
@SuppressWarnings({"UnusedReturnValue", "unused"})
|
@SuppressWarnings({"UnusedReturnValue", "unused"})
|
||||||
public final class CommandMap {
|
public final class CommandMap {
|
||||||
|
@ -1,9 +1,8 @@
|
|||||||
package emu.grasscutter.data.binout.config;
|
package emu.grasscutter.data.binout.config;
|
||||||
|
|
||||||
import emu.grasscutter.data.binout.config.fields.ConfigAbilityData;
|
import emu.grasscutter.data.binout.config.fields.ConfigAbilityData;
|
||||||
import lombok.Getter;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
public class ConfigLevelEntity {
|
public class ConfigLevelEntity {
|
||||||
|
|
||||||
|
@ -2,7 +2,6 @@ package emu.grasscutter.game.ability.actions;
|
|||||||
|
|
||||||
import com.google.protobuf.ByteString;
|
import com.google.protobuf.ByteString;
|
||||||
import com.google.protobuf.InvalidProtocolBufferException;
|
import com.google.protobuf.InvalidProtocolBufferException;
|
||||||
|
|
||||||
import emu.grasscutter.Grasscutter;
|
import emu.grasscutter.Grasscutter;
|
||||||
import emu.grasscutter.data.GameData;
|
import emu.grasscutter.data.GameData;
|
||||||
import emu.grasscutter.data.binout.AbilityModifier.AbilityModifierAction;
|
import emu.grasscutter.data.binout.AbilityModifier.AbilityModifierAction;
|
||||||
@ -11,7 +10,6 @@ import emu.grasscutter.game.ability.Ability;
|
|||||||
import emu.grasscutter.game.entity.EntityAvatar;
|
import emu.grasscutter.game.entity.EntityAvatar;
|
||||||
import emu.grasscutter.game.entity.EntityItem;
|
import emu.grasscutter.game.entity.EntityItem;
|
||||||
import emu.grasscutter.game.entity.GameEntity;
|
import emu.grasscutter.game.entity.GameEntity;
|
||||||
import emu.grasscutter.game.props.ItemUseOp;
|
|
||||||
import emu.grasscutter.game.props.SceneType;
|
import emu.grasscutter.game.props.SceneType;
|
||||||
import emu.grasscutter.net.proto.AbilityActionGenerateElemBallOuterClass.AbilityActionGenerateElemBall;
|
import emu.grasscutter.net.proto.AbilityActionGenerateElemBallOuterClass.AbilityActionGenerateElemBall;
|
||||||
import emu.grasscutter.utils.Position;
|
import emu.grasscutter.utils.Position;
|
||||||
@ -19,7 +17,8 @@ import emu.grasscutter.utils.Position;
|
|||||||
@AbilityAction(AbilityModifierAction.Type.GenerateElemBall)
|
@AbilityAction(AbilityModifierAction.Type.GenerateElemBall)
|
||||||
public class ActionGenerateElemBall extends AbilityActionHandler {
|
public class ActionGenerateElemBall extends AbilityActionHandler {
|
||||||
@Override
|
@Override
|
||||||
public boolean execute(Ability ability, AbilityModifierAction action, ByteString abilityData, GameEntity target) {
|
public boolean execute(
|
||||||
|
Ability ability, AbilityModifierAction action, ByteString abilityData, GameEntity target) {
|
||||||
GameEntity owner = ability.getOwner();
|
GameEntity owner = ability.getOwner();
|
||||||
|
|
||||||
AbilityActionGenerateElemBall generateElemBall;
|
AbilityActionGenerateElemBall generateElemBall;
|
||||||
@ -29,58 +28,72 @@ public class ActionGenerateElemBall extends AbilityActionHandler {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Check if we should allow elem ball generation
|
// Check if we should allow elem ball generation
|
||||||
if(action.dropType == 0x0) {
|
if (action.dropType == 0x0) {
|
||||||
String levelEntityConfig = owner.getScene().getSceneData().getLevelEntityConfig();
|
String levelEntityConfig = owner.getScene().getSceneData().getLevelEntityConfig();
|
||||||
ConfigLevelEntity config = GameData.getConfigLevelEntityDataMap().get(levelEntityConfig);
|
ConfigLevelEntity config = GameData.getConfigLevelEntityDataMap().get(levelEntityConfig);
|
||||||
if(config != null && config.getDropElemControlType() != null && config.getDropElemControlType().compareTo("None") == 0) {
|
if (config != null
|
||||||
|
&& config.getDropElemControlType() != null
|
||||||
|
&& config.getDropElemControlType().compareTo("None") == 0) {
|
||||||
Grasscutter.getLogger().warn("This level config don't allow element balls");
|
Grasscutter.getLogger().warn("This level config don't allow element balls");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} else if(action.dropType == 0x1) {
|
} else if (action.dropType == 0x1) {
|
||||||
if(owner.getScene().getSceneData().getSceneType() != SceneType.SCENE_WORLD) {
|
if (owner.getScene().getSceneData().getSceneType() != SceneType.SCENE_WORLD) {
|
||||||
Grasscutter.getLogger().warn("This level config only allows element balls on big world");
|
Grasscutter.getLogger().warn("This level config only allows element balls on big world");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} //Else the drop is forced
|
} // Else the drop is forced
|
||||||
|
|
||||||
var energy = action.baseEnergy.get(ability) * action.ratio.get(ability);
|
var energy = action.baseEnergy.get(ability) * action.ratio.get(ability);
|
||||||
if(energy <= 0.0) return true;
|
if (energy <= 0.0) return true;
|
||||||
|
|
||||||
var itemData = GameData.getItemDataMap().get(action.configID);
|
var itemData = GameData.getItemDataMap().get(action.configID);
|
||||||
if(itemData == null) {
|
if (itemData == null) {
|
||||||
Grasscutter.getLogger().warn("configID {} not found", action.configID);
|
Grasscutter.getLogger().warn("configID {} not found", action.configID);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(itemData.getItemUse() == null || itemData.getItemUse().isEmpty()) {
|
if (itemData.getItemUse() == null || itemData.getItemUse().isEmpty()) {
|
||||||
Grasscutter.getLogger().warn("Item {} has no item use array", action.configID);
|
Grasscutter.getLogger().warn("Item {} has no item use array", action.configID);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
var itemUse = itemData.getItemUse().get(0);
|
var itemUse = itemData.getItemUse().get(0);
|
||||||
double requiredEnergy;
|
double requiredEnergy;
|
||||||
switch(itemUse.getUseOp()) {
|
switch (itemUse.getUseOp()) {
|
||||||
case ITEM_USE_ADD_ELEM_ENERGY: requiredEnergy = Integer.parseInt(itemUse.getUseParam()[1]); break;
|
case ITEM_USE_ADD_ELEM_ENERGY:
|
||||||
case ITEM_USE_ADD_ALL_ENERGY: requiredEnergy = Integer.parseInt(itemUse.getUseParam()[0]); break;
|
requiredEnergy = Integer.parseInt(itemUse.getUseParam()[1]);
|
||||||
|
break;
|
||||||
|
case ITEM_USE_ADD_ALL_ENERGY:
|
||||||
|
requiredEnergy = Integer.parseInt(itemUse.getUseParam()[0]);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
Grasscutter.getLogger().warn("UseOp not implemented", itemUse.getUseOp());
|
Grasscutter.getLogger().warn("UseOp not implemented", itemUse.getUseOp());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
var amountGenerated = (int)Math.ceil(energy / requiredEnergy);
|
var amountGenerated = (int) Math.ceil(energy / requiredEnergy);
|
||||||
if(amountGenerated >= 21) {
|
if (amountGenerated >= 21) {
|
||||||
Grasscutter.getLogger().warn("Attempt to generate more than 20 element balls {}", amountGenerated);
|
Grasscutter.getLogger()
|
||||||
|
.warn("Attempt to generate more than 20 element balls {}", amountGenerated);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Grasscutter.getLogger().debug("Generating {} of {} element balls", amountGenerated, action.configID);
|
Grasscutter.getLogger()
|
||||||
for(int i = 0; i < amountGenerated; i++) {
|
.debug("Generating {} of {} element balls", amountGenerated, action.configID);
|
||||||
EntityItem energyBall = new EntityItem(owner.getScene(), (owner instanceof EntityAvatar avatar) ? avatar.getPlayer() : null, itemData, new Position(generateElemBall.getPos()), new Position(generateElemBall.getRot()), 1);
|
for (int i = 0; i < amountGenerated; i++) {
|
||||||
|
EntityItem energyBall =
|
||||||
|
new EntityItem(
|
||||||
|
owner.getScene(),
|
||||||
|
(owner instanceof EntityAvatar avatar) ? avatar.getPlayer() : null,
|
||||||
|
itemData,
|
||||||
|
new Position(generateElemBall.getPos()),
|
||||||
|
new Position(generateElemBall.getRot()),
|
||||||
|
1);
|
||||||
owner.getScene().addEntity(energyBall);
|
owner.getScene().addEntity(energyBall);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,18 +37,29 @@ public class EntityItem extends EntityBaseGadget {
|
|||||||
this(scene, player, itemData, pos, count, true);
|
this(scene, player, itemData, pos, count, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public EntityItem(Scene scene, Player player, ItemData itemData, Position pos, Position rotation, int count) {
|
public EntityItem(
|
||||||
|
Scene scene, Player player, ItemData itemData, Position pos, Position rotation, int count) {
|
||||||
this(scene, player, itemData, pos, rotation, count, true);
|
this(scene, player, itemData, pos, rotation, count, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public EntityItem(Scene scene, Player player, ItemData itemData, Position pos, int count, boolean share) {
|
public EntityItem(
|
||||||
|
Scene scene, Player player, ItemData itemData, Position pos, int count, boolean share) {
|
||||||
this(scene, player, itemData, pos, null, count, share);
|
this(scene, player, itemData, pos, null, count, share);
|
||||||
}
|
}
|
||||||
|
|
||||||
// In official game, some drop items are shared to all players, and some other items are independent to all players
|
// In official game, some drop items are shared to all players, and some other items are
|
||||||
// For example, if you killed a monster in MP mode, all players could get drops but rarity and number of them are different
|
// independent to all players
|
||||||
|
// For example, if you killed a monster in MP mode, all players could get drops but rarity and
|
||||||
|
// number of them are different
|
||||||
// but if you broke regional mine, when someone picked up the drop then it disappeared
|
// but if you broke regional mine, when someone picked up the drop then it disappeared
|
||||||
public EntityItem(Scene scene, Player player, ItemData itemData, Position pos, Position rotation, int count, boolean share) {
|
public EntityItem(
|
||||||
|
Scene scene,
|
||||||
|
Player player,
|
||||||
|
ItemData itemData,
|
||||||
|
Position pos,
|
||||||
|
Position rotation,
|
||||||
|
int count,
|
||||||
|
boolean share) {
|
||||||
super(scene, pos, rotation);
|
super(scene, pos, rotation);
|
||||||
this.id = getScene().getWorld().getNextEntityId(EntityIdType.GADGET);
|
this.id = getScene().getWorld().getNextEntityId(EntityIdType.GADGET);
|
||||||
this.guid =
|
this.guid =
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
package emu.grasscutter.server.game;
|
package emu.grasscutter.server.game;
|
||||||
|
|
||||||
|
import static emu.grasscutter.config.Configuration.*;
|
||||||
|
import static emu.grasscutter.utils.lang.Language.translate;
|
||||||
|
|
||||||
import emu.grasscutter.*;
|
import emu.grasscutter.*;
|
||||||
import emu.grasscutter.Grasscutter.ServerRunMode;
|
import emu.grasscutter.Grasscutter.ServerRunMode;
|
||||||
import emu.grasscutter.database.DatabaseHelper;
|
import emu.grasscutter.database.DatabaseHelper;
|
||||||
@ -30,17 +33,13 @@ import emu.grasscutter.server.event.types.ServerEvent;
|
|||||||
import emu.grasscutter.server.scheduler.ServerTaskScheduler;
|
import emu.grasscutter.server.scheduler.ServerTaskScheduler;
|
||||||
import emu.grasscutter.task.TaskMap;
|
import emu.grasscutter.task.TaskMap;
|
||||||
import emu.grasscutter.utils.Utils;
|
import emu.grasscutter.utils.Utils;
|
||||||
import kcp.highway.*;
|
|
||||||
import lombok.*;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
|
|
||||||
import java.net.*;
|
import java.net.*;
|
||||||
import java.time.*;
|
import java.time.*;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.concurrent.*;
|
import java.util.concurrent.*;
|
||||||
|
import kcp.highway.*;
|
||||||
import static emu.grasscutter.config.Configuration.*;
|
import lombok.*;
|
||||||
import static emu.grasscutter.utils.lang.Language.translate;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
public final class GameServer extends KcpServer implements Iterable<Player> {
|
public final class GameServer extends KcpServer implements Iterable<Player> {
|
||||||
|
Loading…
Reference in New Issue
Block a user