Created
July 27, 2014 10:38
-
-
Save FormallyMyles/25dde243da1f64be75fe to your computer and use it in GitHub Desktop.
Example using Auto-Boxing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package us.myles.trapexamples.api; | |
@TrapTag | |
public interface CraftPlayer { | |
public EntityPlayer getHandle(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package us.myles.trapexamples.api; | |
import us.myles.classtrap.TrapTag; | |
import us.myles.classtrap.TrapTagType; | |
@TrapTag | |
public interface EntityPlayer { | |
@TrapTag(type = TrapTagType.GETTER, value = "playerConnection") | |
public PlayerConnection getPlayerConnection(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package us.myles.trapexamples; | |
import org.bukkit.command.Command; | |
import org.bukkit.command.CommandSender; | |
import org.bukkit.entity.Player; | |
import org.bukkit.plugin.java.JavaPlugin; | |
import us.myles.classtrap.MCUtils; | |
import us.myles.classtrap.Trap; | |
import us.myles.trapexamples.api.CraftPlayer; | |
import us.myles.trapexamples.api.EntityPlayer; | |
import us.myles.trapexamples.api.PlayerConnection; | |
public class Example extends JavaPlugin { | |
public void onEnable() { | |
} | |
@Override | |
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { | |
if (sender instanceof Player) { | |
CraftPlayer cp = Trap.create(CraftPlayer.class, sender); | |
Object packet = MCUtils.makeNMS("PacketPlayOutUpdateHealth", 10f, 5, 1f); | |
cp.getHandle().getPlayerConnection().sendPacket(packet); | |
} | |
return true; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package us.myles.trapexamples.api; | |
import us.myles.classtrap.TrapTag; | |
import us.myles.classtrap.TrapTagType; | |
@TrapTag | |
public interface PlayerConnection { | |
@TrapTag(type = TrapTagType.METHOD, value = "sendPacket") | |
public void sendPacket(Object packet); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment