mirror of
https://github.com/TheDeus-Group/TFM-4.3-Reloaded.git
synced 2024-12-23 02:04:57 +00:00
Migrate to essx (closes #34)
This commit is contained in:
parent
01e12a617b
commit
bd564798f0
2 changed files with 60 additions and 1 deletions
|
@ -0,0 +1,53 @@
|
||||||
|
package me.StevenLawson.TotalFreedomMod.commands;
|
||||||
|
|
||||||
|
import com.earth2me.essentials.User;
|
||||||
|
import me.StevenLawson.TotalFreedomMod.bridge.EssentialsBridge;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.OfflinePlayer;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
@CommandPermissions(level = AdminLevel.SUPER, source = SourceType.ONLY_IN_GAME)
|
||||||
|
public class Command_offlinetp extends FreedomCommand {
|
||||||
|
@Override
|
||||||
|
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) {
|
||||||
|
if(args.length < 1) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
OfflinePlayer target = null;
|
||||||
|
String searchString = args[0];
|
||||||
|
|
||||||
|
for (OfflinePlayer offlinePlayer : Bukkit.getOfflinePlayers()) {
|
||||||
|
if(offlinePlayer.getName().equalsIgnoreCase(searchString)) {
|
||||||
|
target = offlinePlayer;
|
||||||
|
break;
|
||||||
|
} else if (offlinePlayer.getName().startsWith(searchString.toLowerCase())) {
|
||||||
|
target = offlinePlayer;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(target == null) {
|
||||||
|
playerMsg(sender, FreedomCommand.PLAYER_NOT_FOUND);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(target.isOnline()) {
|
||||||
|
playerMsg(sender, "That player is already online. Use /tp.");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
playerMsg(sender, String.format("Teleporting to %s's last known location...", target.getName()));
|
||||||
|
try {
|
||||||
|
Location location = EssentialsBridge.getEssentialsUser(target.getName()).getLastLocation();
|
||||||
|
sender_p.teleport(location);
|
||||||
|
} catch (Exception e) {
|
||||||
|
playerMsg(sender, "Oops");
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,5 +1,6 @@
|
||||||
package me.StevenLawson.TotalFreedomMod.commands;
|
package me.StevenLawson.TotalFreedomMod.commands;
|
||||||
|
|
||||||
|
import me.StevenLawson.TotalFreedomMod.util.Utilities;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
|
@ -14,6 +15,10 @@ import java.nio.file.Paths;
|
||||||
public class Command_resetplayer extends FreedomCommand {
|
public class Command_resetplayer extends FreedomCommand {
|
||||||
@Override
|
@Override
|
||||||
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) {
|
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) {
|
||||||
|
if(args.length < 1) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
OfflinePlayer target = null;
|
OfflinePlayer target = null;
|
||||||
String searchString = args[0];
|
String searchString = args[0];
|
||||||
|
|
||||||
|
@ -36,7 +41,8 @@ public class Command_resetplayer extends FreedomCommand {
|
||||||
target.getPlayer().kickPlayer(ChatColor.RED + "YOU ARE BEING RESET.");
|
target.getPlayer().kickPlayer(ChatColor.RED + "YOU ARE BEING RESET.");
|
||||||
}
|
}
|
||||||
|
|
||||||
playerMsg(sender, String.format("Resetting %s's user data (excluding TFM)...", target.getName()));
|
Utilities.adminAction(sender.getName(), String.format("Resetting %s's player data", target.getName()), true);
|
||||||
|
playerMsg(sender, String.format("Resetting %s's player data (excluding TFM)...", target.getName()));
|
||||||
try {
|
try {
|
||||||
String uuid = target.getUniqueId().toString();
|
String uuid = target.getUniqueId().toString();
|
||||||
Files.deleteIfExists(Paths.get(".", "world", "playerdata", uuid + ".dat"));
|
Files.deleteIfExists(Paths.get(".", "world", "playerdata", uuid + ".dat"));
|
||||||
|
|
Loading…
Reference in a new issue