use of v1_8_9.net.minecraft.util.ChatComponentText in project Engine by VoltzEngine-Project.
the class CommandVEButcher method handleConsoleCommand.
@Override
public boolean handleConsoleCommand(ICommandSender sender, String[] args) {
long time = System.nanoTime();
// TODO add ability to set location and range
int dim = 0;
if (args != null && args.length > 0) {
if (args[0].startsWith("dim")) {
try {
dim = Integer.parseInt(args[0].replace("dim", ""));
} catch (NumberFormatException e) {
sender.addChatMessage(new ChatComponentText("Dim id needs to be an int"));
return true;
}
} else {
sender.addChatMessage(new ChatComponentText("Right now only /ve butcher dim[#] is supported, ex /ve butcher dim0"));
return true;
}
}
WorldServer world = DimensionManager.getWorld(dim);
if (world != null) {
int entitiesKilled = 0;
int chunksSearched = 0;
ChunkProviderServer provider = world.theChunkProviderServer;
for (Object object : provider.loadedChunks) {
if (object instanceof Chunk) {
chunksSearched++;
for (Object l : ((Chunk) object).entityLists) {
if (l instanceof Collection) {
for (Object e : (Collection) l) {
if (e instanceof Entity && e instanceof IMob) {
if (((Entity) e).isEntityAlive()) {
((Entity) e).setDead();
entitiesKilled++;
}
}
}
}
}
}
}
time = System.nanoTime() - time;
sender.addChatMessage(new ChatComponentText("Removed " + entitiesKilled + "mobs over " + chunksSearched + " chunks in " + StringHelpers.formatNanoTime(time)));
} else {
sender.addChatMessage(new ChatComponentText("World doesn't exist, this means it unloaded or the wrong id was provided."));
}
return true;
}
use of v1_8_9.net.minecraft.util.ChatComponentText in project Engine by VoltzEngine-Project.
the class CommandVERemove method handleConsoleCommand.
@Override
public boolean handleConsoleCommand(ICommandSender sender, String[] args) {
long time = System.nanoTime();
// TODO add ability to set location and range
int dim = 0;
EntitySelector selector = getSelector(args[0]);
if (selector == null) {
// TODO return error
return false;
}
if (args != null && args.length > 1) {
if (args[1].startsWith("dim")) {
try {
dim = Integer.parseInt(args[1].replace("dim", ""));
} catch (NumberFormatException e) {
sender.addChatMessage(new ChatComponentText("Dim id needs to be an int"));
return true;
}
} else {
sender.addChatMessage(new ChatComponentText("Right now only /ve butcher dim[#] is supported, ex /ve butcher dim0"));
return true;
}
}
WorldServer world = DimensionManager.getWorld(dim);
if (world != null) {
int entitiesKilled = 0;
int chunksSearched = 0;
ChunkProviderServer provider = world.theChunkProviderServer;
for (Object object : provider.loadedChunks) {
if (object instanceof Chunk) {
chunksSearched++;
for (Object l : ((Chunk) object).entityLists) {
if (l instanceof Collection) {
for (Object e : (Collection) l) {
if (e instanceof Entity && ((Entity) e).isEntityAlive() && selector.isEntityApplicable((Entity) e)) {
((Entity) e).setDead();
entitiesKilled++;
}
}
}
}
}
}
time = System.nanoTime() - time;
sender.addChatMessage(new ChatComponentText("Removed " + entitiesKilled + " entities over " + chunksSearched + " chunks in " + StringHelpers.formatNanoTime(time)));
} else {
sender.addChatMessage(new ChatComponentText("World doesn't exist, this means it unloaded or the wrong id was provided."));
}
return true;
}
use of v1_8_9.net.minecraft.util.ChatComponentText in project Engine by VoltzEngine-Project.
the class CommandVERemove method handleEntityPlayerCommand.
@Override
public boolean handleEntityPlayerCommand(EntityPlayer entityPlayer, String[] args) {
if (args.length > 0) {
int radius = 100;
EntitySelector selector = getSelector(args[0]);
if (selector == null) {
// TODO return error
return false;
}
// Get radius from player
if (args.length > 1 && args[1] != null) {
try {
radius = Integer.parseInt(args[1]);
if (radius > 1000) {
entityPlayer.addChatMessage(new ChatComponentText("To prevent lag/crashes radius is limited to 1000"));
return true;
} else if (radius < 1) {
entityPlayer.addChatMessage(new ChatComponentText("Radius needs to be positive"));
return true;
}
} catch (NumberFormatException e) {
entityPlayer.addChatMessage(new ChatComponentText("Radius needs to be an integer"));
return true;
}
}
if (selector != null) {
List<Entity> list = selector.getEntities(entityPlayer, radius);
for (Entity entity : list) {
entity.setDead();
}
entityPlayer.addChatMessage(new ChatComponentText("Removed " + list.size() + " " + args[0] + " entities within " + radius + " block radius"));
} else {
entityPlayer.addChatMessage(new ChatComponentText("Error unknown selector"));
}
return true;
}
return false;
}
use of v1_8_9.net.minecraft.util.ChatComponentText in project Engine by VoltzEngine-Project.
the class CommandNewGroup method handleConsoleCommand.
@Override
public boolean handleConsoleCommand(ICommandSender sender, String[] args) {
if (args.length > 0) {
String name = args[0];
if (GroupProfileHandler.GLOBAL.getAccessProfile().getGroup(name) == null) {
AccessGroup toExtend = null;
if (args.length > 1 && args[1].equalsIgnoreCase("extend")) {
if (args.length > 2) {
String extendName = args[2];
toExtend = GroupProfileHandler.GLOBAL.getAccessProfile().getGroup(extendName);
}
if (toExtend == null) {
sender.addChatMessage(new ChatComponentText("Error: Unknown group to extend"));
return true;
}
}
AccessGroup group = new AccessGroup(name);
if (toExtend != null) {
group.setToExtend(toExtend);
}
if (GroupProfileHandler.GLOBAL.getAccessProfile().addGroup(group)) {
sender.addChatMessage(new ChatComponentText("Group added"));
} else {
sender.addChatMessage(new ChatComponentText("Error adding group"));
}
} else {
sender.addChatMessage(new ChatComponentText("A Group by that name already exists"));
}
} else {
sender.addChatMessage(new ChatComponentText("Missing group name"));
}
return true;
}
use of v1_8_9.net.minecraft.util.ChatComponentText in project Engine by VoltzEngine-Project.
the class GSCPerm method handle.
@Override
public boolean handle(ICommandSender sender, AccessGroup group, String node, String[] args) {
if (!remove && group.hasNode(node) || remove && group.hasExactNode(node)) {
if (remove) {
group.removeNode(node);
} else {
sender.addChatMessage(new ChatComponentText("Group already contains the node or super version of the node"));
}
} else {
if (!remove) {
group.addNode(node);
sender.addChatMessage(new ChatComponentText("Node added to the group"));
} else if (group.hasNode(node)) {
sender.addChatMessage(new ChatComponentText("Group contains a super version of that node, but not an exact match"));
} else if (group.getExtendGroup() != null && group.getExtendGroup().hasNode(node)) {
sender.addChatMessage(new ChatComponentText("Super group contains the node, but the node is not contained in this group"));
} else {
sender.addChatMessage(new ChatComponentText("Group does not contain the node"));
}
}
return true;
}
Aggregations