Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
added highlight command
  • Loading branch information
dries007 committed Aug 1, 2017
1 parent ada7d95 commit e79d0b8
Show file tree
Hide file tree
Showing 3 changed files with 129 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/main/java/net/doubledoordev/d3commands/D3Commands.java
Expand Up @@ -86,7 +86,8 @@ public void preInit(FMLPreInitializationEvent event)
new BasicCommandEntry(CommandPos.class, "pos", true, "Get other players coordinates."),
new BasicCommandEntry(CommandExplorers.class, "analiselocations", true, "Analise locations of online players."),
new BasicCommandEntry(CommandSmite.class, "smite", true, "Power! UNLIMITED POWER."),
new BasicCommandEntry(CommandFireworks.class, "fireworks", true, "Needs more fireworks.")
new BasicCommandEntry(CommandFireworks.class, "fireworks", true, "Needs more fireworks."),
new BasicCommandEntry(CommandHighlight.class, "heal", true, "Set/remove outline for a player.")
};
for (CommandEntry e : a)
{
Expand Down
@@ -0,0 +1,125 @@
/*
* Copyright (c) 2014-2016, Dries007 & DoubleDoorDevelopment
* 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.
*
* 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 net.minecraft.command.CommandBase;
import net.minecraft.command.CommandException;
import net.minecraft.command.ICommandSender;
import net.minecraft.command.PlayerNotFoundException;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.network.datasync.DataParameter;
import net.minecraft.network.datasync.DataSerializers;
import net.minecraft.network.datasync.EntityDataManager;
import net.minecraft.network.play.server.SPacketEntityMetadata;
import net.minecraft.server.MinecraftServer;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.text.TextComponentTranslation;
import net.minecraftforge.common.util.FakePlayer;

import javax.annotation.Nullable;
import java.util.List;

public class CommandHighlight extends CommandBase
{
@Override
public String getCommandName()
{
return "highlight";
}

@Override
public String getCommandUsage(ICommandSender icommandsender)
{
return "/highlight [target] [true|false]";
}

@Override
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException
{
if (args.length == 0)
{
getCommandSenderAsPlayer(sender).setGlowing(getCommandSenderAsPlayer(sender).isGlowing());
sender.addChatMessage(new TextComponentTranslation("d3.cmd.highlight.success", sender.getDisplayName()));
return;
}
if (args.length == 1)
{
try
{
getCommandSenderAsPlayer(sender).setGlowing(parseBoolean(args[0]));
sender.addChatMessage(new TextComponentTranslation("d3.cmd.highlight.success", sender.getDisplayName()));
}
catch (CommandException ignored)
{
for (Entity e : getEntityList(server, sender, args[0]))
{
e.setGlowing(!e.isGlowing());
}
}
return;
}
boolean b = parseBoolean(args[1]);
for (Entity e : getEntityList(server, sender, args[0]))
{
e.setGlowing(b);
}
// target.setGlowing(!target.isGlowing());
//
// DataParameter<Byte> FLAGS = new DataParameter<>(0, DataSerializers.BYTE);
// EntityDataManager dm = target.getDataManager();
// EntityDataManager fake = new EntityDataManager(target);
// fake.register(FLAGS, (byte) (dm.get(FLAGS) & (1 << 6)));
//
// EntityPlayerMP senderMP = getCommandSenderAsPlayer(sender);
//
// SPacketEntityMetadata p = new SPacketEntityMetadata(target.getEntityId(), dm, false);
// senderMP.connection.sendPacket(p);
//
// sender.addChatMessage(new TextComponentTranslation("d3.cmd.highlight.success", target.getDisplayName()));
}

@Override
public int getRequiredPermissionLevel()
{
return 2;
}

@Override
public boolean isUsernameIndex(final String[] args, final int userIndex)
{
return userIndex == 0;
}

@Override
public List<String> getTabCompletionOptions(MinecraftServer server, ICommandSender sender, String[] args, @Nullable BlockPos pos)
{
if (args.length == 1) return getListOfStringsMatchingLastWord(args, server.getAllUsernames());
if (args.length == 2) return getListOfStringsMatchingLastWord(args, "true", "false");
return super.getTabCompletionOptions(server, sender, args, pos);
}
}
2 changes: 2 additions & 0 deletions src/main/resources/assets/d3commands/lang/en_US.lang
Expand Up @@ -8,6 +8,8 @@ d3.cmd.back.failed=Could not find a death point to return to for %s

d3.cmd.feed.success=Fed %s

d3.cmd.highlight.success=Poofed fairy dust at %s

d3.cmd.fly.success.on=I believe %s can fly!
d3.cmd.fly.success.off=No more flying for %s

Expand Down

0 comments on commit e79d0b8

Please sign in to comment.