SHARE
TWEET

Untitled

a guest Dec 14th, 2019 90 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package com.picono435.randomtp;
  2.  
  3. import java.util.List;
  4. import java.util.Random;
  5.  
  6. import com.google.common.collect.Lists;
  7.  
  8. import net.minecraft.command.CommandBase;
  9. import net.minecraft.command.CommandException;
  10. import net.minecraft.command.ICommandSender;
  11. import net.minecraft.entity.player.EntityPlayerMP;
  12. import net.minecraft.server.MinecraftServer;
  13. import net.minecraft.util.text.TextComponentString;
  14. import net.minecraft.util.text.TextFormatting;
  15. import net.minecraft.world.World;
  16. import net.minecraft.world.border.WorldBorder;
  17. import net.minecraftforge.fml.common.FMLCommonHandler;
  18.  
  19.  
  20.  
  21.  
  22. public class RTPCommand extends CommandBase {
  23.  
  24.       private final List<String> aliases = Lists.newArrayList(MainMod.MODID, "randomtp", "rtp", "randomteleport", "rteleport", "rndtp", "rndteleport");
  25.    
  26.       public int coolDown = 0;
  27.       public boolean canUse;
  28.      
  29.   @Override
  30.   public void execute(MinecraftServer server, ICommandSender sender, String[] params) throws CommandException {
  31.     int results = Integer.parseInt(ConfigHandler.getString("command", "cooldown"));
  32.     int stot = 20*results;
  33.     TextComponentString text = new TextComponentString("Succefully teleported you to a random location.");
  34.     text.getStyle().setColor(TextFormatting.GREEN);
  35.     TextComponentString text2 = new TextComponentString(ConfigHandler.getString("command", "cooldown") + "eee" + stot);
  36.     MinecraftServer serverf = FMLCommonHandler.instance().getMinecraftServerInstance();
  37.     World world = getCommandSenderAsPlayer(sender).getEntityWorld();
  38.     WorldBorder border = world.getWorldBorder();
  39.     EntityPlayerMP player = getCommandSenderAsPlayer(sender);
  40.     if(canUse == true) {
  41.     server.getCommandManager().executeCommand(serverf, "aspreadplayers " + border.getCenterX() + " " + border.getCenterZ() + " 1" + " " + border.getDiameter()/2 + " false " + player.getDisplayNameString());
  42.     player.sendMessage(text);
  43.     player.sendMessage(text2);
  44.     }
  45.     if(coolDown <= 0) {
  46.         coolDown = stot;
  47.    }
  48.     if(canUse == false) {
  49.         TextComponentString text3 = new TextComponentString("You need to wait more " + coolDown + " seconds.");
  50.         text3.getStyle().setColor(TextFormatting.RED);
  51.         player.sendMessage(text3);
  52.     }
  53.   }
  54.  
  55.   @Override
  56.   public void onUpdate(MinecraftServer server, ICommandSender sender, String[] params) {
  57.       if(coolDown > 0) {
  58.           coolDown--;
  59.           canUse = false;
  60.       }
  61.       if(coolDown == 0) {
  62.           canUse = true;
  63.       }
  64.   }
  65.  
  66.   @Override
  67.   public String getName() {
  68.     return "randomtp";
  69.   }
  70.  
  71.   @Override
  72.   public String getUsage(ICommandSender sender) {
  73.     return "Use /randomtp";
  74.   }
  75.  
  76.  
  77.  
  78. @Override
  79. public List<String> getAliases()
  80. {
  81.     return aliases;
  82. }
  83.  
  84.   @Override
  85.   public boolean checkPermission(MinecraftServer server, ICommandSender sender) {
  86.       return true;
  87.   }
  88.  
  89.  
  90. }
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