Adjusted RandomTP to be static
This commit is contained in:
parent
6dab69e2c9
commit
4c812b5129
3 changed files with 56 additions and 48 deletions
27
src/alisolarflare/DebugRTP.java
Normal file
27
src/alisolarflare/DebugRTP.java
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
package alisolarflare;
|
||||||
|
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandExecutor;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
public class DebugRTP implements CommandExecutor {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
|
if(!(sender instanceof Player)){
|
||||||
|
sender.sendMessage("You must be a Player to use this command!");
|
||||||
|
sender.sendMessage(sender.toString());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
Player player = (Player) sender;
|
||||||
|
if(player.getWorld().getName() != "hardcore"){
|
||||||
|
sender.sendMessage("You must be in the hardcore world to use this command!");
|
||||||
|
sender.sendMessage("Current World: " + player.getWorld().getName());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
RandomTPModule.rtp(player, player.getWorld(), new Location(player.getWorld(), 644, 65, -944), new Location(player.getWorld(), 1700, 65, 464));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,33 +1,31 @@
|
||||||
package alisolarflare;
|
package alisolarflare;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.command.Command;
|
|
||||||
import org.bukkit.command.CommandExecutor;
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import iie.HelloWorldPlugin;
|
import iie.HelloWorldPlugin;
|
||||||
|
|
||||||
public class RandomTP implements CommandExecutor{
|
public class RandomTPModule{
|
||||||
|
private static int conflictX;
|
||||||
private int conflictX;
|
private static int conflictZ;
|
||||||
private int conflictZ;
|
private static int conflictRadius = 70;
|
||||||
private int conflictRadius = 70;
|
private static boolean northUsed;
|
||||||
private boolean northUsed;
|
private static boolean southUsed;
|
||||||
private boolean southUsed;
|
private static boolean eastUsed;
|
||||||
private boolean eastUsed;
|
private static boolean westUsed;
|
||||||
private boolean westUsed;
|
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
private HelloWorldPlugin helloWorldPlugin;
|
private HelloWorldPlugin helloWorldPlugin;
|
||||||
public RandomTP(HelloWorldPlugin helloWorldPlugin) {
|
public RandomTPModule(HelloWorldPlugin helloWorldPlugin) {
|
||||||
this.helloWorldPlugin = helloWorldPlugin;
|
this.helloWorldPlugin = helloWorldPlugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
//every 4 players who use it will be teleported near each other.
|
//every 4 players who use it will be teleported near each other.
|
||||||
//ex. iie > 1200, ali -> 1210, byz -> 1190, charles -> 1195, wind -> 300, zan -> 310, etc
|
//ex. iie 2000, ali 2010, byz 2005, charles 1995, wind 300, zan 310, etc
|
||||||
public void conflictRtp(Player player, World world, Location minLocation, Location maxLocation){
|
public static void conflictRtp(Player player, World world, Location minLocation, Location maxLocation){
|
||||||
//INIT - xDifference, xAverage
|
//INIT - xDifference, xAverage
|
||||||
int xdifference = minLocation.getBlockX() - maxLocation.getBlockX();
|
int xdifference = minLocation.getBlockX() - maxLocation.getBlockX();
|
||||||
int xAverage = (int) Math.floor(minLocation.getBlockX() + maxLocation.getBlockX() / 2);
|
int xAverage = (int) Math.floor(minLocation.getBlockX() + maxLocation.getBlockX() / 2);
|
||||||
|
@ -59,10 +57,10 @@ public class RandomTP implements CommandExecutor{
|
||||||
//TRANSFER - data to class
|
//TRANSFER - data to class
|
||||||
if (groundIsSafe && (northIsSafe || southIsSafe || eastIsSafe || westIsSafe)){
|
if (groundIsSafe && (northIsSafe || southIsSafe || eastIsSafe || westIsSafe)){
|
||||||
|
|
||||||
northUsed = northIsSafe;
|
northUsed = !northIsSafe;
|
||||||
eastUsed = eastIsSafe;
|
eastUsed = !eastIsSafe;
|
||||||
westUsed = westIsSafe;
|
westUsed = !westIsSafe;
|
||||||
southUsed = southIsSafe;
|
southUsed = !southIsSafe;
|
||||||
conflictX = attemptedX;
|
conflictX = attemptedX;
|
||||||
conflictZ = attemptedZ;
|
conflictZ = attemptedZ;
|
||||||
|
|
||||||
|
@ -74,28 +72,28 @@ public class RandomTP implements CommandExecutor{
|
||||||
|
|
||||||
String dir = "north";
|
String dir = "north";
|
||||||
//CHOOSES A RANDOM DIRECTION
|
//CHOOSES A RANDOM DIRECTION
|
||||||
for(int i = 0; i < 1000; i++){
|
for(int i = 0; i < 200; i++){
|
||||||
double randomDirection = Math.random();
|
double randomDirection = Math.random();
|
||||||
if (randomDirection < 0.25){
|
if (randomDirection < 0.25){
|
||||||
if(northUsed){
|
if(!northUsed){
|
||||||
northUsed = true;
|
northUsed = true;
|
||||||
dir = "north";
|
dir = "north";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}else if(randomDirection < 0.50){
|
}else if(randomDirection < 0.50){
|
||||||
if(eastUsed){
|
if(!eastUsed){
|
||||||
eastUsed = true;
|
eastUsed = true;
|
||||||
dir = "east";
|
dir = "east";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}else if(randomDirection < 0.75){
|
}else if(randomDirection < 0.75){
|
||||||
if(southUsed){
|
if(!southUsed){
|
||||||
southUsed = true;
|
southUsed = true;
|
||||||
dir = "south";
|
dir = "south";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
if(westUsed){
|
if(!westUsed){
|
||||||
westUsed = true;
|
westUsed = true;
|
||||||
dir = "west";
|
dir = "west";
|
||||||
break;
|
break;
|
||||||
|
@ -108,19 +106,15 @@ public class RandomTP implements CommandExecutor{
|
||||||
//TELEPORT - teleports player to the conflict point
|
//TELEPORT - teleports player to the conflict point
|
||||||
switch(dir){
|
switch(dir){
|
||||||
case "north":
|
case "north":
|
||||||
northUsed = false;
|
|
||||||
player.teleport(world.getHighestBlockAt(conflictX, conflictZ - conflictRadius).getLocation());
|
player.teleport(world.getHighestBlockAt(conflictX, conflictZ - conflictRadius).getLocation());
|
||||||
break;
|
break;
|
||||||
case "east":
|
case "east":
|
||||||
eastUsed = false;
|
|
||||||
player.teleport(world.getHighestBlockAt(conflictX + conflictRadius, conflictZ).getLocation());
|
player.teleport(world.getHighestBlockAt(conflictX + conflictRadius, conflictZ).getLocation());
|
||||||
break;
|
break;
|
||||||
case "south":
|
case "south":
|
||||||
southUsed = false;
|
|
||||||
player.teleport(world.getHighestBlockAt(conflictX, conflictZ + conflictRadius).getLocation());
|
player.teleport(world.getHighestBlockAt(conflictX, conflictZ + conflictRadius).getLocation());
|
||||||
break;
|
break;
|
||||||
case "west":
|
case "west":
|
||||||
westUsed = false;
|
|
||||||
player.teleport(world.getHighestBlockAt(conflictX - conflictRadius, conflictZ).getLocation());
|
player.teleport(world.getHighestBlockAt(conflictX - conflictRadius, conflictZ).getLocation());
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -130,7 +124,7 @@ public class RandomTP implements CommandExecutor{
|
||||||
}
|
}
|
||||||
|
|
||||||
//Randomly teleports a player, into the hardcore world
|
//Randomly teleports a player, into the hardcore world
|
||||||
public void rtp(Player player, World world, Location minLocation, Location maxLocation){
|
public static void rtp(Player player, World world, Location minLocation, Location maxLocation){
|
||||||
player.sendMessage("TELEPORT INITIATED");
|
player.sendMessage("TELEPORT INITIATED");
|
||||||
player.sendMessage("minLocation: " + minLocation.toString());
|
player.sendMessage("minLocation: " + minLocation.toString());
|
||||||
player.sendMessage("maxLocation: " + maxLocation.toString());
|
player.sendMessage("maxLocation: " + maxLocation.toString());
|
||||||
|
@ -163,21 +157,4 @@ public class RandomTP implements CommandExecutor{
|
||||||
//player.teleport(arg0)
|
//player.teleport(arg0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
|
||||||
if(!(sender instanceof Player)){
|
|
||||||
sender.sendMessage("You must be a Player to use this command!");
|
|
||||||
sender.sendMessage(sender.toString());
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
Player player = (Player) sender;
|
|
||||||
if(player.getWorld().getName() != "hardcore"){
|
|
||||||
sender.sendMessage("You must be in the hardcore world to use this command!");
|
|
||||||
sender.sendMessage("Current World: " + player.getWorld().getName());
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
rtp(player, player.getWorld(), new Location(player.getWorld(), 644, 65, -944), new Location(player.getWorld(), 1700, 65, 464));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
|
@ -10,7 +10,9 @@ import org.bukkit.plugin.java.JavaPlugin;
|
||||||
import org.bukkit.scoreboard.Objective;
|
import org.bukkit.scoreboard.Objective;
|
||||||
import org.bukkit.scoreboard.Scoreboard;
|
import org.bukkit.scoreboard.Scoreboard;
|
||||||
|
|
||||||
import alisolarflare.RandomTP;
|
import alisolarflare.DebugRTP;
|
||||||
|
import alisolarflare.RandomTPModule;
|
||||||
|
import alisolarflare.listeners.CompassLobby;
|
||||||
import alisolarflare.listeners.ConflictCompassCraftingListener;
|
import alisolarflare.listeners.ConflictCompassCraftingListener;
|
||||||
import alisolarflare.listeners.DiamondArmorBlocker;
|
import alisolarflare.listeners.DiamondArmorBlocker;
|
||||||
|
|
||||||
|
@ -50,14 +52,16 @@ public class HelloWorldPlugin extends JavaPlugin {
|
||||||
getServer().getPluginManager().registerEvents(new JoinListener(this), this);
|
getServer().getPluginManager().registerEvents(new JoinListener(this), this);
|
||||||
getServer().getPluginManager().registerEvents(new DeathListener(this), this);
|
getServer().getPluginManager().registerEvents(new DeathListener(this), this);
|
||||||
getServer().getPluginManager().registerEvents(new BoundaryListener(this), this);
|
getServer().getPluginManager().registerEvents(new BoundaryListener(this), this);
|
||||||
|
|
||||||
getServer().getPluginManager().registerEvents(new DiamondArmorBlocker(), this);
|
getServer().getPluginManager().registerEvents(new DiamondArmorBlocker(), this);
|
||||||
getServer().getPluginManager().registerEvents(new ConflictCompassCraftingListener(), this);
|
getServer().getPluginManager().registerEvents(new ConflictCompassCraftingListener(), this);
|
||||||
|
getServer().getPluginManager().registerEvents(new CompassLobby(), this);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
public void registerCommands(){
|
public void registerCommands(){
|
||||||
getCommand("hardcore").setExecutor(new HelloWorld(this));
|
getCommand("hardcore").setExecutor(new HelloWorld(this));
|
||||||
getCommand("debugRTP").setExecutor(new RandomTP(this));
|
getCommand("debugRTP").setExecutor(new DebugRTP());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
Loading…
Reference in a new issue