Advertisement
thevipershowita

Untitled

Jul 25th, 2019
581
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.91 KB | None | 0 0
  1. package me.tylercreator.fallensurv.spawnmodifier;
  2.  
  3. import java.security.PublicKey;
  4. import java.util.Random;
  5.  
  6. import org.apache.logging.log4j.core.config.plugins.Plugin;
  7. import org.bukkit.Bukkit;
  8. import org.bukkit.ChatColor;
  9. import org.bukkit.Location;
  10. import org.bukkit.configuration.file.FileConfiguration;
  11. import org.bukkit.craftbukkit.Main;
  12. import org.bukkit.event.EventHandler;
  13. import org.bukkit.event.Listener;
  14. import org.bukkit.event.player.PlayerJoinEvent;
  15.  
  16. import me.tylercreator.fallensurv.main;
  17.  
  18.  
  19. public class Spawnmodifier implements Listener{
  20.    
  21.  
  22.    
  23.    
  24.    
  25.     @EventHandler
  26.     public void randomspawn(PlayerJoinEvent pj) {
  27.        
  28.        
  29.         public static final FileConfiguration config = main.plugin.getConfig();
  30.        
  31.        
  32.         int PlayerJoinLocX = pj.getPlayer().getLocation().getBlockX();
  33.         int PlayerJoinLocY = pj.getPlayer().getLocation().getBlockY();
  34.         int PlayerJoinLocZ = pj.getPlayer().getLocation().getBlockZ();
  35.        
  36.         boolean newplayer = pj.getPlayer().hasPlayedBefore();
  37.         String playername = pj.getPlayer().getName();
  38.        
  39.         Random random = new Random();
  40.        
  41.        
  42.        
  43.         int low = config.getInt("minimumTeleport");
  44.         int high = config.getInt("maximumTeleport");
  45.        
  46.         //int low= 250; minimum random value
  47.         //int high= 1750; //max random value
  48.        
  49.         int resultX = random.nextInt(high-low) + low; //random X function
  50.         int resultZ = random.nextInt(high-low) + low; //random Z function
  51.        
  52.         Location loc = pj.getPlayer().getLocation().add(resultX, 0, resultZ);
  53.                        
  54.         if(newplayer) {
  55.                        
  56.             Bukkit.getPlayer(playername).sendMessage(ChatColor.AQUA + "Welcome back, remember to watch out for other players...");
  57.         } else {
  58.            
  59.             pj.getPlayer().teleport(loc);
  60.            
  61.             Bukkit.getPlayer(playername).sendMessage(ChatColor.RED + "Welcome! This is the FallenSurvivor gamemode!");
  62.             Bukkit.getPlayer(playername).sendMessage(ChatColor.RED + "Read the gamemode mechanics with /fs help");
  63.         }
  64.        
  65.     }
  66.  
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement