PrefabSpawnerWeightCommand.java
package com.hypixel.hytale.server.core.modules.prefabspawner.commands;
import com.hypixel.hytale.server.core.Message;
import com.hypixel.hytale.server.core.command.system.CommandContext;
import com.hypixel.hytale.server.core.command.system.arguments.system.RequiredArg;
import com.hypixel.hytale.server.core.command.system.arguments.types.ArgTypes;
import com.hypixel.hytale.server.core.modules.prefabspawner.PrefabSpawnerState;
import com.hypixel.hytale.server.core.prefab.PrefabWeights;
import com.hypixel.hytale.server.core.universe.world.chunk.WorldChunk;
import javax.annotation.Nonnull;
public class PrefabSpawnerWeightCommand extends TargetPrefabSpawnerCommand {
@Nonnull
private final RequiredArg<String> prefabArg;
@Nonnull
private final RequiredArg<Float> weightArg;
public PrefabSpawnerWeightCommand() {
super("weight", "server.commands.prefabspawner.weight.desc");
this.prefabArg = this.withRequiredArg("prefab", "server.commands.prefabspawner.weight.prefab.desc", ArgTypes.STRING);
this.weightArg = this.withRequiredArg("weight", , ArgTypes.FLOAT);
}
{
(String).prefabArg.get(context);
(Float).weightArg.get(context);
prefabSpawner.getPrefabWeights();
(prefabWeights == PrefabWeights.NONE) {
prefabWeights = ();
}
(weight < ) {
prefabWeights.removeWeight(prefab);
context.sendMessage(Message.translation().param(, prefab));
} {
prefabWeights.setWeight(prefab, ()weight);
context.sendMessage(Message.translation().param(, prefab).param(, weight));
}
prefabSpawner.setPrefabWeights(prefabWeights);
chunk.markNeedsSaving();
}
}