use of com.mraof.minestuck.world.lands.terrain.TerrainLandAspect in project Minestuck by mraof.
the class CommandSburbSession method execute.
@Override
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException {
if (args.length < 2 || args.length < 3 && args[1].equalsIgnoreCase("add") || args.length != 4 && (args[1].equalsIgnoreCase("landTerrain") || args[1].equalsIgnoreCase("landTitle")) || args.length != 5 && args[1].equalsIgnoreCase("title") || args.length != 6 && args.length != 7 && args[1].equalsIgnoreCase("define"))
throw new WrongUsageException(this.getUsage(sender));
String sessionName = args[0];
String command = args[1];
if (command.equalsIgnoreCase("name")) {
String playerName = args.length < 3 ? getCommandSenderAsPlayer(sender).getName() : args[2];
SburbHandler.sessionName(server, sender, this, playerName, sessionName);
} else if (command.equalsIgnoreCase("add")) /* || command.equalsIgnoreCase("finish")*/
{
String[] params = Arrays.copyOfRange(args, 2, args.length);
// command.equalsIgnoreCase("finish"));
SburbHandler.managePredefinedSession(server, sender, this, sessionName, params, false);
} else if (command.equalsIgnoreCase("title")) {
String playerName = args[2];
String classStr = args[3], aspectStr = args[4];
EnumClass titleClass = null;
EnumAspect titleAspect = null;
try // Parse class
{
for (EnumClass c : EnumClass.values()) if (c.name().equalsIgnoreCase(classStr)) {
titleClass = c;
break;
}
if (titleClass == null) {
int classIndex = Integer.parseInt(classStr);
titleClass = EnumClass.getClassFromInt(classIndex);
}
} catch (Exception e) {
throw new WrongUsageException("commands.sburbSession.notClass", classStr);
}
try // Parse aspect
{
for (EnumAspect aspect : EnumAspect.values()) if (aspect.name().equalsIgnoreCase(aspectStr)) {
titleAspect = aspect;
break;
}
if (titleAspect == null) {
int aspectIndex = Integer.parseInt(aspectStr);
titleAspect = EnumAspect.getAspectFromInt(aspectIndex);
}
} catch (Exception e) {
throw new WrongUsageException("commands.sburbSession.notAspect", aspectStr);
}
SburbHandler.predefineTitle(server, sender, this, playerName, sessionName, new Title(titleClass, titleAspect));
} else if (command.equalsIgnoreCase("landTerrain")) {
String playerName = args[2];
TerrainLandAspect landAspect = LandAspectRegistry.fromNameTerrain(args[3].toLowerCase());
if (landAspect == null)
throw new CommandException("Can't find terrain land aspect by the name %s", args[3]);
SburbHandler.predefineTerrainLandAspect(server, sender, this, playerName, sessionName, landAspect);
} else if (command.equalsIgnoreCase("landTitle")) {
String playerName = args[2];
TitleLandAspect landAspect = LandAspectRegistry.fromNameTitle(args[3].toLowerCase());
if (landAspect == null)
throw new CommandException("Can't find title land aspect by the name %s", args[3]);
SburbHandler.predefineTitleLandAspect(server, sender, this, playerName, sessionName, landAspect);
} else if (command.equalsIgnoreCase("define")) {
String playerName = args[2];
String classStr = args[3], aspectStr = args[4];
EnumClass titleClass = null;
EnumAspect titleAspect = null;
try // Parse class
{
for (EnumClass c : EnumClass.values()) if (c.name().equalsIgnoreCase(classStr)) {
titleClass = c;
break;
}
if (titleClass == null) {
int classIndex = Integer.parseInt(classStr);
titleClass = EnumClass.getClassFromInt(classIndex);
}
} catch (Exception e) {
throw new WrongUsageException("commands.sburbSession.notClass", classStr);
}
try // Parse aspect
{
for (EnumAspect aspect : EnumAspect.values()) if (aspect.name().equalsIgnoreCase(aspectStr)) {
titleAspect = aspect;
break;
}
if (titleAspect == null) {
int aspectIndex = Integer.parseInt(aspectStr);
titleAspect = EnumAspect.getAspectFromInt(aspectIndex);
}
} catch (Exception e) {
throw new WrongUsageException("commands.sburbSession.notAspect", aspectStr);
}
TerrainLandAspect terrainLand = null;
TitleLandAspect titleLand = null;
if (args.length == 7) {
titleLand = LandAspectRegistry.fromNameTitle(args[5].toLowerCase());
if (titleLand == null)
throw new CommandException("Can't find title land aspect by the name %s", args[5]);
terrainLand = LandAspectRegistry.fromNameTerrain(args[6].toLowerCase());
if (terrainLand == null)
throw new CommandException("Can't find terrain land aspect by the name %s", args[6]);
} else {
titleLand = LandAspectRegistry.fromNameTitle(args[5].toLowerCase());
if (titleLand == null) {
terrainLand = LandAspectRegistry.fromNameTerrain(args[5].toLowerCase());
if (terrainLand == null)
throw new CommandException("Can't find any land aspect by the name %s", args[5]);
}
}
SburbHandler.predefineTitle(server, sender, this, playerName, sessionName, new Title(titleClass, titleAspect));
if (titleLand != null)
SburbHandler.predefineTitleLandAspect(server, sender, this, playerName, sessionName, titleLand);
if (terrainLand != null)
SburbHandler.predefineTerrainLandAspect(server, sender, this, playerName, sessionName, terrainLand);
} else
throw new WrongUsageException(this.getUsage(sender));
}
use of com.mraof.minestuck.world.lands.terrain.TerrainLandAspect in project Minestuck by mraof.
the class SburbHandler method genLandAspects.
private static void genLandAspects(SburbConnection connection) {
LandAspectRegistry aspectGen = new LandAspectRegistry((Minestuck.worldSeed ^ connection.clientHomeLand) ^ (connection.clientHomeLand << 8));
Session session = getPlayerSession(connection.getClientIdentifier());
Title title = MinestuckPlayerData.getTitle(connection.getClientIdentifier());
TitleLandAspect titleAspect = null;
TerrainLandAspect terrainAspect = null;
if (session.predefinedPlayers.containsKey(connection.getClientIdentifier())) {
PredefineData data = session.predefinedPlayers.get(connection.getClientIdentifier());
if (data.landTitle != null)
titleAspect = data.landTitle;
if (data.landTerrain != null)
terrainAspect = data.landTerrain;
}
boolean frogs = false;
ArrayList<TerrainLandAspect> usedTerrainAspects = new ArrayList<TerrainLandAspect>();
ArrayList<TitleLandAspect> usedTitleAspects = new ArrayList<TitleLandAspect>();
for (SburbConnection c : session.connections) if (c.enteredGame && c != connection) {
LandAspectRegistry.AspectCombination aspects = MinestuckDimensionHandler.getAspects(c.clientHomeLand);
if (aspects.aspectTitle == LandAspectRegistry.frogAspect)
frogs = true;
usedTitleAspects.add(aspects.aspectTitle);
usedTerrainAspects.add(aspects.aspectTerrain);
}
for (PredefineData data : session.predefinedPlayers.values()) {
if (data.landTerrain != null)
usedTerrainAspects.add(data.landTerrain);
if (data.landTitle != null) {
usedTitleAspects.add(data.landTitle);
if (data.landTitle == LandAspectRegistry.frogAspect)
frogs = true;
}
}
if (titleAspect == null)
titleAspect = aspectGen.getTitleAspect(terrainAspect, title.getHeroAspect(), usedTitleAspects);
if (terrainAspect == null)
terrainAspect = aspectGen.getTerrainAspect(titleAspect, usedTerrainAspects);
MinestuckDimensionHandler.registerLandDimension(connection.clientHomeLand, new AspectCombination(terrainAspect, titleAspect));
}
use of com.mraof.minestuck.world.lands.terrain.TerrainLandAspect in project Minestuck by mraof.
the class LandAspectLootCondition method testCondition.
@Override
public boolean testCondition(Random rand, LootContext context) {
WorldServer world = context.getWorld();
if (world != null && MinestuckDimensionHandler.isLandDimension(world.provider.getDimension())) {
AspectCombination aspects = MinestuckDimensionHandler.getAspects(world.provider.getDimension());
TerrainLandAspect terrain = includeSubtypes ? aspects.aspectTerrain.getPrimaryVariant() : aspects.aspectTerrain;
TitleLandAspect title = includeSubtypes ? aspects.aspectTitle.getPrimaryVariant() : aspects.aspectTitle;
for (ILandAspect aspect : landAspectNames) if (terrain == aspect || title == aspect)
return !inverted;
}
return inverted;
}
Aggregations