This commit is contained in:
BuildTools 2016-10-22 21:03:38 -04:00
commit 740ac21fec
3 changed files with 57 additions and 52 deletions

View 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;
}
}

View file

@ -1,38 +1,32 @@
package alisolarflare; package alisolarflare;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; 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();
@ -66,10 +60,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;
@ -81,6 +75,7 @@ public class RandomTP implements CommandExecutor{
String dir = "north"; String dir = "north";
//CHOOSES A RANDOM DIRECTION
ArrayList<String> directions = new ArrayList<String>(); ArrayList<String> directions = new ArrayList<String>();
if(!northUsed) directions.add("north"); if(!northUsed) directions.add("north");
if(!southUsed) directions.add("south"); if(!southUsed) directions.add("south");
@ -88,29 +83,29 @@ public class RandomTP implements CommandExecutor{
if(!eastUsed) directions.add("east"); if(!eastUsed) directions.add("east");
dir = directions.get((int) Math.floor(Math.random() * directions.size())); dir = directions.get((int) Math.floor(Math.random() * directions.size()));
//CHOOSES A RANDOM DIRECTION /*
/*for(int i = 0; i < 1000; i++){ for(int i = 0; i < 1000; 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;
@ -123,19 +118,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:
@ -145,7 +136,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());
@ -178,21 +169,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;
}
} }

View file

@ -9,7 +9,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;
@ -46,14 +48,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());
} }
} }