Skip to content
This repository has been archived by the owner on Jun 16, 2022. It is now read-only.

Commit

Permalink
/getpos and /whois changes
Browse files Browse the repository at this point in the history
  • Loading branch information
superischroma committed Dec 31, 2019
1 parent e7881f7 commit c705a7b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 12 deletions.
24 changes: 13 additions & 11 deletions Essentials/src/com/earth2me/essentials/commands/Commandgetpos.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ public Commandgetpos() {
public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception {
if (args.length > 0 && user.isAuthorized("essentials.getpos.others")) {
final User otherUser = getPlayer(server, user, args, 0);
outputPosition(user.getSource(), otherUser.getLocation(), user.getLocation());
outputPosition(user.getSource(), user, otherUser.getLocation(), user.getLocation());
return;
}
outputPosition(user.getSource(), user.getLocation(), null);
outputPosition(user.getSource(), user, user.getLocation(), null);
}

@Override
Expand All @@ -32,18 +32,20 @@ protected void run(final Server server, final CommandSource sender, final String
throw new NotEnoughArgumentsException();
}
final User user = getPlayer(server, args, 0, true, false);
outputPosition(sender, user.getLocation(), null);
outputPosition(sender, user, user.getLocation(), null);
}

private void outputPosition(final CommandSource sender, final Location coords, final Location distance) {
private void outputPosition(final CommandSource sender, final User user, final Location coords, final Location distance) {
sender.sendMessage(tl("currentWorld", coords.getWorld().getName()));
sender.sendMessage(tl("posX", coords.getBlockX()));
sender.sendMessage(tl("posY", coords.getBlockY()));
sender.sendMessage(tl("posZ", coords.getBlockZ()));
sender.sendMessage(tl("posYaw", (coords.getYaw() + 360) % 360));
sender.sendMessage(tl("posPitch", coords.getPitch()));
if (distance != null && coords.getWorld().equals(distance.getWorld())) {
sender.sendMessage(tl("distance", coords.distance(distance)));
if (!sender.isPlayer()|| getTFMHandler().isAdmin(sender.getPlayer()) || user.getSource() == sender) {
sender.sendMessage(tl("posX", coords.getBlockX()));
sender.sendMessage(tl("posY", coords.getBlockY()));
sender.sendMessage(tl("posZ", coords.getBlockZ()));
sender.sendMessage(tl("posYaw", (coords.getYaw() + 360) % 360));
sender.sendMessage(tl("posPitch", coords.getPitch()));
if (distance != null && coords.getWorld().equals(distance.getWorld())) {
sender.sendMessage(tl("distance", coords.distance(distance)));
}
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
package com.earth2me.essentials.commands;

import com.earth2me.essentials.CommandSource;
import com.earth2me.essentials.TFMHandler;
import com.earth2me.essentials.User;
import com.earth2me.essentials.craftbukkit.SetExpFix;
import com.earth2me.essentials.utils.DateUtil;
import com.earth2me.essentials.utils.EnumUtil;
import com.earth2me.essentials.utils.NumberUtil;
import org.bukkit.Server;
import org.bukkit.Statistic;
import org.bukkit.command.ConsoleCommandSender;

import java.util.Locale;
import java.util.Collections;
Expand Down Expand Up @@ -40,7 +42,9 @@ public void run(final Server server, final CommandSource sender, final String co
sender.sendMessage(tl("whoisHealth", user.getBase().getHealth()));
sender.sendMessage(tl("whoisHunger", user.getBase().getFoodLevel(), user.getBase().getSaturation()));
sender.sendMessage(tl("whoisExp", SetExpFix.getTotalExperience(user.getBase()), user.getBase().getLevel()));
sender.sendMessage(tl("whoisLocation", user.getLocation().getWorld().getName(), user.getLocation().getBlockX(), user.getLocation().getBlockY(), user.getLocation().getBlockZ()));
if (!sender.isPlayer() || getTFMHandler().isAdmin(sender.getPlayer())) {
sender.sendMessage(tl("whoisLocation", user.getLocation().getWorld().getName(), user.getLocation().getBlockX(), user.getLocation().getBlockY(), user.getLocation().getBlockZ()));
}
long playtimeMs = System.currentTimeMillis() - (user.getBase().getStatistic(PLAY_ONE_TICK) * 50);
sender.sendMessage(tl("whoisPlaytime", DateUtil.formatDateDiff(playtimeMs)));
if (!ess.getSettings().isEcoDisabled()) {
Expand Down

0 comments on commit c705a7b

Please sign in to comment.