Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

specify position instead of player #153

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

specify position instead of player #153

wants to merge 1 commit into from

Conversation

tgwaste
Copy link

@tgwaste tgwaste commented May 14, 2020

Allow player to do (for example):
/mob spawn Zombie x,y,z

toPos = true;
}

if (args.length == 3 && toPos == false) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why toPos == false instead of !toPos ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just readability, but am happy to change it.

@@ -138,10 +143,30 @@ public boolean onCommand(CommandSender sender, Command cmd, String label, String
if (playerThatSpawns != null) {
Position pos = playerThatSpawns.getPosition();

if (toPos == true) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not just if (toPos) {?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just readability, but am happy to change it.

if (toPos == true) {
// specifying a position instead of a player
String[] arg = args[2].split(",");
playerThatSpawns = (Player) sender;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will give a ClassCastException if run from console

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will look into this, still pretty new to java.

String[] arg = args[2].split(",");
playerThatSpawns = (Player) sender;

Position newpos = new Position
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we should catch the exception which comes if player gives invalid coordinates?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will look into this, at this point I do not know how to validate coordinates.

Entity ent;
if ((ent = Entity.createEntity(mob, pos)) != null) {
ent.spawnToAll();
sender.sendMessage("Spawned " + mob + " to " + playerThatSpawns.getName());
if (toPos == true) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not just if (toPos) {?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just readability, but am happy to change it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants