Skip to content

Commit

Permalink
Added "getuuid" command
Browse files Browse the repository at this point in the history
  • Loading branch information
dries007 committed Aug 20, 2014
1 parent 2fd4bd6 commit c976ea5
Show file tree
Hide file tree
Showing 2 changed files with 105 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/main/java/net/doubledoordev/d3commands/D3Commands.java
Expand Up @@ -4,6 +4,7 @@
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.event.FMLServerStartingEvent;
import net.doubledoordev.d3commands.commands.CommandGetUUID;
import net.doubledoordev.d3commands.commands.CommandKill;
import net.doubledoordev.d3commands.commands.CommandTps;
import net.doubledoordev.d3commands.commands.CommandTpx;
Expand All @@ -25,6 +26,7 @@ public class D3Commands implements ID3Mod
private boolean tps = true;
private boolean tpx = true;
private boolean kill = true;
private boolean getuuid = true;
public Configuration configuration;

@Mod.EventHandler
Expand All @@ -44,6 +46,7 @@ public void syncConfig()
tps = configuration.getBoolean("tps", MODID, tps, "A TPS command for all players, not just ops.");
tpx = configuration.getBoolean("tpx", MODID, tpx, "Interdimensional TP command.");
kill = configuration.getBoolean("kill", MODID, kill, "Allow you to kill other players.");
getuuid = configuration.getBoolean("getuuid", MODID, getuuid, "Allows easy UUID grabbing.");

if (configuration.hasChanged()) configuration.save();
}
Expand All @@ -57,9 +60,10 @@ public void addConfigElements(List<IConfigElement> configElements)
@Mod.EventHandler
public void serverStarting(FMLServerStartingEvent event)
{
if (tps) event.registerServerCommand(new CommandTps());
if (tpx) event.registerServerCommand(new CommandTpx());
if (kill) event.registerServerCommand(new CommandKill());
if (tps) event.registerServerCommand(new CommandTps());
if (tpx) event.registerServerCommand(new CommandTpx());
if (kill) event.registerServerCommand(new CommandKill());
if (getuuid) event.registerServerCommand(new CommandGetUUID());
}
}

@@ -0,0 +1,98 @@
/*
* Copyright (c) 2014,
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* Neither the name of the {organization} nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*
*/

package net.doubledoordev.d3commands.commands;

import com.mojang.authlib.GameProfile;
import net.minecraft.command.CommandBase;
import net.minecraft.command.ICommandSender;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.management.ServerConfigurationManager;
import net.minecraft.util.ChatComponentText;
import net.minecraft.util.EnumChatFormatting;

import java.util.List;

/**
* @author Dries007
*/
public class CommandGetUUID extends CommandBase
{
@Override
public String getCommandName()
{
return "getuuid";
}

@Override
public String getCommandUsage(ICommandSender p_71518_1_)
{
return "/getuuid [username] [username 2] [...]";
}

@Override
public void processCommand(ICommandSender sender, String[] args)
{
ServerConfigurationManager scm = MinecraftServer.getServer().getConfigurationManager();
if (args.length == 0)
{
sender.addChatMessage(new ChatComponentText(EnumChatFormatting.GOLD + "All online players:"));
for (GameProfile gp : scm.func_152600_g())
{
sender.addChatMessage(new ChatComponentText(gp.getName() + " -> " + gp.getId()));
}
}
else
{
sender.addChatMessage(new ChatComponentText(EnumChatFormatting.GOLD + "All listed players:"));
for (String name : args)
{
EntityPlayerMP player = scm.func_152612_a(name);
if (player == null) sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "No player with name " + name));
else sender.addChatMessage(new ChatComponentText(player.getCommandSenderName() + " -> " + player.getUniqueID()));
}
}
}

@Override
public boolean isUsernameIndex(String[] p_82358_1_, int p_82358_2_)
{
return true;
}

@Override
public List addTabCompletionOptions(ICommandSender sender, String[] args)
{
return getListOfStringsMatchingLastWord(args, MinecraftServer.getServer().getAllUsernames());
}
}

0 comments on commit c976ea5

Please sign in to comment.