SHARE
TWEET

Speed v.1.1

rotorwash47 Dec 11th, 2019 (edited) 98 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package com.rotor.speed;
  2.  
  3. import org.bukkit.Bukkit;
  4. import org.bukkit.command.Command;
  5. import org.bukkit.command.CommandSender;
  6. import org.bukkit.entity.Player;
  7. import org.bukkit.event.EventHandler;
  8. import org.bukkit.event.Listener;
  9. import org.bukkit.event.player.PlayerMoveEvent;
  10. import org.bukkit.plugin.java.JavaPlugin;
  11. import org.bukkit.potion.PotionEffect;
  12. import org.bukkit.potion.PotionEffectType;
  13.  
  14. public class Main extends JavaPlugin implements Listener {
  15.  
  16.     int speed = 0;
  17.    
  18.     @Override
  19.     public void onEnable() {
  20.         System.out.println("Speed is enabled");
  21.        
  22.         this.getConfig().options().copyDefaults();
  23.         saveDefaultConfig();
  24.        
  25.         Bukkit.getPluginManager().registerEvents(this,  this);
  26.     }
  27.    
  28.     public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
  29.            
  30.         if (cmd.getName().equals("speed")) {
  31.             Player player = (Player) sender;
  32.             if(player.hasPermission("speed.speed")) {
  33.                 if (speed == 1) {
  34.                     if (sender instanceof Player) {
  35.                         String speedDisabled = this.getConfig().getString("speedDisabled");
  36.                         player.sendMessage(speedDisabled);
  37.                         speed = 0;
  38.                     }
  39.                 } else {
  40.                     if (sender instanceof Player) {
  41.                         String speedEnabled = this.getConfig().getString("speedEnabled");
  42.                         player.sendMessage(speedEnabled);
  43.                         speed = 1;
  44.                     }
  45.                 }
  46.             } else {
  47.                 String noPermission = this.getConfig().getString("noPermission");
  48.                 player.sendMessage(noPermission);
  49.             }
  50.         }
  51.         return false;
  52.     }
  53.    
  54.     @EventHandler
  55.     public void onMove(PlayerMoveEvent e) {
  56.         if (speed == 1) {
  57.             Player player = e.getPlayer();
  58.             int x = this.getConfig().getInt("speedMultiplier");
  59.             player.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 1, x - 1));
  60.         }
  61.     }
  62. }
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
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top