Alright let's see what happens with this conflicting commit

# Conflicts:
#	src/iie/DeathListener.java
#	src/iie/HelloWorldPlugin.java
This commit is contained in:
BuildTools 2016-08-31 14:14:05 -04:00
commit 172c1224f8
3 changed files with 193 additions and 11 deletions

View file

@ -7,32 +7,144 @@ import org.bukkit.entity.Player;
public class RandomTP{
//Randomly teleports a player, into the hardcore world
public void rtp(Player player, World world, Location minLocation, Location maxLocation){
private int conflictX;
private int conflictZ;
private int conflictRadius = 70;
private boolean northUsed;
private boolean southUsed;
private boolean eastUsed;
private boolean westUsed;
//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
public void conflictRtp(Player player, World world, Location minLocation, Location maxLocation){
//INIT - xDifference, xAverage
int xdifference = minLocation.getBlockX() - maxLocation.getBlockX();
int xAverage = (int) Math.floor(minLocation.getBlockX() + maxLocation.getBlockX() / 2);
//INIT - zDifference, zAverage
int zdifference = minLocation.getBlockX() - maxLocation.getBlockY();
int zAverage = (int) Math.floor(minLocation.getBlockZ() + maxLocation.getBlockZ());
//CHECK - Reset Cycle
if ((northUsed || southUsed || eastUsed || westUsed) == false){
//Tries 20 times to find a location
for(int i = 0; i < 20; i ++){
//INIT - attemptedX, attemptedZ
int attemptedX = (int) Math.floor((Math.random()-0.5)*xdifference) + xAverage;
int attemptedZ = (int) Math.floor((Math.random()-0.5)*zdifference) + zAverage;
int cr = conflictRadius;
//CHECKS - if ground is safe
boolean groundIsSafe = world.getHighestBlockAt(attemptedX, attemptedZ).getType() != Material.WATER;
boolean northIsSafe = world.getHighestBlockAt(attemptedX, attemptedZ-cr).getType() != Material.WATER;
boolean eastIsSafe = world.getHighestBlockAt(attemptedX+cr, attemptedZ).getType() != Material.WATER;
boolean southIsSafe = world.getHighestBlockAt(attemptedX, attemptedZ+cr).getType() != Material.WATER;
boolean westIsSafe = world.getHighestBlockAt(attemptedX-cr, attemptedZ).getType() != Material.WATER;
//TRANSFER - data to class
if (groundIsSafe && (northIsSafe || southIsSafe || eastIsSafe || westIsSafe)){
northUsed = northIsSafe;
eastUsed = eastIsSafe;
westUsed = westIsSafe;
southUsed = southIsSafe;
conflictX = attemptedX;
conflictZ = attemptedZ;
player.teleport(world.getHighestBlockAt(attemptedX, attemptedZ).getLocation());
break;
}
}
}
String dir = "north";
//CHOOSES A RANDOM DIRECTION
for(int i = 0; i < 1000; i++){
double randomDirection = Math.random();
if (randomDirection < 0.25){
if(northUsed){
northUsed = true;
dir = "north";
break;
}
}else if(randomDirection < 0.50){
if(eastUsed){
eastUsed = true;
dir = "east";
break;
}
}else if(randomDirection < 0.75){
if(southUsed){
southUsed = true;
dir = "south";
break;
}
}else{
if(westUsed){
westUsed = true;
dir = "west";
break;
}
}
}
//TELEPORT - teleports player to the conflict point
switch(dir){
case "north":
northUsed = false;
player.teleport(world.getHighestBlockAt(conflictX, conflictZ - conflictRadius).getLocation());
break;
case "east":
eastUsed = false;
player.teleport(world.getHighestBlockAt(conflictX + conflictRadius, conflictZ).getLocation());
break;
case "south":
southUsed = false;
player.teleport(world.getHighestBlockAt(conflictX, conflictZ + conflictRadius).getLocation());
break;
case "west":
westUsed = false;
player.teleport(world.getHighestBlockAt(conflictX - conflictRadius, conflictZ).getLocation());
break;
default:
player.teleport(world.getHighestBlockAt(conflictX, conflictZ).getLocation());
break;
}
}
//Randomly teleports a player, into the hardcore world
public void rtp(Player player, World world, Location minLocation, Location maxLocation){
//INIT - xDifference, xAverage
int xdifference = minLocation.getBlockX() - maxLocation.getBlockX();
int xAverage = (int) Math.floor(minLocation.getBlockX() + maxLocation.getBlockX() / 2);
//INIT - zDifference, zAverage
int zdifference = minLocation.getBlockX() - maxLocation.getBlockY();
int zAverage = (int) Math.floor(minLocation.getBlockZ() + maxLocation.getBlockZ());
//TELEPORTS - Tries 20 times to find a location
for(int i = 0; i < 20; i ++){
//INIT - attemptedX, attemptedZ
int attemptedX = (int) Math.floor((Math.random()-0.5)*xdifference) + xAverage;
int attemptedZ = (int) Math.floor((Math.random()-0.5)*zdifference) + zAverage;
//CHECKS - if ground is safe
boolean groundisSafe = world.getHighestBlockAt(attemptedX, attemptedZ).getType() != Material.WATER;
if (groundisSafe){
player.teleport(world.getHighestBlockAt(attemptedX, attemptedZ).getLocation());
return;
}
//player.teleport(arg0)
}
}

View file

@ -0,0 +1,68 @@
package alisolarflare.listeners;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.HumanEntity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.inventory.CraftItemEvent;
import org.bukkit.inventory.ItemStack;
public class ConflictCompassCraftingListener implements Listener{
@EventHandler
public boolean onConflictCompassCraft(CraftItemEvent event){
//SANITATION - HARDCORE
if(event.getWhoClicked().getWorld().getName() != "hardcore"){
return false;
}
//INIT - targetItem
ItemStack targetItem = event.getRecipe().getResult();
//SANITATION - NOT COMPASS
if(targetItem.getType() != Material.COMPASS){
return false;
}
event.setCancelled(true);
//GIVE - chainmail chestplate
event.getWhoClicked().getInventory().addItem(generateConflictCompass(event.getWhoClicked()));
//PLAY - cave sound
event.getWhoClicked().getWorld().playSound(event.getWhoClicked().getLocation(), Sound.AMBIENT_CAVE,0,0);
return false;
}
private ItemStack generateConflictCompass(HumanEntity crafter) {
ItemStack conflictCompass = new ItemStack(Material.COMPASS);
conflictCompass.addUnsafeEnchantment(Enchantment.DURABILITY, 1);
List<String> loreString = new ArrayList<String>();
loreString.add("The needle is tipped with the scent of");
loreString.add(nearestPlayerName(crafter));
conflictCompass.getItemMeta().setLore(loreString);
return null;
}
private String nearestPlayerName(HumanEntity crafter) {
Player nearestPlayer = null;
for(Player player: crafter.getWorld().getPlayers()){
if (player.getUniqueId() == crafter.getUniqueId()){
//SKIP CODE
}if (nearestPlayer == null){
nearestPlayer = player;
}else if (nearestPlayer.getLocation().distance(crafter.getLocation()) > player.getLocation().distance(crafter.getLocation())){
nearestPlayer = player;
}
}
if(nearestPlayer == null){
return "METAL";
}
return nearestPlayer.toString();
}
}

View file

@ -15,10 +15,10 @@ import org.bukkit.inventory.ItemStack;
public class DiamondArmorBlocker implements Listener{
public static List<Material> blockedItems = Arrays.asList(Material.DIAMOND_BOOTS, Material.DIAMOND_CHESTPLATE, Material.DIAMOND_LEGGINGS, Material.DIAMOND_HELMET);
@EventHandler
public void onArmorSmith(CraftItemEvent event){
public boolean onArmorSmith(CraftItemEvent event){
//SANITATION - hardcore
if(event.getWhoClicked().getWorld().getName() != "hardcore"){
return;
return false;
}
//INIT - inventory, targetItem
@ -33,6 +33,7 @@ public class DiamondArmorBlocker implements Listener{
event.getWhoClicked().getWorld().playSound(event.getWhoClicked().getLocation(), Sound.AMBIENT_CAVE,0,0);
event.getWhoClicked().getWorld().playSound(event.getWhoClicked().getLocation(), Sound.ENTITY_ITEM_BREAK,0,0);
}
return false;
}
@ -42,7 +43,8 @@ public class DiamondArmorBlocker implements Listener{
//INIT - Chainmail's lore
List<String> loreString = new ArrayList<String>();
loreString.add("This world is forever dangerous. There is no protection here");
loreString.add("This world is forever dangerous.");
loreString.add("There is no protection here.");
failArmor.getItemMeta().setLore(loreString);
return failArmor;
}