Created
February 10, 2013 03:56
-
-
Save aadnk/4748292 to your computer and use it in GitHub Desktop.
Force the end credits on an unsuspecting player.
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 com.comphenix.example; | |
import net.minecraft.server.v1_4_R1.EntityPlayer; | |
import net.minecraft.server.v1_4_R1.Packet70Bed; | |
import org.bukkit.ChatColor; | |
import org.bukkit.command.Command; | |
import org.bukkit.command.CommandSender; | |
import org.bukkit.craftbukkit.v1_4_R1.entity.CraftPlayer; | |
import org.bukkit.entity.Player; | |
import org.bukkit.event.Listener; | |
import org.bukkit.plugin.java.JavaPlugin; | |
public class ForceEnd extends JavaPlugin implements Listener { | |
@Override | |
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { | |
if (sender instanceof Player) { | |
displayCredits((Player) sender); | |
} else { | |
sender.sendMessage(ChatColor.RED + "Must be a player."); | |
} | |
return true; | |
} | |
private void displayCredits(Player player) { | |
CraftPlayer craft = (CraftPlayer) player; | |
EntityPlayer nms = craft.getHandle(); | |
nms.viewingCredits = true; | |
nms.playerConnection.sendPacket(new Packet70Bed(4, 0)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Updated for 1.8: https://gist.github.com/Zeryther/95b7212dcbdfc4e818c6