First commit.

This commit is contained in:
Jakub1221 2013-03-26 20:20:20 +01:00
commit 94f623c0a9
66 changed files with 13464 additions and 0 deletions

10
README.md Normal file
View File

@ -0,0 +1,10 @@
![HerobrineAI](http://dev.bukkit.org/media/images/53/795/herobrineai_logo_v3.png)
=========
HerobrineAI is plugin that creates Herobrine with custom AI and skin.
But all it is likely true Herobrine legend with some improvements.
Herobrine can be found randomly in the world or he can attack or haunt a player.
Building
---------
git clone git://github.com/jakub1221/HerobrineAI.git

BIN
lib/CustomItems.jar Normal file

Binary file not shown.

BIN
lib/GriefPrevention.jar Normal file

Binary file not shown.

BIN
lib/PreciousStones.jar Normal file

Binary file not shown.

BIN
lib/Residence.jar Normal file

Binary file not shown.

BIN
lib/Towny.jar Normal file

Binary file not shown.

BIN
lib/WorldGuard.jar Normal file

Binary file not shown.

10
plugin.yml Normal file
View File

@ -0,0 +1,10 @@
name: HerobrineAI
main: org.jakub1221.herobrineai.HerobrineAI
version: 3.0.0
commands:
hb-ai:
description: Main command.
usage: /hb-ai help
hb:
description: Main command.
usage: /hb help

3638
res/graveyard_world.yml Normal file

File diff suppressed because it is too large Load Diff

2750
res/temple.yml Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,635 @@
package org.jakub1221.herobrineai.AI;
import java.util.ArrayList;
import java.util.Random;
import org.bukkit.Bukkit;
import org.bukkit.Effect;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.jakub1221.herobrineai.HerobrineAI;
import org.jakub1221.herobrineai.AI.Core.CoreType;
import org.jakub1221.herobrineai.AI.cores.Attack;
import org.jakub1221.herobrineai.AI.cores.Book;
import org.jakub1221.herobrineai.AI.cores.BuildStuff;
import org.jakub1221.herobrineai.AI.cores.BuryPlayer;
import org.jakub1221.herobrineai.AI.cores.DestroyTorches;
import org.jakub1221.herobrineai.AI.cores.Graveyard;
import org.jakub1221.herobrineai.AI.cores.Haunt;
import org.jakub1221.herobrineai.AI.cores.Heads;
import org.jakub1221.herobrineai.AI.cores.Pyramid;
import org.jakub1221.herobrineai.AI.cores.RandomPosition;
import org.jakub1221.herobrineai.AI.cores.Signs;
import org.jakub1221.herobrineai.AI.cores.SoundF;
import org.jakub1221.herobrineai.AI.cores.Temple;
import org.jakub1221.herobrineai.AI.cores.Totem;
import org.jakub1221.herobrineai.misc.ItemName;
public class AICore {
public static ConsoleLogger log = new ConsoleLogger();
private ArrayList<Core> AllCores = new ArrayList<Core>();
private CoreType CoreNow = CoreType.ANY;
public static HerobrineAI plugin;
public static Player PlayerTarget;
public static boolean isTarget=false;
public static int ticksToEnd=0;
public static boolean isDiscCalled=false;
public static boolean isTotemCalled=false;
public static int _ticks=0;
private boolean BuildINT=false;
private boolean MainINT=false;
private boolean RandomPositionINT=false;
private boolean RandomMoveINT=false;
private boolean RandomSeeINT=false;
private boolean CheckGravityINT=false;
private RandomPosition RandomPositionCore;
private Graveyard GraveyardCore;
private int RP_INT=0;
private int RM_INT=0;
private int RS_INT=0;
private int CG_INT=0;
private int MAIN_INT=0;
private int BD_INT=0;
public Core getCore(CoreType type){
for (Core c : AllCores){
if (c.getCoreType()==type){
return c;
}
}
return null;
}
public AICore (){
/* Cores init */
this.GraveyardCore=new Graveyard();
this.RandomPositionCore=new RandomPosition();
AllCores.add(new Attack());
AllCores.add(new Book());
AllCores.add(new BuildStuff());
AllCores.add(new BuryPlayer());
AllCores.add(new DestroyTorches());
AllCores.add(this.GraveyardCore);
AllCores.add(new Haunt());
AllCores.add(new Pyramid());
AllCores.add(this.RandomPositionCore);
AllCores.add(new Signs());
AllCores.add(new SoundF());
AllCores.add(new Temple());
AllCores.add(new Totem());
AllCores.add(new Heads());
plugin = HerobrineAI.getPluginCore();
log.info("[HerobrineAI] Debug mode enabled!");
FindPlayer();
StartIntervals();
}
public Graveyard getGraveyard(){return this.GraveyardCore;}
public RandomPosition getRandomPosition(){return this.RandomPositionCore;}
public void setCoreTypeNow(CoreType c){CoreNow=c;}
public CoreType getCoreTypeNow(){return CoreNow;}
public static String getStringWalkingMode(){
String result="";
if (HerobrineAI.getPluginCore().getAICore().getCoreTypeNow() == CoreType.RANDOM_POSITION){result="Yes";}else{result="No";}
return result;
}
public void FindPlayer(){
if (HerobrineAI.getPluginCore().getConfigDB().OnlyWalkingMode==false){
if (isTarget==false){
Random generator = new Random();
int att_chance= generator.nextInt(100);
log.info("[HerobrineAI] Generating find chance...");
if (att_chance-(HerobrineAI.getPluginCore().getConfigDB().ShowRate*4)<55){
if (Bukkit.getServer().getOnlinePlayers().length>0){
log.info("[HerobrineAI] Finding target...");
Player [] AllOnPlayers = Bukkit.getServer().getOnlinePlayers();
Random generator2 = new Random();
int player_rolled= generator2.nextInt(Bukkit.getServer().getOnlinePlayers().length);
if (player_rolled>Bukkit.getServer().getOnlinePlayers().length-1){
FindPlayer();
}else{
if (AllOnPlayers[player_rolled].getEntityId()!=HerobrineAI.HerobrineEntityID){
if (HerobrineAI.getPluginCore().getConfigDB().useWorlds.contains(AllOnPlayers[player_rolled].getLocation().getWorld().getName()) && HerobrineAI.getPluginCore().canAttackPlayerNoMSG(AllOnPlayers[player_rolled])){
CancelTarget(CoreType.ANY);
PlayerTarget=AllOnPlayers[player_rolled];
isTarget=true;
log.info("[HerobrineAI] Target founded, starting AI now! ("+PlayerTarget.getName()+")");
setCoreTypeNow(CoreType.START);
StartAI();
}else{ log.info("[HerobrineAI] Target is in the safe world! ("+AllOnPlayers[player_rolled].getLocation().getWorld().getName()+")");FindPlayer();}
}
}
}
}
}
}
}
public void CancelTarget(CoreType coreType){
if (coreType == CoreNow || coreType == CoreType.ANY){
if (CoreNow == CoreType.RANDOM_POSITION){
Stop_RM();
Stop_RS();
Stop_CG();
Location nowloc = new Location((World) Bukkit.getServer().getWorlds().get(0),(float) 0,(float) -20,(float) 0);
nowloc.setYaw((float) 1);
nowloc.setPitch((float) 1);
HerobrineAI.HerobrineNPC.moveTo(nowloc);
CoreNow=CoreType.ANY;
HerobrineAI.getPluginCore().getPathManager().setPath(null);
}
if (isTarget==true){
if (CoreNow == CoreType.ATTACK){
Attack at = (Attack) getCore(CoreType.ATTACK);
at.StopHandler();
}
if (CoreNow == CoreType.HAUNT){
Haunt ht = (Haunt) getCore(CoreType.HAUNT);
ht.StopHandler();
}
_ticks=0;
isTarget=false;
HerobrineAI.HerobrineHP=HerobrineAI.HerobrineMaxHP;
log.info("[HerobrineAI] Target cancelled.");
Location nowloc = new Location((World) Bukkit.getServer().getWorlds().get(0),(float) 0,(float) -20,(float) 0);
nowloc.setYaw((float) 1);
nowloc.setPitch((float) 1);
HerobrineAI.HerobrineNPC.moveTo(nowloc);
CoreNow=CoreType.ANY;
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(AICore.plugin, new Runnable() {
public void run() {
FindPlayer();
}
}, (6/HerobrineAI.getPluginCore().getConfigDB().ShowRate) * (HerobrineAI.getPluginCore().getConfigDB().ShowInterval * 1L));
}
}
}
public void StartAI(){
if (PlayerTarget.isOnline() && isTarget){
if (PlayerTarget.isDead()==false){
Object[] data = {PlayerTarget};
Random generator = new Random();
int chance= generator.nextInt(100);
if (chance<=10){
if(HerobrineAI.getPluginCore().getConfigDB().UseGraveyardWorld==true){
log.info("[HerobrineAI] Teleporting target to Graveyard world.");
getCore(CoreType.GRAVEYARD).RunCore(data);
}
}else if (chance<=25){
getCore(CoreType.ATTACK).RunCore(data);
}else{
getCore(CoreType.HAUNT).RunCore(data);
}
}else{CancelTarget(CoreType.START);}
}else{CancelTarget(CoreType.START);}
}
public CoreResult setAttackTarget(Player player){
Object[] data = {player};
return getCore(CoreType.ATTACK).RunCore(data);
}
public CoreResult setHauntTarget(Player player){
Object[] data = {player};
return getCore(CoreType.HAUNT).RunCore(data);
}
public void GraveyardTeleport(final Player player){
if (player.isOnline()){
CancelTarget(CoreType.ANY);
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(AICore.plugin, new Runnable() {
public void run() {
Object[] data = {player};
getCore(CoreType.GRAVEYARD).RunCore(data);
}
}, 1 * 10L);
}
}
public void PlayerCallTotem(Player player){
final String playername=player.getName();
final Location loc = (Location) player.getLocation();
isTotemCalled=true;
CancelTarget(CoreType.ANY);
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(AICore.plugin, new Runnable() {
public void run() {
CancelTarget(CoreType.ANY);
Object[] data = {loc, playername};
getCore(CoreType.TOTEM).RunCore(data);
}
}, 1 * 40L);
}
private void RandomPositionInterval(){
if (CoreNow==CoreType.ANY){
RandomPositionCore.setRandomTicks(0);
int count = HerobrineAI.getPluginCore().getConfigDB().useWorlds.size();
Random randgen = new Random();
int chance=randgen.nextInt(count);
Object[] data = {Bukkit.getServer().getWorld(HerobrineAI.getPluginCore().getConfigDB().useWorlds.get(chance))};
getCore(CoreType.RANDOM_POSITION).RunCore(data);
}
}
private void CheckGravityInterval(){
if (this.CoreNow==CoreType.RANDOM_POSITION){
this.RandomPositionCore.CheckGravity();
}
}
private void RandomMoveInterval(){
RandomPositionCore.RandomMove();
}
private void RandomSeeInterval(){
if (CoreNow == CoreType.RANDOM_POSITION){
RandomPositionCore.CheckPlayerPosition();
}
}
private void PyramidInterval(){
Random generator1 = new Random();
Random generator3 = new Random();
int chance=generator1.nextInt(100);
if (chance>50){
if (Bukkit.getServer().getOnlinePlayers().length>0){
log.info("[HerobrineAI] Finding pyramid target...");
Player [] AllOnPlayers = Bukkit.getServer().getOnlinePlayers();
Random generator2 = new Random();
int player_rolled= generator2.nextInt(Bukkit.getServer().getOnlinePlayers().length);
if (player_rolled>Bukkit.getServer().getOnlinePlayers().length-1){
}else{
if (HerobrineAI.getPluginCore().getConfigDB().useWorlds.contains(AllOnPlayers[player_rolled].getLocation().getWorld().getName())){
int chance2=generator3.nextInt(100);
if (chance2<30){
if (HerobrineAI.getPluginCore().getConfigDB().BuildPyramids==true){
Object[] data = {AllOnPlayers[player_rolled]};
getCore(CoreType.PYRAMID).RunCore(data);
}
}else if(chance2<70){
if (HerobrineAI.getPluginCore().getConfigDB().BuryPlayers){
Object[] data = {AllOnPlayers[player_rolled]};
getCore(CoreType.BURY_PLAYER).RunCore(data);
}
}else{
if (HerobrineAI.getPluginCore().getConfigDB().UseHeads){
Object[] data = {AllOnPlayers[player_rolled].getName()};
getCore(CoreType.HEADS).RunCore(data);
}
}
}
}
}
}
}
private void TempleInterval(){
if (HerobrineAI.getPluginCore().getConfigDB().BuildTemples==true){
Random generator1 = new Random();
Random generator3 = new Random();
int chance=generator1.nextInt(100);
if (chance>50){
if (Bukkit.getServer().getOnlinePlayers().length>0){
log.info("[HerobrineAI] Finding temple target...");
Player [] AllOnPlayers = Bukkit.getServer().getOnlinePlayers();
Random generator2 = new Random();
int player_rolled= generator2.nextInt(Bukkit.getServer().getOnlinePlayers().length);
if (player_rolled>Bukkit.getServer().getOnlinePlayers().length-1){
}else{
if (HerobrineAI.getPluginCore().getConfigDB().useWorlds.contains(AllOnPlayers[player_rolled].getLocation().getWorld().getName())){
int chance2=generator3.nextInt(100);
if (chance2<50){
Object[] data = {AllOnPlayers[player_rolled]};
getCore(CoreType.TEMPLE).RunCore(data);
}
}
}
}
}
}
}
private void BuildCave(){
if (HerobrineAI.getPluginCore().getConfigDB().BuildStuff==true){
Random generator1 = new Random();
Random generator3 = new Random();
int chance=generator1.nextInt(100);
if (chance>50){
if (Bukkit.getServer().getOnlinePlayers().length>0){
log.info("[HerobrineAI] Finding cave target...");
Player [] AllOnPlayers = Bukkit.getServer().getOnlinePlayers();
Random generator2 = new Random();
int player_rolled= generator2.nextInt(Bukkit.getServer().getOnlinePlayers().length);
if (player_rolled>Bukkit.getServer().getOnlinePlayers().length-1){
}else{
if (HerobrineAI.getPluginCore().getConfigDB().useWorlds.contains(AllOnPlayers[player_rolled].getLocation().getWorld().getName())){
int chance2=generator3.nextInt(100);
if (chance2<50){
Object[] data = {AllOnPlayers[player_rolled].getLocation()};
getCore(CoreType.BUILD_STUFF).RunCore(data);
}
}
}
}
}
}
}
public void callByDisc(Player player){
isDiscCalled=false;
if (player.isOnline()){
CancelTarget(CoreType.ANY);
setHauntTarget(player);
}
}
public void DisappearEffect(){
Location ploc = (Location) PlayerTarget.getLocation();
Location hbloc1 = (Location) HerobrineAI.HerobrineNPC.getBukkitEntity().getLocation();
hbloc1.setY(hbloc1.getY()+1);
Location hbloc2 = (Location) HerobrineAI.HerobrineNPC.getBukkitEntity().getLocation();
hbloc2.setY(hbloc2.getY()+0);
Location hbloc3 = (Location) HerobrineAI.HerobrineNPC.getBukkitEntity().getLocation();
hbloc3.setY(hbloc3.getY()+0.5);
Location hbloc4 = (Location) HerobrineAI.HerobrineNPC.getBukkitEntity().getLocation();
hbloc4.setY(hbloc4.getY()+1.5);
ploc.getWorld().playEffect(hbloc1, Effect.SMOKE, 80);
ploc.getWorld().playEffect(hbloc2, Effect.SMOKE, 80);
ploc.getWorld().playEffect(hbloc3, Effect.SMOKE, 80);
ploc.getWorld().playEffect(hbloc4, Effect.SMOKE, 80);
ploc.getWorld().playEffect(hbloc1, Effect.SMOKE, 80);
ploc.getWorld().playEffect(hbloc2, Effect.SMOKE, 80);
ploc.getWorld().playEffect(hbloc3, Effect.SMOKE, 80);
ploc.getWorld().playEffect(hbloc4, Effect.SMOKE, 80);
ploc.getWorld().playEffect(hbloc1, Effect.SMOKE, 80);
ploc.getWorld().playEffect(hbloc2, Effect.SMOKE, 80);
ploc.getWorld().playEffect(hbloc3, Effect.SMOKE, 80);
ploc.getWorld().playEffect(hbloc4, Effect.SMOKE, 80);
ploc.getWorld().playEffect(hbloc1, Effect.SMOKE, 80);
ploc.getWorld().playEffect(hbloc2, Effect.SMOKE, 80);
ploc.getWorld().playEffect(hbloc3, Effect.SMOKE, 80);
ploc.getWorld().playEffect(hbloc4, Effect.SMOKE, 80);
ploc.getWorld().playEffect(hbloc1, Effect.SMOKE, 80);
ploc.getWorld().playEffect(hbloc2, Effect.SMOKE, 80);
ploc.getWorld().playEffect(hbloc3, Effect.SMOKE, 80);
ploc.getWorld().playEffect(hbloc4, Effect.SMOKE, 80);
ploc.getWorld().playEffect(hbloc1, Effect.SMOKE, 80);
ploc.getWorld().playEffect(hbloc2, Effect.SMOKE, 80);
ploc.getWorld().playEffect(hbloc3, Effect.SMOKE, 80);
ploc.getWorld().playEffect(hbloc4, Effect.SMOKE, 80);
ploc.getWorld().playEffect(hbloc1, Effect.SMOKE, 80);
ploc.getWorld().playEffect(hbloc2, Effect.SMOKE, 80);
ploc.getWorld().playEffect(hbloc3, Effect.SMOKE, 80);
ploc.getWorld().playEffect(hbloc4, Effect.SMOKE, 80);
ploc.setY(-20);
HerobrineAI.HerobrineNPC.moveTo(ploc);
}
private void BuildInterval(){
if(new Random().nextInt(100)<75){
PyramidInterval();
}else{
TempleInterval();
}
if (new Random().nextBoolean()){
BuildCave();
}
}
private void StartIntervals(){
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(AICore.plugin, new Runnable() {
public void run() {
Start_RP();
Start_MAIN();
Start_BD();
}
}, 1 * 5L);
}
public void Start_RP(){
RandomPositionINT=true;
RP_INT=Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(AICore.plugin, new Runnable() {
public void run() {
RandomPositionInterval();
}
},1 * 300L, 1 * 300L);
}
public void Start_BD(){
BuildINT=true;
BD_INT=Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(AICore.plugin, new Runnable() {
public void run() {
BuildInterval();
}
}, 1 * 1L * HerobrineAI.getPluginCore().getConfigDB().BuildInterval, 1 * 1L * HerobrineAI.getPluginCore().getConfigDB().BuildInterval);
}
public void Start_MAIN(){
MainINT=true;
MAIN_INT=Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(AICore.plugin, new Runnable() {
public void run() {
FindPlayer();
}
},(6/HerobrineAI.getPluginCore().getConfigDB().ShowRate) * (HerobrineAI.getPluginCore().getConfigDB().ShowInterval * 1L),(6/HerobrineAI.getPluginCore().getConfigDB().ShowRate) * (HerobrineAI.getPluginCore().getConfigDB().ShowInterval * 1L));
}
public void Start_RM(){
RandomMoveINT=true;
RM_INT=Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(AICore.plugin, new Runnable() {
public void run() {
RandomMoveInterval();
}
},1 * 50L ,1 * 50L);
}
public void Start_RS(){
RandomSeeINT=true;
RS_INT=Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(AICore.plugin, new Runnable() {
public void run() {
RandomSeeInterval();
}
}, 1 * 15L,1 * 15L);
}
public void Start_CG(){
CheckGravityINT=true;
CG_INT=Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(AICore.plugin, new Runnable() {
public void run() {
CheckGravityInterval();
}
}, 1 * 10L,1 * 10L);
}
public void Stop_RP(){
if (RandomPositionINT){
RandomPositionINT=false;
Bukkit.getServer().getScheduler().cancelTask(RP_INT);
}
}
public void Stop_BD(){
if (BuildINT){
BuildINT=false;
Bukkit.getServer().getScheduler().cancelTask(BD_INT);
}
}
public void Stop_RS(){
if (RandomSeeINT){
RandomSeeINT=false;
Bukkit.getServer().getScheduler().cancelTask(RS_INT);
}
}
public void Stop_RM(){
if (RandomMoveINT){
RandomMoveINT=false;
Bukkit.getServer().getScheduler().cancelTask(RM_INT);
}
}
public void Stop_CG(){
if (CheckGravityINT){
CheckGravityINT=false;
Bukkit.getServer().getScheduler().cancelTask(CG_INT);
}
}
public void Stop_MAIN(){
if (MainINT){
MainINT=false;
Bukkit.getServer().getScheduler().cancelTask(MAIN_INT);
}
}
public ItemStack createAncientSword(){
ItemStack item = new ItemStack(Material.GOLD_SWORD);
String name = "Ancient Sword";
ArrayList<String> lore = new ArrayList<String>();
lore.add("AncientSword");
lore.add("Very old and mysterious sword.");
lore.add("This will protect you aganist Herobrine.");
item = ItemName.setNameAndLore(item, name, lore);
return item;
}
public boolean isAncientSword(ItemStack item){
ArrayList<String> lore = new ArrayList<String>();
lore.add("AncientSword");
lore.add("Very old and mysterious sword.");
lore.add("This will protect you aganist Herobrine.");
if (item!=null){
if (item.getItemMeta()!=null){
if (item.getItemMeta().getLore()!=null){
ArrayList<String> ilore = (ArrayList<String>) item.getItemMeta().getLore();
if (ilore.containsAll(lore)){
return true;
}
}
}
}
return false;
}
public boolean checkAncientSword(Inventory inv){
ItemStack[] itemlist = inv.getContents();
ItemStack item = null;
int i=0;
for (i=0;i<=itemlist.length-1;i++){
item=itemlist[i];
if (isAncientSword(item)){
return true;
}
}
return false;
}
}

View File

@ -0,0 +1,17 @@
package org.jakub1221.herobrineai.AI;
import java.util.logging.Logger;
import org.jakub1221.herobrineai.HerobrineAI;
public class ConsoleLogger {
static Logger log = Logger.getLogger("Minecraft");
public void info(String text){
if (HerobrineAI.isDebugging){
log.info(text);
}
}
}

View File

@ -0,0 +1,60 @@
package org.jakub1221.herobrineai.AI;
import org.jakub1221.herobrineai.HerobrineAI;
public abstract class Core {
private final AppearType Appear;
private final CoreType coreType;
private CoreResult nowData=null;
public Core(CoreType cp,AppearType ap){
this.coreType=cp;
this.Appear=ap;
}
public AppearType getAppear(){
return Appear;
}
public CoreType getCoreType(){
return coreType;
}
public abstract CoreResult CallCore(Object[] data);
public CoreResult RunCore(Object[] data){
nowData=this.CallCore(data);
if (nowData.getResult() && Appear == AppearType.APPEAR){
HerobrineAI.getPluginCore().getAICore().setCoreTypeNow(this.coreType);
}
return nowData;
}
public enum CoreType{
ATTACK,
HAUNT,
BOOK,
BUILD_STUFF,
BURY_PLAYER,
DESTROY_TORCHES,
GRAVEYARD,
PYRAMID,
RANDOM_POSITION,
SIGNS,
SOUNDF,
TOTEM,
ANY,
START,
TEMPLE,
HEADS,
}
public enum AppearType{
APPEAR,
NORMAL,
}
}

View File

@ -0,0 +1,18 @@
package org.jakub1221.herobrineai.AI;
public class CoreResult {
private final boolean bo;
private final String text;
public CoreResult(boolean b,String t){
this.bo=b;
this.text=t;
}
public boolean getResult(){
return this.bo;
}
public String getResultString(){
return this.text;
}
}

View File

@ -0,0 +1,24 @@
package org.jakub1221.herobrineai.AI;
import java.util.Random;
import org.bukkit.entity.Player;
import org.jakub1221.herobrineai.HerobrineAI;
public class Message {
public static void SendMessage(Player player){
if (HerobrineAI.getPluginCore().getConfigDB().SendMessages==true){
int count = HerobrineAI.getPluginCore().getConfigDB().useMessages.size();
Random randgen = new Random();
int randmsg=randgen.nextInt(count);
player.sendMessage("<Herobrine> "+HerobrineAI.getPluginCore().getConfigDB().useMessages.get(randmsg));
}
}
}

View File

@ -0,0 +1,242 @@
package org.jakub1221.herobrineai.AI.cores;
import java.util.Random;
import org.bukkit.Bukkit;
import org.bukkit.Effect;
import org.bukkit.Location;
import org.bukkit.Sound;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import org.jakub1221.herobrineai.HerobrineAI;
import org.jakub1221.herobrineai.AI.AICore;
import org.jakub1221.herobrineai.AI.Core;
import org.jakub1221.herobrineai.AI.CoreResult;
import org.jakub1221.herobrineai.AI.Message;
import org.jakub1221.herobrineai.AI.extensions.Position;
public class Attack extends Core{
private int ticksToEnd = 0;
private int HandlerINT=0;
private boolean isHandler=false;
public Attack(){
super(CoreType.ATTACK,AppearType.APPEAR);
}
public CoreResult CallCore(Object[] data){
return setAttackTarget((Player)data[0]);
}
public CoreResult setAttackTarget(Player player){
if (!HerobrineAI.getPluginCore().getAICore().checkAncientSword(player.getInventory())){
if (HerobrineAI.getPluginCore().getSupport().checkAttack(player.getLocation())){
HerobrineAI.HerobrineHP=HerobrineAI.HerobrineMaxHP;
ticksToEnd=0;
AICore.PlayerTarget=player;
AICore.isTarget=true;
AICore.log.info("[HerobrineAI] Teleporting to target. ("+ AICore.PlayerTarget.getName()+")");
Location ploc = (Location) AICore.PlayerTarget.getLocation();
Object[] data = {ploc};
HerobrineAI.getPluginCore().getAICore().getCore(CoreType.DESTROY_TORCHES).RunCore(data);
if (HerobrineAI.getPluginCore().getConfigDB().UsePotionEffects){
AICore.PlayerTarget.addPotionEffect(new PotionEffect(PotionEffectType.CONFUSION, 1000, 1));
AICore.PlayerTarget.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, 1000, 1));
AICore.PlayerTarget.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 1000, 1));
}
Location tploc = (Location) Position.getTeleportPosition(ploc);
HerobrineAI.HerobrineNPC.moveTo(tploc);
Message.SendMessage(AICore.PlayerTarget);
StartHandler();
return new CoreResult(true,"Herobrine attacks "+player.getName()+"!");
}else{
return new CoreResult(false,"Player is in secure area.");
}
}else{
return new CoreResult(false,"Player has Ancient Sword.");
}
}
public void StopHandler(){
if (isHandler){
Bukkit.getScheduler().cancelTask(HandlerINT);
isHandler=false;
}
}
public void StartHandler(){
KeepLooking();
FollowHideRepeat();
isHandler=true;
HandlerINT=Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(AICore.plugin, new Runnable() {
public void run() {
Handler();
}
}, 1 * 5L,1 * 5L);
}
private void Handler(){
KeepLooking();
if (ticksToEnd==1 || ticksToEnd==16 || ticksToEnd==32 || ticksToEnd==48 || ticksToEnd==64 || ticksToEnd==80 || ticksToEnd==96 || ticksToEnd==112 || ticksToEnd==128 || ticksToEnd==144){
FollowHideRepeat();
}
}
public void KeepLooking(){
if (AICore.PlayerTarget.isOnline() && AICore.isTarget && HerobrineAI.getPluginCore().getAICore().getCoreTypeNow()==CoreType.ATTACK){
if (AICore.PlayerTarget.isDead()==false){
if (ticksToEnd==160){HerobrineAI.getPluginCore().getAICore().CancelTarget(CoreType.ATTACK);}else{
ticksToEnd++;
Location ploc = (Location) AICore.PlayerTarget.getLocation();
ploc.setY(ploc.getY()+1.5);
HerobrineAI.HerobrineNPC.lookAtPoint(ploc);
if (HerobrineAI.getPluginCore().getConfigDB().Lighting==true){
Random lchancegen= new Random();
int lchance= lchancegen.nextInt(100);
if (lchance>75){
Location newloc = (Location) ploc;
int randx= new Random().nextInt(50);
int randz= new Random().nextInt(50);
if (new Random().nextBoolean()){
newloc.setX(newloc.getX()+randx);
}else{
newloc.setX(newloc.getX()-randx);
}
if (new Random().nextBoolean()){
newloc.setZ(newloc.getZ()+randz);
}else{
newloc.setZ(newloc.getZ()-randz);
}
newloc.setY(250);
newloc.getWorld().strikeLightning(newloc);
}
}
}
}else{HerobrineAI.getPluginCore().getAICore().CancelTarget(CoreType.ATTACK);}
}else{HerobrineAI.getPluginCore().getAICore().CancelTarget(CoreType.ATTACK);}
}
public void Follow(){
if (AICore.PlayerTarget.isOnline() && AICore.isTarget && HerobrineAI.getPluginCore().getAICore().getCoreTypeNow()==CoreType.ATTACK){
if (AICore.PlayerTarget.isDead()==false){
if (HerobrineAI.getPluginCore().getConfigDB().useWorlds.contains(AICore.PlayerTarget.getWorld().getName()) && HerobrineAI.getPluginCore().getSupport().checkAttack(AICore.PlayerTarget.getLocation())){
HerobrineAI.HerobrineNPC.moveTo(Position.getTeleportPosition(AICore.PlayerTarget.getLocation()));
Location ploc = (Location) AICore.PlayerTarget.getLocation();
ploc.setY(ploc.getY()+1.5);
HerobrineAI.HerobrineNPC.lookAtPoint(ploc);
AICore.PlayerTarget.playSound(AICore.PlayerTarget.getLocation(),Sound.BREATH,(float) 0.75,(float) 0.75);
if (HerobrineAI.getPluginCore().getConfigDB().HitPlayer==true){
Random hitchancegen= new Random();
int hitchance= hitchancegen.nextInt(100);
if (hitchance<55){
AICore.PlayerTarget.playSound(AICore.PlayerTarget.getLocation(), Sound.HURT,(float) 0.75,(float) 0.75);
if (AICore.PlayerTarget.getHealth()>=4){
AICore.PlayerTarget.setHealth(AICore.PlayerTarget.getHealth()-4);
}else{AICore.PlayerTarget.setHealth(0);}
}
}
}else{HerobrineAI.getPluginCore().getAICore().CancelTarget(CoreType.ATTACK);}
}else{HerobrineAI.getPluginCore().getAICore().CancelTarget(CoreType.ATTACK);}
}else{HerobrineAI.getPluginCore().getAICore().CancelTarget(CoreType.ATTACK);}
}
public void Hide(){
if (AICore.PlayerTarget.isOnline() && AICore.isTarget && HerobrineAI.getPluginCore().getAICore().getCoreTypeNow()==CoreType.ATTACK){
if (AICore.PlayerTarget.isDead()==false){
Location ploc = (Location) AICore.PlayerTarget.getLocation();
ploc.setY(-20);
Location hbloc1 = (Location) HerobrineAI.HerobrineNPC.getBukkitEntity().getLocation();
hbloc1.setY(hbloc1.getY()+1);
Location hbloc2 = (Location) HerobrineAI.HerobrineNPC.getBukkitEntity().getLocation();
hbloc2.setY(hbloc2.getY()+0);
Location hbloc3 = (Location) HerobrineAI.HerobrineNPC.getBukkitEntity().getLocation();
hbloc3.setY(hbloc3.getY()+0.5);
Location hbloc4 = (Location) HerobrineAI.HerobrineNPC.getBukkitEntity().getLocation();
hbloc4.setY(hbloc4.getY()+1.5);
ploc.getWorld().playEffect(hbloc1, Effect.SMOKE, 80);
ploc.getWorld().playEffect(hbloc2, Effect.SMOKE, 80);
ploc.getWorld().playEffect(hbloc3, Effect.SMOKE, 80);
ploc.getWorld().playEffect(hbloc4, Effect.SMOKE, 80);
ploc.getWorld().playEffect(hbloc1, Effect.SMOKE, 80);
ploc.getWorld().playEffect(hbloc2, Effect.SMOKE, 80);
ploc.getWorld().playEffect(hbloc3, Effect.SMOKE, 80);
ploc.getWorld().playEffect(hbloc4, Effect.SMOKE, 80);
ploc.getWorld().playEffect(hbloc1, Effect.SMOKE, 80);
ploc.getWorld().playEffect(hbloc2, Effect.SMOKE, 80);
ploc.getWorld().playEffect(hbloc3, Effect.SMOKE, 80);
ploc.getWorld().playEffect(hbloc4, Effect.SMOKE, 80);
ploc.getWorld().playEffect(hbloc1, Effect.SMOKE, 80);
ploc.getWorld().playEffect(hbloc2, Effect.SMOKE, 80);
ploc.getWorld().playEffect(hbloc3, Effect.SMOKE, 80);
ploc.getWorld().playEffect(hbloc4, Effect.SMOKE, 80);
ploc.getWorld().playEffect(hbloc1, Effect.SMOKE, 80);
ploc.getWorld().playEffect(hbloc2, Effect.SMOKE, 80);
ploc.getWorld().playEffect(hbloc3, Effect.SMOKE, 80);
ploc.getWorld().playEffect(hbloc4, Effect.SMOKE, 80);
ploc.getWorld().playEffect(hbloc1, Effect.SMOKE, 80);
ploc.getWorld().playEffect(hbloc2, Effect.SMOKE, 80);
ploc.getWorld().playEffect(hbloc3, Effect.SMOKE, 80);
ploc.getWorld().playEffect(hbloc4, Effect.SMOKE, 80);
ploc.getWorld().playEffect(hbloc1, Effect.SMOKE, 80);
ploc.getWorld().playEffect(hbloc2, Effect.SMOKE, 80);
ploc.getWorld().playEffect(hbloc3, Effect.SMOKE, 80);
ploc.getWorld().playEffect(hbloc4, Effect.SMOKE, 80);
if (HerobrineAI.getPluginCore().getConfigDB().SpawnBats){
int cc = new Random().nextInt(3);
if (cc==0){
ploc.getWorld().spawnEntity(hbloc1, EntityType.BAT);
ploc.getWorld().spawnEntity(hbloc1, EntityType.BAT);
}else if (cc==1){
ploc.getWorld().spawnEntity(hbloc1, EntityType.BAT);
}
}
HerobrineAI.HerobrineNPC.moveTo(ploc);
}else{HerobrineAI.getPluginCore().getAICore().CancelTarget(CoreType.ATTACK);}
}else{HerobrineAI.getPluginCore().getAICore().CancelTarget(CoreType.ATTACK);}
}
public void FollowHideRepeat(){
if (AICore.PlayerTarget.isOnline() && AICore.isTarget && HerobrineAI.getPluginCore().getAICore().getCoreTypeNow()==CoreType.ATTACK){
if (AICore.PlayerTarget.isDead()==false){
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(AICore.plugin, new Runnable() {
public void run() {
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(AICore.plugin, new Runnable() {
public void run() {
Hide();
}
}, 1 * 30L);
Follow();
}
}, 1 * 45L);
}else{HerobrineAI.getPluginCore().getAICore().CancelTarget(CoreType.ATTACK);}
}else{HerobrineAI.getPluginCore().getAICore().CancelTarget(CoreType.ATTACK);}
}
}

View File

@ -0,0 +1,71 @@
package org.jakub1221.herobrineai.AI.cores;
import java.util.ArrayList;
import java.util.Random;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.BookMeta;
import org.jakub1221.herobrineai.HerobrineAI;
import org.jakub1221.herobrineai.AI.Core;
import org.jakub1221.herobrineai.AI.CoreResult;
public class Book extends Core{
public Book(){
super(CoreType.BOOK,AppearType.NORMAL);
}
public CoreResult CallCore(Object[] data){
Player player = (Player) data[0];
if (HerobrineAI.getPluginCore().getConfigDB().useWorlds.contains(player.getLocation().getWorld().getName())){
if (HerobrineAI.getPluginCore().getConfigDB().WriteBooks==true && HerobrineAI.getPluginCore().getSupport().checkBooks(player.getLocation())){
Random randgen = new Random();
int chance=randgen.nextInt(100);
if (chance>(100-HerobrineAI.getPluginCore().getConfigDB().BookChance)){
Inventory chest = (Inventory) data[1];
if (chest.firstEmpty()!=-1){
chest.setItem(chest.firstEmpty(),newBook());
return new CoreResult(true,"Book created!");
}else{
return new CoreResult(false,"Book create failed!");
}
}else{
return new CoreResult(false,"Books are not allowed!");
}
}else{
return new CoreResult(false,"Player is not in allowed world!");
}
}
return new CoreResult(false,"Book create failed!");
}
public ItemStack newBook(){
int count = HerobrineAI.getPluginCore().getConfigDB().useBookMessages.size();
Random randgen = new Random();
int chance=randgen.nextInt(count);
ItemStack book = new ItemStack(Material.WRITTEN_BOOK);
BookMeta meta = (BookMeta) book.getItemMeta();
ArrayList<String> list = new ArrayList<String>();
meta.setTitle("");
meta.setAuthor("");
list.add(0, (String) HerobrineAI.getPluginCore().getConfigDB().useBookMessages.get(chance));
meta.setPages(list);
book.setItemMeta(meta);
return (ItemStack) book;
}
}

View File

@ -0,0 +1,148 @@
package org.jakub1221.herobrineai.AI.cores;
import java.util.ArrayList;
import java.util.Random;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.jakub1221.herobrineai.HerobrineAI;
import org.jakub1221.herobrineai.AI.*;
public class BuildStuff extends Core{
public BuildStuff(){
super(CoreType.BUILD_STUFF,AppearType.NORMAL);
}
public CoreResult CallCore(Object[] data){
if (data.length==2){
return BuildCave((Location) data[0],true);
}
return BuildCave((Location) data[0]);
}
public CoreResult BuildCave(Location loc){
if (HerobrineAI.getPluginCore().getConfigDB().BuildStuff==true){
if (HerobrineAI.getPluginCore().getSupport().checkBuild(loc)){
if (loc.getBlockY()<60){
Random randgen = new Random();
int chance=randgen.nextInt(100);
if (chance>(100-HerobrineAI.getPluginCore().getConfigDB().CaveChance)){
AICore.log.info("Creating cave...");
GenerateCave(loc);
return new CoreResult(false,"Cave created!");
}else{
return new CoreResult(false,"Roll failed!");
}
}else{
return new CoreResult(false,"Location must be under 60 of Y.");
}
}else{
return new CoreResult(false,"Cannot build stuff.");
}
}else{
return new CoreResult(false,"Player is in secure location.");
}
}
public CoreResult BuildCave(Location loc,boolean cmd){
if (HerobrineAI.getPluginCore().getSupport().checkBuild(loc)){
if (loc.getBlockY()<60){
AICore.log.info("Creating cave...");
GenerateCave(loc);
return new CoreResult(false,"Cave created!");
}else{
return new CoreResult(false,"Location must be under 60 of Y.");
}
}else{
return new CoreResult(false,"Player is in secure location.");
}
}
public void GenerateCave(Location loc){
if (HerobrineAI.getPluginCore().getSupport().checkBuild(loc)){
ArrayList<Location> redstoneTorchList = new ArrayList<Location>();
boolean goByX=new Random().nextBoolean();
boolean goNegative=new Random().nextBoolean();
int baseX=loc.getBlockX();
int baseZ=loc.getBlockZ();
int baseY=loc.getBlockY();
int finalX=0;
int finalZ=0;
int maxL=new Random().nextInt(10)+4;
int iR=new Random().nextInt(3)+4;
int iNow=0;
while(iNow!=iR){
iNow++;
goByX=new Random().nextBoolean();
goNegative=new Random().nextBoolean();
int i=0;
for (i=0;i<=maxL;i++){
finalX=0;
finalZ=0;
if (goNegative){
if (goByX){
finalX=-1;
}else{
finalZ=-1;
}
}else{
if (goByX){
finalX=1;
}else{
finalZ=1;
}
}
baseX=baseX+finalX;
baseZ=baseZ+finalZ;
loc.getWorld().getBlockAt(baseX,baseY,baseZ).breakNaturally(null);
loc.getWorld().getBlockAt(baseX,baseY+1,baseZ).breakNaturally(null);
if (new Random().nextBoolean()){
redstoneTorchList.add(new Location(loc.getWorld(),baseX,baseY+1,baseZ));
}
}
}
for (Location _loc : redstoneTorchList){
PlaceRedstoneTorch(_loc.getWorld(),_loc.getBlockX(),_loc.getBlockY(),_loc.getBlockZ());
}
AICore.log.info("Cave created!");
}
}
public void PlaceRedstoneTorch(World world,int x,int y,int z){
Random randgen = new Random();
int chance=randgen.nextInt(100);
if (chance>70){
world.getBlockAt(x, y, z).setType(Material.REDSTONE_TORCH_ON);
}
}
}

View File

@ -0,0 +1,86 @@
package org.jakub1221.herobrineai.AI.cores;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.block.Sign;
import org.bukkit.entity.Player;
import org.jakub1221.herobrineai.HerobrineAI;
import org.jakub1221.herobrineai.AI.Core;
import org.jakub1221.herobrineai.AI.CoreResult;
public class BuryPlayer extends Core{
public Block savedBlock1=null;
public Block savedBlock2=null;
public BuryPlayer(){
super(CoreType.BURY_PLAYER,AppearType.NORMAL);
}
public CoreResult CallCore(Object[] data){
return FindPlace((Player)data[0]);
}
public CoreResult FindPlace(Player player){
if(HerobrineAI.getPluginCore().getSupport().checkBuild(player.getLocation())){
Location loc = (Location) player.getLocation();
if (HerobrineAI.StandBlocks.contains(loc.getWorld().getBlockAt(loc.getBlockX(), loc.getBlockY()-1, loc.getBlockZ()).getType())){
if (HerobrineAI.StandBlocks.contains(loc.getWorld().getBlockAt(loc.getBlockX(), loc.getBlockY()-2, loc.getBlockZ()).getType())){
if (HerobrineAI.StandBlocks.contains(loc.getWorld().getBlockAt(loc.getBlockX(), loc.getBlockY()-1, loc.getBlockZ()-1).getType())){
if (HerobrineAI.StandBlocks.contains(loc.getWorld().getBlockAt(loc.getBlockX(), loc.getBlockY()-2, loc.getBlockZ()-1).getType())){
if (HerobrineAI.StandBlocks.contains(loc.getWorld().getBlockAt(loc.getBlockX(), loc.getBlockY()-3, loc.getBlockZ()).getType())){
if (HerobrineAI.StandBlocks.contains(loc.getWorld().getBlockAt(loc.getBlockX(), loc.getBlockY()-3, loc.getBlockZ()-1).getType())){
if (HerobrineAI.StandBlocks.contains(loc.getWorld().getBlockAt(loc.getBlockX(), loc.getBlockY()-1, loc.getBlockZ()-1).getType())){
if (HerobrineAI.StandBlocks.contains(loc.getWorld().getBlockAt(loc.getBlockX(), loc.getBlockY()-2, loc.getBlockZ()-1).getType())){
if (HerobrineAI.StandBlocks.contains(loc.getWorld().getBlockAt(loc.getBlockX(), loc.getBlockY()-1, loc.getBlockZ()-2).getType())){
if (HerobrineAI.NonStandBlocks.contains(loc.getWorld().getBlockAt(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()-2).getType())){
Bury(loc.getWorld(),loc.getBlockX(),loc.getBlockY(),loc.getBlockZ(),player);
return new CoreResult(true,"Player buried!");
}
}
}
}
}
}
}
}
}
}
}
return new CoreResult(false,"Cannot find a good location!");
}
public void Bury(World world,int X,int Y,int Z,Player player){
Location loc = new Location(world,X,Y,Z);
loc.getWorld().getBlockAt(X, Y-1, Z).breakNaturally();
loc.getWorld().getBlockAt(X, Y-2, Z).breakNaturally();
loc.getWorld().getBlockAt(X, Y-3, Z).breakNaturally();
loc.getWorld().getBlockAt(X, Y-1, Z-1).breakNaturally();
loc.getWorld().getBlockAt(X, Y-2, Z-1).breakNaturally();
loc.getWorld().getBlockAt(X, Y-3, Z-1).breakNaturally();
player.teleport(new Location(world,X,Y-3,Z));
RegenBlocks(world,X,Y,Z,player.getName());
}
public void RegenBlocks(World world,int X,int Y,int Z,String playername){
Location loc = new Location(world,X,Y,Z);
Location signloc = new Location(world,X,Y,Z-2);
Block signblock = signloc.add(0, 0D ,0).getBlock();
signblock.setType(Material.SIGN_POST);
Sign sign = (Sign) signblock.getState();
sign.setLine(1, playername);
sign.update();
loc.getWorld().getBlockAt(X, Y-1, Z).setTypeIdAndData(98,(byte)2,false);
loc.getWorld().getBlockAt(X, Y-1, Z-1).setTypeIdAndData(98,(byte)2,false);
}
}

View File

@ -0,0 +1,50 @@
package org.jakub1221.herobrineai.AI.cores;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.jakub1221.herobrineai.HerobrineAI;
import org.jakub1221.herobrineai.AI.Core;
import org.jakub1221.herobrineai.AI.CoreResult;
public class DestroyTorches extends Core{
public DestroyTorches(){
super(CoreType.DESTROY_TORCHES,AppearType.NORMAL);
}
public CoreResult CallCore(Object[] data){
return destroyTorches((Location) data[0]);
}
public CoreResult destroyTorches(Location loc){
if (HerobrineAI.getPluginCore().getConfigDB().DestroyTorches==true){
int x=loc.getBlockX();
int y=loc.getBlockY();
int z=loc.getBlockZ();
World world=loc.getWorld();
int i=-(HerobrineAI.getPluginCore().getConfigDB().DestroyTorchesRadius); // Y
int ii=-(HerobrineAI.getPluginCore().getConfigDB().DestroyTorchesRadius); // X
int iii=-(HerobrineAI.getPluginCore().getConfigDB().DestroyTorchesRadius); // Z
for(i=-(HerobrineAI.getPluginCore().getConfigDB().DestroyTorchesRadius);i<=HerobrineAI.getPluginCore().getConfigDB().DestroyTorchesRadius;i++){
for(ii=-(HerobrineAI.getPluginCore().getConfigDB().DestroyTorchesRadius);ii<=HerobrineAI.getPluginCore().getConfigDB().DestroyTorchesRadius;ii++){
for(iii=-(HerobrineAI.getPluginCore().getConfigDB().DestroyTorchesRadius);iii<=HerobrineAI.getPluginCore().getConfigDB().DestroyTorchesRadius;iii++){
if(world.getBlockAt(x+ii, y+i, z+iii).getType() == Material.TORCH){
world.getBlockAt(x+ii, y+i, z+iii).breakNaturally();
return new CoreResult(true,"Torches destroyed!");
}
}
}
}
}
return new CoreResult(false,"Cannot destroy torches.");
}
}

View File

@ -0,0 +1,142 @@
package org.jakub1221.herobrineai.AI.cores;
import java.util.List;
import java.util.Random;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.jakub1221.herobrineai.HerobrineAI;
import org.jakub1221.herobrineai.AI.AICore;
import org.jakub1221.herobrineai.AI.Core;
import org.jakub1221.herobrineai.AI.CoreResult;
public class Graveyard extends Core{
private List<LivingEntity> LivingEntities;
private int ticks=0;
private double savedX=0;
private double savedY=0;
private double savedZ=0;
private World savedWorld=null;
private Player savedPlayer=null;
public Graveyard(){
super(CoreType.GRAVEYARD,AppearType.APPEAR);
}
public CoreResult CallCore(Object[] data){
return Teleport((Player) data[0]);
}
public CoreResult Teleport(Player player){
if (HerobrineAI.getPluginCore().getConfigDB().UseGraveyardWorld==true){
if (!HerobrineAI.getPluginCore().getAICore().checkAncientSword(player.getInventory())){
LivingEntities = Bukkit.getServer().getWorld("world_herobrineai_graveyard").getLivingEntities();
for (int i=0;i<=LivingEntities.size()-1;i++){
if (LivingEntities.get(i) instanceof Player || LivingEntities.get(i).getEntityId() == HerobrineAI.HerobrineEntityID){}else{
LivingEntities.get(i).remove();
}
}
Bukkit.getServer().getWorld("world_herobrineai_graveyard").setTime(15000);
HerobrineAI.getPluginCore().getAICore().PlayerTarget=player;
Location loc = (Location) player.getLocation();
savedX=loc.getX();
savedY=loc.getY();
savedZ=loc.getZ();
savedWorld=loc.getWorld();
savedPlayer=player;
loc.setWorld(Bukkit.getServer().getWorld("world_herobrineai_graveyard"));
loc.setX(-2.49);
loc.setY(4);
loc.setZ(10.69);
loc.setYaw((float)-179.85);
loc.setPitch((float) 0.44999);
player.teleport(loc);
Start();
HerobrineAI.getPluginCore().getAICore().isTarget=true;
Bukkit.getServer().getWorld("world_herobrineai_graveyard").setStorm(false);
return new CoreResult(true,"Player successfully teleported!");
}else{return new CoreResult(false,"Player has Ancient Sword.");}
}
return new CoreResult(false,"Graveyard world is not allowed!");
}
public void Start(){
ticks=0;
HerobrineAI.HerobrineNPC.moveTo(new Location(Bukkit.getServer().getWorld("world_herobrineai_graveyard"),-2.49,4,-4.12));
HandlerInterval();
}
public void HandlerInterval(){
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(AICore.plugin, new Runnable() {
public void run() {
Handler();
}
}, 1 * 5L);
}
public void Handler(){
LivingEntities = Bukkit.getServer().getWorld("world_herobrineai_graveyard").getLivingEntities();
for (int i=0;i<=LivingEntities.size()-1;i++){
if (LivingEntities.get(i) instanceof Player || LivingEntities.get(i).getEntityId() == HerobrineAI.HerobrineEntityID){}else{
LivingEntities.get(i).remove();
}
}
if (savedPlayer.isDead()==true || savedPlayer.isOnline()==false || savedPlayer.getLocation().getWorld()!=Bukkit.getServer().getWorld("world_herobrineai_graveyard") || this.ticks==90 || HerobrineAI.getPluginCore().getAICore().isTarget==false){
if ( HerobrineAI.getPluginCore().getAICore().PlayerTarget==savedPlayer){
HerobrineAI.getPluginCore().getAICore().CancelTarget(CoreType.GRAVEYARD);
}
savedPlayer.teleport(new Location(savedWorld,savedX,savedY,savedZ));
}else{
Location ploc = (Location) savedPlayer.getLocation();
ploc.setY(ploc.getY()+1.5);
HerobrineAI.HerobrineNPC.lookAtPoint(ploc);
if (ticks==1){
HerobrineAI.HerobrineNPC.moveTo(new Location(Bukkit.getServer().getWorld("world_herobrineai_graveyard"),-2.49,4,-4.12));
}
else if (ticks==40){
HerobrineAI.HerobrineNPC.moveTo(new Location(Bukkit.getServer().getWorld("world_herobrineai_graveyard"),-2.49,4,-0.5));
}else if (ticks==60){
HerobrineAI.HerobrineNPC.moveTo(new Location(Bukkit.getServer().getWorld("world_herobrineai_graveyard"),-2.49,4,5.1));
}else if (ticks==84){
HerobrineAI.HerobrineNPC.moveTo(new Location(Bukkit.getServer().getWorld("world_herobrineai_graveyard"),-2.49,4,7.5));
}
if (new Random().nextInt(4)==1){
Location newloc = new Location(Bukkit.getServer().getWorld("world_herobrineai_graveyard"),(double)new Random().nextInt(400),(double)new Random().nextInt(20)+20,(double)new Random().nextInt(400));
Bukkit.getServer().getWorld("world_herobrineai_graveyard").strikeLightning(newloc);
}
ticks++;
HandlerInterval();
}
}
public Location getSavedLocation(){
return new Location(savedWorld,savedX,savedY,savedZ);
}
}

View File

@ -0,0 +1,254 @@
package org.jakub1221.herobrineai.AI.cores;
import java.util.Random;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.entity.CreatureType;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.entity.Wolf;
import org.jakub1221.herobrineai.HerobrineAI;
import org.jakub1221.herobrineai.AI.AICore;
import org.jakub1221.herobrineai.AI.Core;
import org.jakub1221.herobrineai.AI.CoreResult;
public class Haunt extends Core{
private int _ticks = 0;
private int ticksToEnd = 0;
private int spawnedWolves = 0;
private int spawnedBats = 0;
private int KL_INT=0;
private int PS_INT=0;
private boolean isHandler=false;
public Haunt(){
super(CoreType.HAUNT,AppearType.APPEAR);
}
public CoreResult CallCore(Object[] data){
return setHauntTarget((Player) data[0]);
}
public CoreResult setHauntTarget(Player player){
if (HerobrineAI.getPluginCore().getSupport().checkHaunt(player.getLocation())){
spawnedWolves=0;
spawnedBats=0;
_ticks=0;
ticksToEnd=0;
AICore.isTarget=true;
AICore.PlayerTarget=player;
AICore.log.info("[HerobrineAI] Hauntig player!");
Location loc = (Location) HerobrineAI.HerobrineNPC.getBukkitEntity().getLocation();
loc.setY(-20);
HerobrineAI.HerobrineNPC.moveTo(loc);
StartHandler();
return new CoreResult(true,"Herobrine haunts "+player.getName()+"!");
}
return new CoreResult(false,"Player is in secure area!");
}
public void StartHandler(){
isHandler=true;
KL_INT=Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(AICore.plugin, new Runnable() {
public void run() {
KeepLookingHaunt();
}
}, 1 * 5L, 1 * 5L);
PS_INT=Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(AICore.plugin, new Runnable() {
public void run() {
PlaySounds();
}
}, 1 * 35L, 1 * 35L);
}
public void StopHandler(){
if(isHandler){
isHandler=false;
Bukkit.getScheduler().cancelTask(KL_INT);
Bukkit.getScheduler().cancelTask(PS_INT);
}
}
public void PlaySounds(){
if (AICore.PlayerTarget.isOnline() && AICore.isTarget && HerobrineAI.getPluginCore().getAICore().getCoreTypeNow()==CoreType.HAUNT){
if (AICore.PlayerTarget.isDead()==false){
if (ticksToEnd==35){HerobrineAI.getPluginCore().getAICore().CancelTarget(CoreType.HAUNT);}else{
ticksToEnd++;
Object[] data = {AICore.PlayerTarget};
HerobrineAI.getPluginCore().getAICore().getCore(CoreType.SOUNDF).RunCore(data);
Location ploc = (Location) AICore.PlayerTarget.getLocation();
Random randxgen = new Random();
int randx= randxgen.nextInt(100);
if (randx<70){}
else if (randx<80 && spawnedBats<=3){
if (HerobrineAI.getPluginCore().getConfigDB().SpawnBats){
ploc.getWorld().spawnEntity(ploc, EntityType.BAT);
spawnedBats++;
}
}else if (randx<90 && spawnedWolves<=2){
if (HerobrineAI.getPluginCore().getConfigDB().SpawnWolves){
Wolf wolf = (Wolf) ploc.getWorld().spawnCreature(ploc, CreatureType.WOLF);
wolf.setAdult();
wolf.setAngry(true);
spawnedWolves++;
}
}
if (HerobrineAI.getPluginCore().getConfigDB().Lighting==true){
int lchance= new Random().nextInt(100);
if (lchance>75){
Location newloc = (Location) ploc;
int randz= new Random().nextInt(50);
int randxp= new Random().nextInt(1);
int randzp= new Random().nextInt(1);
if (randxp==1){
newloc.setX(newloc.getX()+randx);
}else{
newloc.setX(newloc.getX()-randx);
}
if (randzp==1){
newloc.setZ(newloc.getZ()+randz);
}else{
newloc.setZ(newloc.getZ()-randz);
}
newloc.setY(250);
newloc.getWorld().strikeLightning(newloc);
}
}
if (ticksToEnd==1){
Object[] data2 = {AICore.PlayerTarget.getLocation()};
HerobrineAI.getPluginCore().getAICore().getCore(CoreType.BUILD_STUFF).RunCore(data2);}
}
}else{HerobrineAI.getPluginCore().getAICore().CancelTarget(CoreType.HAUNT);}
}else{HerobrineAI.getPluginCore().getAICore().CancelTarget(CoreType.HAUNT);}
}
public void KeepLookingHaunt(){
if (AICore.PlayerTarget.isOnline() && AICore.isTarget && HerobrineAI.getPluginCore().getAICore().getCoreTypeNow()==CoreType.HAUNT){
if (AICore.PlayerTarget.isDead()==false){
Location loc = (Location) HerobrineAI.HerobrineNPC.getBukkitEntity().getLocation();
Player [] AllOnPlayers = Bukkit.getServer().getOnlinePlayers();
if (Bukkit.getServer().getOnlinePlayers().length>0){
int i = 0;
for (i=0;i<=Bukkit.getServer().getOnlinePlayers().length-1;i++){
if (AllOnPlayers[i].getEntityId()!=HerobrineAI.HerobrineEntityID){
Location ploc = (Location) AllOnPlayers[i].getLocation();
if (ploc.getWorld() == loc.getWorld() && ploc.getX()+5>loc.getX() && ploc.getX()-5<loc.getX() && ploc.getZ()+5>loc.getZ() && ploc.getZ()-5<loc.getZ() && ploc.getY()+5>loc.getY() && ploc.getY()-5<loc.getY()){
HerobrineAI.getPluginCore().getAICore().DisappearEffect();
}
}
}
}
HerobrineAI.HerobrineHP=HerobrineAI.HerobrineMaxHP;
loc = AICore.PlayerTarget.getLocation();
loc.setY(loc.getY()+1.5);
HerobrineAI.HerobrineNPC.lookAtPoint(loc);
_ticks++;
if (_ticks==0){HauntTP();}else if (_ticks==20){HerobrineAI.getPluginCore().getAICore().DisappearEffect();}else if (_ticks==30){HauntTP();}else if (_ticks==50){HerobrineAI.getPluginCore().getAICore().DisappearEffect();}else if (_ticks==60){HauntTP();}
else if (_ticks==80){HerobrineAI.getPluginCore().getAICore().DisappearEffect();}else if (_ticks==90){HauntTP();}else if (_ticks==115){HerobrineAI.getPluginCore().getAICore().DisappearEffect();}else if (_ticks==120){HauntTP();}else if (_ticks==140){HerobrineAI.getPluginCore().getAICore().DisappearEffect();}
else if (_ticks==145){HauntTP();}else if (_ticks==170){HerobrineAI.getPluginCore().getAICore().DisappearEffect();}else if (_ticks==175){HauntTP();}else if (_ticks==190){HerobrineAI.getPluginCore().getAICore().DisappearEffect();}
}else{HerobrineAI.getPluginCore().getAICore().CancelTarget(CoreType.HAUNT);}
}else{HerobrineAI.getPluginCore().getAICore().CancelTarget(CoreType.HAUNT);}
}
public void HauntTP(){
if (AICore.PlayerTarget.isOnline() && AICore.isTarget && HerobrineAI.getPluginCore().getAICore().getCoreTypeNow()==CoreType.HAUNT){
if (AICore.PlayerTarget.isDead()==false){
if (HerobrineAI.getPluginCore().getConfigDB().useWorlds.contains(AICore.PlayerTarget.getWorld().getName())){
FindPlace(AICore.PlayerTarget);
Location ploc = (Location) AICore.PlayerTarget.getLocation();
ploc.setY(ploc.getY()+1.5);
HerobrineAI.HerobrineNPC.lookAtPoint(ploc);
}else{HerobrineAI.getPluginCore().getAICore().CancelTarget(CoreType.HAUNT);}
}else{HerobrineAI.getPluginCore().getAICore().CancelTarget(CoreType.HAUNT);}
}else{HerobrineAI.getPluginCore().getAICore().CancelTarget(CoreType.HAUNT);}
}
public boolean FindPlace(Player player){
Location loc = (Location) player.getLocation();
int x=0;
int z=0;
int y=0;
int xMax=new Random().nextInt(10)-7;
int zMax=new Random().nextInt(10)-7;
for(y=-5;y<=5;y++){
for(x=xMax;x<=10;x++){
for(z=zMax;z<=10;z++){
if (HerobrineAI.StandBlocks.contains(loc.getWorld().getBlockAt(x+loc.getBlockX(), y+loc.getBlockY()-1, z+loc.getBlockZ()).getType())){
if (HerobrineAI.AllowedBlocks.contains(loc.getWorld().getBlockAt(x+loc.getBlockX(), y+loc.getBlockY(), z+loc.getBlockZ()).getType())){
if (HerobrineAI.AllowedBlocks.contains(loc.getWorld().getBlockAt(x+loc.getBlockX(), y+loc.getBlockY()+1, z+loc.getBlockZ()).getType())){
Teleport(loc.getWorld(),x+loc.getBlockX(),y+loc.getBlockY(),z+loc.getBlockZ());
}
}
}
}
}
}
return false;
}
public void Teleport(World world,int X,int Y,int Z){
Location loc = (Location) HerobrineAI.HerobrineNPC.getBukkitEntity().getLocation();
loc.setWorld(world);
loc.setX((double) X);
loc.setY((double) Y);
loc.setZ((double) Z);
HerobrineAI.HerobrineNPC.moveTo(loc);
}
}

View File

@ -0,0 +1,88 @@
package org.jakub1221.herobrineai.AI.cores;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.jakub1221.herobrineai.HerobrineAI;
import org.jakub1221.herobrineai.AI.AICore;
import org.jakub1221.herobrineai.AI.Core;
import org.jakub1221.herobrineai.AI.Core.AppearType;
import org.jakub1221.herobrineai.AI.CoreResult;
import org.jakub1221.herobrineai.misc.BlockChanger;
import org.jakub1221.herobrineai.misc.ItemName;
public class Heads extends Core{
private boolean isCalled=false;
private List<Block> headList = new ArrayList<Block>();
public Heads(){
super(CoreType.HEADS,AppearType.NORMAL);
}
public CoreResult CallCore(Object[] data){
if (isCalled==false){
if (Bukkit.getPlayer((String) data[0]).isOnline()){
Player player = (Player) Bukkit.getServer().getPlayer((String) data[0]);
if(HerobrineAI.getPluginCore().getSupport().checkBuild(player.getLocation())){
if (HerobrineAI.getPluginCore().getConfigDB().UseHeads){
Location loc = player.getLocation();
int px=loc.getBlockX();
int pz=loc.getBlockZ();
int y=0;
int x=-7;
int z=-7;
for (x=-7;x<=7;x++){
for (z=-7;z<=7;z++){
if(new Random().nextInt(7) == new Random().nextInt(7)){
if (HerobrineAI.NonStandBlocks.contains(loc.getWorld().getHighestBlockAt(px+x, pz+z).getType())){
y=loc.getWorld().getHighestBlockYAt(px+x, pz+z);
}else{
y=loc.getWorld().getHighestBlockYAt(px+x, pz+z)+1;
}
Block block = loc.getWorld().getBlockAt(px+x, y, pz+z);
BlockChanger.PlaceSkull(block.getLocation(),"Herobrine");
headList.add(block);
}
}
}
isCalled=true;
Bukkit.getScheduler().scheduleSyncDelayedTask(AICore.plugin, new Runnable() {
public void run() {
RemoveHeads();
}
}, 1 * 100L);
return new CoreResult(true,"Spawned some heads near "+player.getName()+"!");
}else{return new CoreResult(false,"Heads are disabled!");}
}else{return new CoreResult(false,"Player is in secure area!");}
}else{return new CoreResult(false,"Player is offline.");}
}else{
return new CoreResult(false,"There are already heads! Wait until they disappear.");
}
}
public void RemoveHeads(){
for (Block h : headList){
h.setType(Material.AIR);
}
headList.clear();
isCalled=false;
}
public ArrayList<Block> getHeadList(){
return (ArrayList<Block>) headList;
}
}

View File

@ -0,0 +1,204 @@
package org.jakub1221.herobrineai.AI.cores;
import java.util.Random;
import org.bukkit.Chunk;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.entity.Player;
import org.jakub1221.herobrineai.HerobrineAI;
import org.jakub1221.herobrineai.AI.AICore;
import org.jakub1221.herobrineai.AI.Core;
import org.jakub1221.herobrineai.AI.CoreResult;
public class Pyramid extends Core{
public Pyramid(){
super(CoreType.PYRAMID,AppearType.NORMAL);
}
public CoreResult CallCore(Object[] data){
if (data[0] instanceof Player){
return FindPlace((Player) data[0]);
}else{
return FindPlace((Chunk) data[0]);
}
}
public CoreResult FindPlace(Chunk chunk){
if (HerobrineAI.getPluginCore().getConfigDB().BuildPyramids){
Location loc = chunk.getBlock(2, 0, 2).getLocation();
loc=loc.getWorld().getHighestBlockAt(loc).getLocation();
boolean canBuild=true;
int i1=0;
int i2=5;
int i3=5;
int i4=0;
int i5=0;
int i6=0;
int x=0;
int y=0;
int z=0;
for (i1=-5;i1<=5;i1++){//Y
canBuild=true;
for (i4=-1;i4<=3;i4++){//Y
for(i5=-2;i5<=2;i5++){//X
for(i6=-2;i6<=2;i6++){//Z
if (loc.getBlockX()==i2+i5+loc.getBlockX() && loc.getBlockY()==i1+i4+loc.getBlockY() && loc.getBlockZ()==i3+i6+loc.getBlockZ()){canBuild=false;}
if (i4==-1){
if (canBuild==true){
if (HerobrineAI.StandBlocks.contains(loc.getWorld().getBlockAt(i2+i5+loc.getBlockX(), i1+i4+loc.getBlockY(), i3+i6+loc.getBlockZ()).getType())){canBuild=true;}else{canBuild=false;}
}
}else{
if (canBuild==true){
if (HerobrineAI.NonStandBlocks.contains(loc.getWorld().getBlockAt(i2+i5+loc.getBlockX(), i1+i4+loc.getBlockY(), i3+i6+loc.getBlockZ()).getType())){canBuild=true;}else{canBuild=false;}
}
}
}
}
}
if (canBuild==true){
BuildPyramid(loc.getWorld(),i2+loc.getBlockX(),i1+loc.getBlockY(),i3+loc.getBlockZ());
return new CoreResult(true,"Creating a pyramid!");
}
}
}
return new CoreResult(false,"Cannot create a pyramid!");
}
public CoreResult FindPlace(Player player){
if (HerobrineAI.getPluginCore().getConfigDB().BuildPyramids){
Location loc = (Location) player.getLocation();
boolean canBuild=true;
int i1=0;
int i2=0;
int i3=0;
int i4=0;
int i5=0;
int i6=0;
int xMax=new Random().nextInt(15)-10;
int zMax=new Random().nextInt(15)-10;
for (i1=-5;i1<=5;i1++){//Y
for(i2=xMax;i2<=15;i2++){//X
for(i3=zMax;i3<=15;i3++){//Z
canBuild=true;
for (i4=-1;i4<=3;i4++){//Y
for(i5=-2;i5<=2;i5++){//X
for(i6=-2;i6<=2;i6++){//Z
if (player.getLocation().getBlockX()==i2+i5+loc.getBlockX() && player.getLocation().getBlockY()==i1+i4+loc.getBlockY() && player.getLocation().getBlockZ()==i3+i6+loc.getBlockZ()){canBuild=false;}
if (i4==-1){
if (canBuild==true){
if (HerobrineAI.StandBlocks.contains(loc.getWorld().getBlockAt(i2+i5+loc.getBlockX(), i1+i4+loc.getBlockY(), i3+i6+loc.getBlockZ()).getType())){canBuild=true;}else{canBuild=false;}
}
}else{
if (canBuild==true){
if (HerobrineAI.NonStandBlocks.contains(loc.getWorld().getBlockAt(i2+i5+loc.getBlockX(), i1+i4+loc.getBlockY(), i3+i6+loc.getBlockZ()).getType())){canBuild=true;}else{canBuild=false;}
}
}
}
}
}
if (canBuild==true){
BuildPyramid(loc.getWorld(),i2+loc.getBlockX(),i1+loc.getBlockY(),i3+loc.getBlockZ());
return new CoreResult(true,"Creating a pyramid!");
}
}
}
}
}
return new CoreResult(false,"Cannot create a pyramid!");
}
public void BuildPyramid(World world,int X,int Y,int Z){
if (HerobrineAI.getPluginCore().getSupport().checkBuild(new Location(world,X,Y,Z))){
AICore.log.info("Creating pyramid at "+X+","+Y+","+Z);
Material mainMat = (Material) Material.SANDSTONE;
// Level 1
world.getBlockAt(X,Y,Z).setType(mainMat);
world.getBlockAt(X-2,Y,Z).setType(mainMat);
world.getBlockAt(X-1,Y,Z).setType(mainMat);
world.getBlockAt(X+1,Y,Z).setType(mainMat);
world.getBlockAt(X+2,Y,Z).setType(mainMat);
world.getBlockAt(X-2,Y,Z-1).setType(mainMat);
world.getBlockAt(X-2,Y,Z+1).setType(mainMat);
world.getBlockAt(X-1,Y,Z-1).setType(mainMat);
world.getBlockAt(X-1,Y,Z+1).setType(mainMat);
world.getBlockAt(X,Y,Z-1).setType(mainMat);
world.getBlockAt(X,Y,Z+1).setType(mainMat);
world.getBlockAt(X,Y,Z-2).setType(mainMat);
world.getBlockAt(X,Y,Z+2).setType(mainMat);
world.getBlockAt(X-1,Y,Z-2).setType(mainMat);
world.getBlockAt(X-1,Y,Z+2).setType(mainMat);
world.getBlockAt(X+1,Y,Z-2).setType(mainMat);
world.getBlockAt(X+1,Y,Z+2).setType(mainMat);
world.getBlockAt(X+1,Y,Z-1).setType(mainMat);
world.getBlockAt(X+1,Y,Z+1).setType(mainMat);
world.getBlockAt(X+2,Y,Z-1).setType(mainMat);
world.getBlockAt(X+2,Y,Z+1).setType(mainMat);
world.getBlockAt(X+1,Y,Z-2).setType(mainMat);
world.getBlockAt(X+1,Y,Z+2).setType(mainMat);
// Level 2
world.getBlockAt(X,Y+1,Z).setType(mainMat);
world.getBlockAt(X-1,Y+1,Z).setType(mainMat);
world.getBlockAt(X+1,Y+1,Z).setType(mainMat);
world.getBlockAt(X-1,Y+1,Z-1).setType(mainMat);
world.getBlockAt(X+1,Y+1,Z-1).setType(mainMat);
world.getBlockAt(X-1,Y+1,Z+1).setType(mainMat);
world.getBlockAt(X+1,Y+1,Z+1).setType(mainMat);
world.getBlockAt(X,Y+1,Z+1).setType(mainMat);
world.getBlockAt(X,Y+1,Z+1).setType(mainMat);
world.getBlockAt(X,Y+1,Z-1).setType(mainMat);
world.getBlockAt(X,Y+1,Z-1).setType(mainMat);
// Level 3
world.getBlockAt(X,Y+2,Z).setType(mainMat);
// Level 4
world.getBlockAt(X,Y+3,Z).setType(Material.REDSTONE_TORCH_ON);
}
}
}

View File

@ -0,0 +1,200 @@
package org.jakub1221.herobrineai.AI.cores;
import java.util.Random;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.entity.Player;
import org.jakub1221.herobrineai.ConfigDB;
import org.jakub1221.herobrineai.HerobrineAI;
import org.jakub1221.herobrineai.AI.AICore;
import org.jakub1221.herobrineai.AI.Core;
import org.jakub1221.herobrineai.AI.CoreResult;
import org.jakub1221.herobrineai.NPC.AI.Path;
public class RandomPosition extends Core{
private int randomTicks=0;
private int randomMoveTicks=0;
private boolean RandomMoveIsPlayer=false;
public RandomPosition(){
super(CoreType.RANDOM_POSITION,AppearType.APPEAR);
}
public int getRandomTicks(){return this.randomTicks;}
public int getRandomMoveTicks(){return this.randomMoveTicks;}
public void setRandomTicks(int i){this.randomTicks=i;};
public void setRandomMoveTicks(int i){this.randomMoveTicks=i;};
public CoreResult CallCore(Object[] data){
return setRandomPosition((World)data[0]);
}
public CoreResult setRandomPosition(World world){
if (HerobrineAI.getPluginCore().getConfigDB().UseWalkingMode){
if (randomTicks!=3){
randomTicks++;
if (HerobrineAI.getPluginCore().getAICore().getCoreTypeNow() != CoreType.RANDOM_POSITION && AICore.isTarget==false){
Location newloc = (Location) getRandomLocation(world);
if (newloc!=null){
HerobrineAI.HerobrineNPC.moveTo(newloc);
newloc.setX(newloc.getX()+2);
newloc.setY(newloc.getY()+1.5);
HerobrineAI.HerobrineNPC.lookAtPoint(newloc);
randomTicks=0;
AICore.log.info("[HerobrineAI] Herobrine is now in RandomLocation mode.");
HerobrineAI.getPluginCore().getAICore().Start_RM();
HerobrineAI.getPluginCore().getAICore().Start_RS();
HerobrineAI.getPluginCore().getAICore().Start_CG();
RandomMoveIsPlayer=false;
return new CoreResult(true,"Herobrine is now in WalkingMode.");
}else{AICore.log.info("[HerobrineAI] RandomPosition Failed!");return setRandomPosition(world);}
}
}else{
return new CoreResult(false,"WalkingMode - Find location failed!");
}
}else{
return new CoreResult(false,"WalkingMode is disabled!");
}
return new CoreResult(false,"WalkingMode failed!");
}
public Location getRandomLocation(World world){
int i = 0;
for (i=0;i<=300;i++){
int r_nxtX=HerobrineAI.getPluginCore().getConfigDB().WalkingModeXRadius;
int nxtX=r_nxtX;
if (nxtX<0){
nxtX=-nxtX;
}
int r_nxtZ=HerobrineAI.getPluginCore().getConfigDB().WalkingModeZRadius;
int nxtZ=r_nxtZ;
if (nxtZ<0){
nxtZ=-nxtZ;
}
int randx= new Random().nextInt(nxtX);
int randy=0;
int randz= new Random().nextInt(nxtZ);
int randxp= new Random().nextInt(1);
int randzp= new Random().nextInt(1);
if (randxp==0 && randx!=0){randx=-(randx);}
if (randzp==0 && randz!=0){randz=-(randz);}
randx=randx+HerobrineAI.getPluginCore().getConfigDB().WalkingModeFromXRadius;
randz=randz+HerobrineAI.getPluginCore().getConfigDB().WalkingModeFromZRadius;
if (world != null){
randy=world.getHighestBlockYAt(randx,randz);
}else{
return null;
}
if (world.getBlockAt(randx, randy, randz).getType() == Material.AIR && world.getBlockAt(randx, randy+1, randz).getType() == Material.AIR){
if (world.getBlockAt(randx, randy-1, randz).getType() != Material.AIR &&
world.getBlockAt(randx, randy-1, randz).getType() != Material.WATER &&
world.getBlockAt(randx, randy-1, randz).getType() != Material.LAVA &&
world.getBlockAt(randx, randy-1, randz).getType() != Material.GRASS &&
world.getBlockAt(randx, randy-1, randz).getType() != Material.SNOW &&
world.getBlockAt(randx, randy-1, randz).getType() != Material.LEAVES &&
world.getBlockAt(randx, randy-1, randz).getType() != Material.WHEAT &&
world.getBlockAt(randx, randy-1, randz).getType() != Material.TORCH &&
world.getBlockAt(randx, randy-1, randz).getType() != Material.REDSTONE_TORCH_OFF &&
world.getBlockAt(randx, randy-1, randz).getType() != Material.REDSTONE_TORCH_ON &&
world.getBlockAt(randx, randy-1, randz).getType() != Material.REDSTONE &&
world.getBlockAt(randx, randy-1, randz).getType() != Material.STATIONARY_WATER &&
world.getBlockAt(randx, randy-1, randz).getType() != Material.STATIONARY_LAVA){
AICore.log.info("[HerobrineAI] RandomLocation "+world.getBlockAt(randx, randy-1, randz).getType().toString()+" is X:"+randx+" Y:"+randy+" Z:"+randz);
return new Location(world,(float) randx + 0.5,(float) randy,(float) randz);
}
}
}
return null;
}
public void RandomMove(){
if (HerobrineAI.getPluginCore().getAICore().getCoreTypeNow()==CoreType.RANDOM_POSITION && AICore.isTarget==false && RandomMoveIsPlayer==false){
HerobrineAI.HerobrineHP=HerobrineAI.HerobrineMaxHP;
if (new Random().nextInt(4)==1){
Location loc = HerobrineAI.HerobrineNPC.getBukkitEntity().getLocation();
Path path = new Path((float)loc.getX()+new Random().nextInt(12)-6,(float)loc.getZ()+new Random().nextInt(12)-6);
HerobrineAI.getPluginCore().getPathManager().setPath(path);
}
}
}
public void CheckGravity(){
if (HerobrineAI.getPluginCore().getAICore().getCoreTypeNow()==CoreType.RANDOM_POSITION && AICore.isTarget==false){
Location hbloc = (Location) HerobrineAI.HerobrineNPC.getBukkitEntity().getLocation();
World w = (World) hbloc.getWorld();
ConfigDB config = HerobrineAI.getPluginCore().getConfigDB();
if (hbloc.getBlockX()<config.WalkingModeXRadius+config.WalkingModeFromXRadius && hbloc.getBlockX()>(-config.WalkingModeXRadius)+config.WalkingModeFromXRadius && hbloc.getBlockZ()<config.WalkingModeZRadius+config.WalkingModeFromZRadius && hbloc.getBlockZ()>(-config.WalkingModeZRadius)+config.WalkingModeFromZRadius){
if (HerobrineAI.NonStandBlocks.contains(w.getBlockAt(hbloc.getBlockX(), hbloc.getBlockY()-1, hbloc.getBlockZ()).getType())){
hbloc.setY(hbloc.getY()-1);
HerobrineAI.HerobrineNPC.moveTo(hbloc);
}
}else{
HerobrineAI.getPluginCore().getAICore().CancelTarget(CoreType.RANDOM_POSITION);
}
}
}
public void CheckPlayerPosition(){
boolean isThere=false;
Location loc = (Location) HerobrineAI.HerobrineNPC.getBukkitEntity().getLocation();
Player [] AllOnPlayers = Bukkit.getServer().getOnlinePlayers();
if (Bukkit.getServer().getOnlinePlayers().length>0){
int i = 0;
for (i=0;i<=Bukkit.getServer().getOnlinePlayers().length-1;i++){
if (HerobrineAI.HerobrineEntityID!=AllOnPlayers[i].getEntityId()){
Location ploc = (Location) AllOnPlayers[i].getLocation();
if (ploc.getWorld() == loc.getWorld() && ploc.getX()+7>loc.getX() && ploc.getX()-7<loc.getX() && ploc.getZ()+7>loc.getZ() && ploc.getZ()-7<loc.getZ() && ploc.getY()+7>loc.getY() && ploc.getY()-7<loc.getY()){
loc.setY(-20);
HerobrineAI.HerobrineNPC.moveTo(loc);
HerobrineAI.getPluginCore().getAICore().CancelTarget(CoreType.RANDOM_POSITION);
RandomMoveIsPlayer=false;
HerobrineAI.getPluginCore().getAICore().setAttackTarget(AllOnPlayers[i]);
}else{
if (ploc.getWorld() == loc.getWorld() && ploc.getX()+15>loc.getX() && ploc.getX()-15<loc.getX() && ploc.getZ()+15>loc.getZ() && ploc.getZ()-15<loc.getZ() && ploc.getY()+15>loc.getY() && ploc.getY()-15<loc.getY()){
ploc.setY(ploc.getY()+1.5);
HerobrineAI.HerobrineNPC.lookAtPoint(ploc);
HerobrineAI.getPluginCore().getPathManager().setPath(null);
isThere=true;
}
}
}
}
}
if (isThere){
RandomMoveIsPlayer=true;
}else{
RandomMoveIsPlayer=false;
}
}
}

View File

@ -0,0 +1,80 @@
package org.jakub1221.herobrineai.AI.cores;
import java.util.Random;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.Sign;
import org.jakub1221.herobrineai.HerobrineAI;
import org.jakub1221.herobrineai.AI.ConsoleLogger;
import org.jakub1221.herobrineai.AI.Core;
import org.jakub1221.herobrineai.AI.CoreResult;
import org.jakub1221.herobrineai.misc.BlockChanger;
public class Signs extends Core{
public Signs(){
super(CoreType.SIGNS,AppearType.NORMAL);
}
public CoreResult CallCore(Object[] data){
return placeSign((Location) data[0],(Location) data[1]);
}
static ConsoleLogger log = new ConsoleLogger();
public CoreResult placeSign(Location loc,Location ploc){
boolean status=false;
log.info("Generating sign location...");
if (loc.getWorld().getBlockAt(loc.getBlockX()+2, loc.getBlockY(), loc.getBlockZ()).getType() == Material.AIR && loc.getWorld().getBlockAt(loc.getBlockX()+2, loc.getBlockY()-1, loc.getBlockZ()).getType()!= Material.AIR){
loc.setX(loc.getBlockX()+2);
createSign(loc,ploc);
status=true;
}else if (loc.getWorld().getBlockAt(loc.getBlockX()-2, loc.getBlockY(), loc.getBlockZ()).getType() == Material.AIR && loc.getWorld().getBlockAt(loc.getBlockX()-2, loc.getBlockY()-1, loc.getBlockZ()).getType()!= Material.AIR){
loc.setX(loc.getBlockX()-2);
createSign(loc,ploc);
status=true;
}else if (loc.getWorld().getBlockAt(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()+2).getType() == Material.AIR && loc.getWorld().getBlockAt(loc.getBlockX(), loc.getBlockY()-1, loc.getBlockZ()+2).getType()!= Material.AIR){
loc.setZ(loc.getBlockZ()+2);
createSign(loc,ploc);
status=true;
}else if (loc.getWorld().getBlockAt(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()-2).getType() == Material.AIR && loc.getWorld().getBlockAt(loc.getBlockX(), loc.getBlockY()-1, loc.getBlockZ()-2).getType()!= Material.AIR){
loc.setZ(loc.getBlockZ()-2);
createSign(loc,ploc);
status=true;
}
if (status){
return new CoreResult(true,"Sign placed!");
}else{
return new CoreResult(false,"Cannot place a sign!");
}
}
public void createSign(Location loc,Location ploc){
Random randcgen = new Random();
int chance=randcgen.nextInt(100);
if (chance>(100-HerobrineAI.getPluginCore().getConfigDB().SignChance)){
Random randgen = new Random();
int count = HerobrineAI.getPluginCore().getConfigDB().useSignMessages.size();
int randmsg=randgen.nextInt(count);
Block signblock = loc.add(0, 0D ,0).getBlock();
Block undersignblock = signblock.getLocation().subtract(0D, 1D, 0D).getBlock();
if (HerobrineAI.NonStandBlocks.contains(signblock.getType()) && !HerobrineAI.NonStandBlocks.contains(undersignblock.getType())){
signblock.setType(Material.SIGN_POST);
Sign sign = (Sign) signblock.getState();
sign.setLine(1, HerobrineAI.getPluginCore().getConfigDB().useSignMessages.get(randmsg));
sign.setRawData((byte) BlockChanger.getPlayerBlockFace(ploc).ordinal());
sign.update();
}
}
}
}

View File

@ -0,0 +1,57 @@
package org.jakub1221.herobrineai.AI.cores;
import java.util.Random;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
import org.jakub1221.herobrineai.AI.Core;
import org.jakub1221.herobrineai.AI.CoreResult;
public class SoundF extends Core{
public SoundF(){
super(CoreType.SOUNDF,AppearType.NORMAL);
}
public CoreResult CallCore(Object[] data){
return playRandom((Player)data[0]);
}
public CoreResult playRandom(Player player){
Sound sound = Sound.BREATH;
Random generator = new Random();
int chance= generator.nextInt(20);
if (chance<5){
sound = Sound.STEP_STONE;
}else if (chance<10){
sound = Sound.STEP_SAND;
}else if (chance<14){
sound = Sound.STEP_GRASS;
}else if (chance<18){
sound = Sound.STEP_GRAVEL;
}else{sound = Sound.BREATH;}
Random randxgen = new Random();
int randx= randxgen.nextInt(3);
Random randzgen = new Random();
int randz= randzgen.nextInt(3);
Random randxgenp = new Random();
int randxp= randxgenp.nextInt(1);
Random randzgenp = new Random();
int randzp= randzgenp.nextInt(1);
if (randxp==0 && randx!=0){randx=(-(randx));}
if (randzp==0 && randz!=0){randz=(-(randz));}
player.playSound(player.getLocation(),sound,(float) 0.75,(float) 0.75);
return new CoreResult(true,"SoundF is starting!");
}
}

View File

@ -0,0 +1,218 @@
package org.jakub1221.herobrineai.AI.cores;
import java.io.File;
import java.util.ArrayList;
import java.util.Random;
import org.bukkit.Chunk;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.Chest;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.jakub1221.herobrineai.HerobrineAI;
import org.jakub1221.herobrineai.AI.Core;
import org.jakub1221.herobrineai.AI.CoreResult;
import org.jakub1221.herobrineai.entity.MobType;
import org.jakub1221.herobrineai.misc.ItemName;
import org.jakub1221.herobrineai.misc.StructureLoader;
public class Temple extends Core{
public Temple(){
super(CoreType.TEMPLE,AppearType.NORMAL);
}
public CoreResult CallCore(Object[] data){
if (data[0] instanceof Player){
return FindPlacePlayer((Player)data[0]);
}else{
return FindPlacePlayer((Chunk)data[0]);
}
}
public CoreResult FindPlacePlayer(Player player){
Location loc = player.getLocation();
boolean canBuild=true;
int i1=0;
int i2=0;
int i3=0;
int i4=0;
int i5=0;
int i6=0;
for (i1=-5;i1<=5;i1++){//Y
for(i2=-20;i2<=20;i2++){//X
for(i3=-20;i3<=20;i3++){//Z
canBuild=true;
for (i4=-1;i4<=12;i4++){//Y
for(i5=0;i5<=11;i5++){//X
for(i6=0;i6<=10;i6++){//Z
if (player.getLocation().getBlockX()==i2+i5+loc.getBlockX() && player.getLocation().getBlockY()==i1+i4+loc.getBlockY() && player.getLocation().getBlockZ()==i3+i6+loc.getBlockZ()){canBuild=false;}
if (i4==-1){
if (canBuild==true){
if (HerobrineAI.StandBlocks.contains(loc.getWorld().getBlockAt(i2+i5+loc.getBlockX(), i1+i4+loc.getBlockY(), i3+i6+loc.getBlockZ()).getType())){canBuild=true;}else{canBuild=false;}
}
}else{
if (canBuild==true){
if (HerobrineAI.NonStandBlocks.contains(loc.getWorld().getBlockAt(i2+i5+loc.getBlockX(), i1+i4+loc.getBlockY(), i3+i6+loc.getBlockZ()).getType())){canBuild=true;}else{canBuild=false;}
}
}
}
}
}
if (canBuild==true){
Create(loc.getWorld(),i2+loc.getBlockX(),i1+loc.getBlockY(),i3+loc.getBlockZ());
return new CoreResult(true,"Creating temple near "+player.getName()+"!");
}
}
}
}
return new CoreResult(false,"Cannot find a good place for Temple.");
}
public CoreResult FindPlacePlayer(Chunk chunk){
Location loc = chunk.getBlock(2, 0, 2).getLocation();
loc=loc.getWorld().getHighestBlockAt(loc).getLocation();
boolean canBuild=true;
int i1=0;
int i2=0;
int i3=0;
int i4=0;
int i5=0;
int i6=0;
i1=0;
i2=0;
i3=0;
i4=0;
i5=0;
i6=0;
for (i1=-5;i1<=5;i1++){//Y
canBuild=true;
for (i4=-1;i4<=12;i4++){//Y
for(i5=0;i5<=11;i5++){//X
for(i6=0;i6<=10;i6++){//Z
if (loc.getBlockX()==i2+i5+loc.getBlockX() && loc.getBlockY()==i1+i4+loc.getBlockY() && loc.getBlockZ()==i3+i6+loc.getBlockZ()){canBuild=false;}
if (i4==-1){
if (canBuild==true){
if (HerobrineAI.StandBlocks.contains(loc.getWorld().getBlockAt(i2+i5+loc.getBlockX(), i1+i4+loc.getBlockY(), i3+i6+loc.getBlockZ()).getType())){canBuild=true;}else{canBuild=false;}
}
}else{
if (canBuild==true){
if (HerobrineAI.NonStandBlocks.contains(loc.getWorld().getBlockAt(i2+i5+loc.getBlockX(), i1+i4+loc.getBlockY(), i3+i6+loc.getBlockZ()).getType())){canBuild=true;}else{canBuild=false;}
}
}
}
}
}
if (canBuild==true){
Create(loc.getWorld(),i2+loc.getBlockX(),i1+loc.getBlockY(),i3+loc.getBlockZ());
return new CoreResult(true,"Creating temple!");
}
}
return new CoreResult(false,"Cannot find a good place for Temple.");
}
public void Create(World world,int X,int Y,int Z){
Location loc = new Location(world,X,Y,Z);
if (HerobrineAI.getPluginCore().getSupport().checkBuild(new Location(world,X,Y,Z))){
int MainX=loc.getBlockX();
int MainY=loc.getBlockY();
int MainZ=loc.getBlockZ();
//Main blocks
new StructureLoader(HerobrineAI.getPluginCore().data_temple).Build(loc.getWorld(), MainX, MainY, MainZ);
//Mob spawn
if (HerobrineAI.getPluginCore().getConfigDB().UseNPC_Guardian){
Location mobloc = new Location(loc.getWorld(),MainX+6, MainY+0, MainZ+4);
HerobrineAI.getPluginCore().getEntityManager().spawnCustomZombie(mobloc, MobType.ARTIFACT_GUARDIAN);
}
//Chest
ItemStack ciItem=null;
if (HerobrineAI.getPluginCore().getConfigDB().UseCustomItems){
if (HerobrineAI.getPluginCore().getConfigDB().UseCustomItemsList.size()>0){
Random generator = new Random();
int chance = generator.nextInt(HerobrineAI.getPluginCore().getConfigDB().UseCustomItemsList.size());
if (HerobrineAI.getPluginCore().getSupport().isCustomItems()){
if (HerobrineAI.getPluginCore().getSupport().getCustomItems().checkItem(HerobrineAI.getPluginCore().getConfigDB().UseCustomItemsList.get(chance))){
ciItem=HerobrineAI.getPluginCore().getSupport().getCustomItems().getItem(HerobrineAI.getPluginCore().getConfigDB().UseCustomItemsList.get(chance));
}
}
}
if (ciItem!=null){
Chest chest = (Chest) loc.getWorld().getBlockAt(MainX+6, MainY+0, MainZ+2).getState();
chest.getBlockInventory().setItem(chest.getInventory().firstEmpty(), ciItem);
}
}else{
Random generator = new Random();
int chance = generator.nextInt(15);
ItemStack item = null;
ArrayList<String> newLore = new ArrayList<String>();
if (chance<4 && HerobrineAI.getPluginCore().getConfigDB().UseArtifactBow){
item = new ItemStack(Material.BOW);
newLore.add("Herobrine´s artifact");
newLore.add("Bow of Teleporting");
item = ItemName.setNameAndLore(item, "Bow of Teleporting", newLore);
}else if (chance<8 && HerobrineAI.getPluginCore().getConfigDB().UseArtifactSword){
item = new ItemStack(Material.DIAMOND_SWORD);
newLore.add("Herobrine´s artifact");
newLore.add("Sword of Lighting");
item = ItemName.setNameAndLore(item, "Sword of Lighting", newLore);
}else if (chance<12 && HerobrineAI.getPluginCore().getConfigDB().UseArtifactApple){
item = new ItemStack(Material.GOLDEN_APPLE);
newLore.add("Herobrine´s artifact");
newLore.add("Apple of Death");
item = ItemName.setNameAndLore(item, "Apple of Death", newLore);
}else{
if (HerobrineAI.getPluginCore().getConfigDB().UseAncientSword){
item=HerobrineAI.getPluginCore().getAICore().createAncientSword();
}
}
Chest chest = (Chest) loc.getWorld().getBlockAt(MainX+6, MainY+0, MainZ+2).getState();
chest.getBlockInventory().setItem(chest.getInventory().firstEmpty(), item);
}
}
}
}

View File

@ -0,0 +1,151 @@
package org.jakub1221.herobrineai.AI.cores;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import org.jakub1221.herobrineai.HerobrineAI;
import org.jakub1221.herobrineai.AI.AICore;
import org.jakub1221.herobrineai.AI.Core;
import org.jakub1221.herobrineai.AI.CoreResult;
import org.jakub1221.herobrineai.AI.Message;
import org.jakub1221.herobrineai.AI.Core.CoreType;
public class Totem extends Core{
public Totem(){
super(CoreType.TOTEM,AppearType.APPEAR);
}
public CoreResult CallCore(Object[] data){
return TotemCall((Location)data[0],(String)data[1]);
}
public CoreResult TotemCall(Location loc,String caller){
AICore.isTotemCalled=false;
loc.getWorld().strikeLightning(loc);
if (HerobrineAI.getPluginCore().getConfigDB().TotemExplodes==true){
loc.getWorld().createExplosion(loc, 5);
}
if (Bukkit.getServer().getPlayer(caller) != null){
if (Bukkit.getServer().getPlayer(caller).isOnline()){
HerobrineAI.getPluginCore().getAICore().setCoreTypeNow(CoreType.TOTEM);
HerobrineAI.getPluginCore().getAICore().setAttackTarget(Bukkit.getServer().getPlayer(caller));
Player player = (Player) Bukkit.getServer().getPlayer(caller);
Player [] AllOnPlayers = Bukkit.getServer().getOnlinePlayers();
if (Bukkit.getServer().getOnlinePlayers().length>0){
int i = 0;
for (i=0;i<=Bukkit.getServer().getOnlinePlayers().length-1;i++){
Location ploc = (Location) AllOnPlayers[i].getLocation();
if (AllOnPlayers[i].getName() != player.getName() && ploc.getX()+10>loc.getX() && ploc.getX()-10<loc.getX() && ploc.getZ()+10>loc.getZ() && ploc.getZ()-10<loc.getZ()){
Message.SendMessage(AllOnPlayers[i]);
if (HerobrineAI.getPluginCore().getConfigDB().UsePotionEffects){
AllOnPlayers[i].addPotionEffect(new PotionEffect(PotionEffectType.CONFUSION, 1000, 1));
AllOnPlayers[i].addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, 1000, 1));
AllOnPlayers[i].addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 1000, 1));
}
}
}
}
}else{
boolean hasTarget=false;
Player target = null;
Player [] AllOnPlayers = Bukkit.getServer().getOnlinePlayers();
if (Bukkit.getServer().getOnlinePlayers().length>0){
int i = 0;
for (i=0;i<=Bukkit.getServer().getOnlinePlayers().length-1;i++){
if (hasTarget==false){
Location ploc = (Location) AllOnPlayers[i].getLocation();
if (ploc.getX()+10>loc.getX() && ploc.getX()-10<loc.getX() && ploc.getZ()+10>loc.getZ() && ploc.getZ()-10<loc.getZ()){
hasTarget=true;
target=AllOnPlayers[i];
}
}
}
}
if (hasTarget==true){
HerobrineAI.getPluginCore().getAICore().CancelTarget(CoreType.TOTEM);
HerobrineAI.getPluginCore().getAICore().setAttackTarget(target);
Player player = (Player) target;
if (Bukkit.getServer().getOnlinePlayers().length>0){
int i = 0;
for (i=0;i<=Bukkit.getServer().getOnlinePlayers().length-1;i++){
Location ploc = (Location) AllOnPlayers[i].getLocation();
if (AllOnPlayers[i].getName() != player.getName() && ploc.getX()+20>loc.getX() && ploc.getX()-20<loc.getX() && ploc.getZ()+20>loc.getZ() && ploc.getZ()-20<loc.getZ()){
Message.SendMessage(AllOnPlayers[i]);
AllOnPlayers[i].addPotionEffect(new PotionEffect(PotionEffectType.CONFUSION, 1000, 1));
AllOnPlayers[i].addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, 1000, 1));
AllOnPlayers[i].addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 1000, 1));
}
}
}
}
}
}else{
boolean hasTarget=false;
Player target = null;
Player [] AllOnPlayers = Bukkit.getServer().getOnlinePlayers();
if (Bukkit.getServer().getOnlinePlayers().length>0){
int i = 0;
for (i=0;i<=Bukkit.getServer().getOnlinePlayers().length-1;i++){
if (hasTarget==false){
Location ploc = (Location) AllOnPlayers[i].getLocation();
if (ploc.getX()+20>loc.getX() && ploc.getX()-20<loc.getX() && ploc.getZ()+20>loc.getZ() && ploc.getZ()-20<loc.getZ()){
hasTarget=true;
target=AllOnPlayers[i];
}
}
}
}
if (hasTarget==true){
HerobrineAI.getPluginCore().getAICore().CancelTarget(CoreType.TOTEM);
HerobrineAI.getPluginCore().getAICore().setAttackTarget(target);
Player player = (Player) target;
if (Bukkit.getServer().getOnlinePlayers().length>0){
int i = 0;
for (i=0;i<=Bukkit.getServer().getOnlinePlayers().length-1;i++){
if (AllOnPlayers[i].getEntityId()!=HerobrineAI.HerobrineEntityID){
Location ploc = (Location) AllOnPlayers[i].getLocation();
if (AllOnPlayers[i].getName() != player.getName() && ploc.getX()+20>loc.getX() && ploc.getX()-20<loc.getX() && ploc.getZ()+20>loc.getZ() && ploc.getZ()-20<loc.getZ()){
Message.SendMessage(AllOnPlayers[i]);
AllOnPlayers[i].addPotionEffect(new PotionEffect(PotionEffectType.CONFUSION, 1000, 1));
AllOnPlayers[i].addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, 1000, 1));
AllOnPlayers[i].addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 1000, 1));
}
}
}
}
}
}
return new CoreResult(false,"Totem called!");
}
}

View File

@ -0,0 +1,34 @@
package org.jakub1221.herobrineai.AI.extensions;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.jakub1221.herobrineai.HerobrineAI;
import org.jakub1221.herobrineai.misc.StructureLoader;
public class GraveyardWorld{
public static void Create(){
Location loc = new Location(Bukkit.getServer().getWorld("world_herobrineai_graveyard"),0,3,0);
for(int x=-50;x<=50;x++){
for(int z=-50;z<=50;z++){
loc.getWorld().getBlockAt(x, 3, z).setTypeId(110);
}
}
int MainX=-10;
int MainY=3;
int MainZ=-10;
new StructureLoader(HerobrineAI.getPluginCore().data_graveyard_world).Build(loc.getWorld(), MainX, MainY, MainZ);
}
}

View File

@ -0,0 +1,132 @@
package org.jakub1221.herobrineai.AI.extensions;
import java.util.Random;
import org.bukkit.Location;
import org.jakub1221.herobrineai.HerobrineAI;
public class Position{
public static Location getTeleportPosition(Location ploc){
Location newloc = (Location) ploc;
int chance= new Random().nextInt(3);
if (chance==0){
if (HerobrineAI.AllowedBlocks.contains(ploc.getWorld().getBlockAt(ploc.getBlockX()-2, ploc.getBlockY(), ploc.getBlockZ()).getType()) && HerobrineAI.AllowedBlocks.contains(ploc.getWorld().getBlockAt(ploc.getBlockX()-2, ploc.getBlockY()+1, ploc.getBlockZ()).getType())){
newloc.setX(newloc.getX()-2);
}else if (HerobrineAI.AllowedBlocks.contains(ploc.getWorld().getBlockAt(ploc.getBlockX()+2, ploc.getBlockY(), ploc.getBlockZ()).getType()) && HerobrineAI.AllowedBlocks.contains(ploc.getWorld().getBlockAt(ploc.getBlockX()+2, ploc.getBlockY()+1, ploc.getBlockZ()).getType())){
newloc.setX(newloc.getX()+2);
}else if (HerobrineAI.AllowedBlocks.contains(ploc.getWorld().getBlockAt(ploc.getBlockX(), ploc.getBlockY(), ploc.getBlockZ()-2).getType()) && HerobrineAI.AllowedBlocks.contains(ploc.getWorld().getBlockAt(ploc.getBlockX(), ploc.getBlockY()+1, ploc.getBlockZ()-2).getType())){
newloc.setZ(newloc.getZ()-2);
}else if (HerobrineAI.AllowedBlocks.contains(ploc.getWorld().getBlockAt(ploc.getBlockX(), ploc.getBlockY(), ploc.getBlockZ()+2).getType()) && HerobrineAI.AllowedBlocks.contains(ploc.getWorld().getBlockAt(ploc.getBlockX(), ploc.getBlockY()+1, ploc.getBlockZ()+2).getType())){
newloc.setZ(newloc.getZ()+2);
}else{
if (HerobrineAI.AllowedBlocks.contains(ploc.getWorld().getBlockAt(ploc.getBlockX()-2, ploc.getBlockY(), ploc.getBlockZ()).getType()) && HerobrineAI.AllowedBlocks.contains(ploc.getWorld().getBlockAt(ploc.getBlockX()-2, ploc.getBlockY()+1, ploc.getBlockZ()).getType())){
newloc.setX(newloc.getX()-2);
}else if (HerobrineAI.AllowedBlocks.contains(ploc.getWorld().getBlockAt(ploc.getBlockX()+2, ploc.getBlockY(), ploc.getBlockZ()).getType()) && HerobrineAI.AllowedBlocks.contains(ploc.getWorld().getBlockAt(ploc.getBlockX()+2, ploc.getBlockY()+1, ploc.getBlockZ()).getType())){
newloc.setX(newloc.getX()+2);
}else if (HerobrineAI.AllowedBlocks.contains(ploc.getWorld().getBlockAt(ploc.getBlockX(), ploc.getBlockY(), ploc.getBlockZ()-2).getType()) && HerobrineAI.AllowedBlocks.contains(ploc.getWorld().getBlockAt(ploc.getBlockX(), ploc.getBlockY()+1, ploc.getBlockZ()-2).getType())){
newloc.setZ(newloc.getZ()-2);
}else if (HerobrineAI.AllowedBlocks.contains(ploc.getWorld().getBlockAt(ploc.getBlockX(), ploc.getBlockY(), ploc.getBlockZ()+2).getType()) && HerobrineAI.AllowedBlocks.contains(ploc.getWorld().getBlockAt(ploc.getBlockX(), ploc.getBlockY()+1, ploc.getBlockZ()+2).getType())){
newloc.setZ(newloc.getZ()+2);
}else{
}
}
}else if(chance==1){
if (HerobrineAI.AllowedBlocks.contains(ploc.getWorld().getBlockAt(ploc.getBlockX()+2, ploc.getBlockY(), ploc.getBlockZ()).getType()) && HerobrineAI.AllowedBlocks.contains(ploc.getWorld().getBlockAt(ploc.getBlockX()+2, ploc.getBlockY()+1, ploc.getBlockZ()).getType())){
newloc.setX(newloc.getX()+2);
}else if (HerobrineAI.AllowedBlocks.contains(ploc.getWorld().getBlockAt(ploc.getBlockX()-2, ploc.getBlockY(), ploc.getBlockZ()).getType()) && HerobrineAI.AllowedBlocks.contains(ploc.getWorld().getBlockAt(ploc.getBlockX()-2, ploc.getBlockY()+1, ploc.getBlockZ()).getType())){
newloc.setX(newloc.getX()-2);
}else if (HerobrineAI.AllowedBlocks.contains(ploc.getWorld().getBlockAt(ploc.getBlockX(), ploc.getBlockY(), ploc.getBlockZ()-2).getType()) && HerobrineAI.AllowedBlocks.contains(ploc.getWorld().getBlockAt(ploc.getBlockX(), ploc.getBlockY()+1, ploc.getBlockZ()-2).getType())){
newloc.setZ(newloc.getZ()-2);
}else if (HerobrineAI.AllowedBlocks.contains(ploc.getWorld().getBlockAt(ploc.getBlockX(), ploc.getBlockY(), ploc.getBlockZ()+2).getType()) && HerobrineAI.AllowedBlocks.contains(ploc.getWorld().getBlockAt(ploc.getBlockX(), ploc.getBlockY()+1, ploc.getBlockZ()+2).getType())){
newloc.setZ(newloc.getZ()+2);
}else{
if (HerobrineAI.AllowedBlocks.contains(ploc.getWorld().getBlockAt(ploc.getBlockX()+2, ploc.getBlockY(), ploc.getBlockZ()).getType()) && HerobrineAI.AllowedBlocks.contains(ploc.getWorld().getBlockAt(ploc.getBlockX()+2, ploc.getBlockY()+1, ploc.getBlockZ()).getType())){
newloc.setX(newloc.getX()+2);
}else if (HerobrineAI.AllowedBlocks.contains(ploc.getWorld().getBlockAt(ploc.getBlockX()-2, ploc.getBlockY(), ploc.getBlockZ()).getType()) && HerobrineAI.AllowedBlocks.contains(ploc.getWorld().getBlockAt(ploc.getBlockX()-2, ploc.getBlockY()+1, ploc.getBlockZ()).getType())){
newloc.setX(newloc.getX()-2);
}else if (HerobrineAI.AllowedBlocks.contains(ploc.getWorld().getBlockAt(ploc.getBlockX(), ploc.getBlockY(), ploc.getBlockZ()-2).getType()) && HerobrineAI.AllowedBlocks.contains(ploc.getWorld().getBlockAt(ploc.getBlockX(), ploc.getBlockY()+1, ploc.getBlockZ()-2).getType())){
newloc.setZ(newloc.getZ()-2);
}else if (HerobrineAI.AllowedBlocks.contains(ploc.getWorld().getBlockAt(ploc.getBlockX(), ploc.getBlockY(), ploc.getBlockZ()+2).getType()) && HerobrineAI.AllowedBlocks.contains(ploc.getWorld().getBlockAt(ploc.getBlockX(), ploc.getBlockY()+1, ploc.getBlockZ()+2).getType())){
newloc.setZ(newloc.getZ()+2);
}else{
}
}
}else if(chance==2){
if (HerobrineAI.AllowedBlocks.contains(ploc.getWorld().getBlockAt(ploc.getBlockX(), ploc.getBlockY(), ploc.getBlockZ()-2).getType()) && HerobrineAI.AllowedBlocks.contains(ploc.getWorld().getBlockAt(ploc.getBlockX(), ploc.getBlockY()+1, ploc.getBlockZ()-2).getType())){
newloc.setZ(newloc.getZ()-2);
}
else if (HerobrineAI.AllowedBlocks.contains(ploc.getWorld().getBlockAt(ploc.getBlockX()+2, ploc.getBlockY(), ploc.getBlockZ()).getType()) && HerobrineAI.AllowedBlocks.contains(ploc.getWorld().getBlockAt(ploc.getBlockX()+2, ploc.getBlockY()+1, ploc.getBlockZ()).getType())){
newloc.setX(newloc.getX()+2);
}else if (HerobrineAI.AllowedBlocks.contains(ploc.getWorld().getBlockAt(ploc.getBlockX()-2, ploc.getBlockY(), ploc.getBlockZ()).getType()) && HerobrineAI.AllowedBlocks.contains(ploc.getWorld().getBlockAt(ploc.getBlockX()-2, ploc.getBlockY()+1, ploc.getBlockZ()).getType())){
newloc.setX(newloc.getX()-2);
}else if (HerobrineAI.AllowedBlocks.contains(ploc.getWorld().getBlockAt(ploc.getBlockX(), ploc.getBlockY(), ploc.getBlockZ()+2).getType()) && HerobrineAI.AllowedBlocks.contains(ploc.getWorld().getBlockAt(ploc.getBlockX(), ploc.getBlockY()+1, ploc.getBlockZ()+2).getType())){
newloc.setZ(newloc.getZ()+2);
}else{
if (HerobrineAI.AllowedBlocks.contains(ploc.getWorld().getBlockAt(ploc.getBlockX(), ploc.getBlockY(), ploc.getBlockZ()-2).getType()) && HerobrineAI.AllowedBlocks.contains(ploc.getWorld().getBlockAt(ploc.getBlockX(), ploc.getBlockY()+1, ploc.getBlockZ()-2).getType())){
newloc.setZ(newloc.getZ()-2);
}
else if (HerobrineAI.AllowedBlocks.contains(ploc.getWorld().getBlockAt(ploc.getBlockX()+2, ploc.getBlockY(), ploc.getBlockZ()).getType()) && HerobrineAI.AllowedBlocks.contains(ploc.getWorld().getBlockAt(ploc.getBlockX()+2, ploc.getBlockY()+1, ploc.getBlockZ()).getType())){
newloc.setX(newloc.getX()+2);
}else if (HerobrineAI.AllowedBlocks.contains(ploc.getWorld().getBlockAt(ploc.getBlockX()-2, ploc.getBlockY(), ploc.getBlockZ()).getType()) && HerobrineAI.AllowedBlocks.contains(ploc.getWorld().getBlockAt(ploc.getBlockX()-2, ploc.getBlockY()+1, ploc.getBlockZ()).getType())){
newloc.setX(newloc.getX()-2);
}else if (HerobrineAI.AllowedBlocks.contains(ploc.getWorld().getBlockAt(ploc.getBlockX(), ploc.getBlockY(), ploc.getBlockZ()+2).getType()) && HerobrineAI.AllowedBlocks.contains(ploc.getWorld().getBlockAt(ploc.getBlockX(), ploc.getBlockY()+1, ploc.getBlockZ()+2).getType())){
newloc.setZ(newloc.getZ()+2);
}else{
}
}
} if (chance==3){
if (HerobrineAI.AllowedBlocks.contains(ploc.getWorld().getBlockAt(ploc.getBlockX(), ploc.getBlockY(), ploc.getBlockZ()+2).getType()) && HerobrineAI.AllowedBlocks.contains(ploc.getWorld().getBlockAt(ploc.getBlockX(), ploc.getBlockY()+1, ploc.getBlockZ()+2).getType())){
newloc.setZ(newloc.getZ()+2);
}
else if (HerobrineAI.AllowedBlocks.contains(ploc.getWorld().getBlockAt(ploc.getBlockX()-2, ploc.getBlockY(), ploc.getBlockZ()).getType()) && HerobrineAI.AllowedBlocks.contains(ploc.getWorld().getBlockAt(ploc.getBlockX()-2, ploc.getBlockY()+1, ploc.getBlockZ()).getType())){
newloc.setX(newloc.getX()-2);
}else if (HerobrineAI.AllowedBlocks.contains(ploc.getWorld().getBlockAt(ploc.getBlockX()+2, ploc.getBlockY(), ploc.getBlockZ()).getType()) && HerobrineAI.AllowedBlocks.contains(ploc.getWorld().getBlockAt(ploc.getBlockX()+2, ploc.getBlockY()+1, ploc.getBlockZ()).getType())){
newloc.setX(newloc.getX()+2);
}else if (HerobrineAI.AllowedBlocks.contains(ploc.getWorld().getBlockAt(ploc.getBlockX(), ploc.getBlockY(), ploc.getBlockZ()-2).getType()) && HerobrineAI.AllowedBlocks.contains(ploc.getWorld().getBlockAt(ploc.getBlockX(), ploc.getBlockY()+1, ploc.getBlockZ()-2).getType())){
newloc.setZ(newloc.getZ()-2);
}else if (HerobrineAI.AllowedBlocks.contains(ploc.getWorld().getBlockAt(ploc.getBlockX(), ploc.getBlockY(), ploc.getBlockZ()+2).getType()) && HerobrineAI.AllowedBlocks.contains(ploc.getWorld().getBlockAt(ploc.getBlockX(), ploc.getBlockY()+1, ploc.getBlockZ()+2).getType())){
newloc.setZ(newloc.getZ()+2);
}else{
if (HerobrineAI.AllowedBlocks.contains(ploc.getWorld().getBlockAt(ploc.getBlockX(), ploc.getBlockY(), ploc.getBlockZ()+2).getType()) && HerobrineAI.AllowedBlocks.contains(ploc.getWorld().getBlockAt(ploc.getBlockX(), ploc.getBlockY()+1, ploc.getBlockZ()+2).getType())){
newloc.setZ(newloc.getZ()+2);
}
else if (HerobrineAI.AllowedBlocks.contains(ploc.getWorld().getBlockAt(ploc.getBlockX()-2, ploc.getBlockY(), ploc.getBlockZ()).getType()) && HerobrineAI.AllowedBlocks.contains(ploc.getWorld().getBlockAt(ploc.getBlockX()-2, ploc.getBlockY()+1, ploc.getBlockZ()).getType())){
newloc.setX(newloc.getX()-2);
}else if (HerobrineAI.AllowedBlocks.contains(ploc.getWorld().getBlockAt(ploc.getBlockX()+2, ploc.getBlockY(), ploc.getBlockZ()).getType()) && HerobrineAI.AllowedBlocks.contains(ploc.getWorld().getBlockAt(ploc.getBlockX()+2, ploc.getBlockY()+1, ploc.getBlockZ()).getType())){
newloc.setX(newloc.getX()+2);
}else if (HerobrineAI.AllowedBlocks.contains(ploc.getWorld().getBlockAt(ploc.getBlockX(), ploc.getBlockY(), ploc.getBlockZ()-2).getType()) && HerobrineAI.AllowedBlocks.contains(ploc.getWorld().getBlockAt(ploc.getBlockX(), ploc.getBlockY()+1, ploc.getBlockZ()-2).getType())){
newloc.setZ(newloc.getZ()-2);
}else{
}
}
}
return newloc;
}
}

View File

@ -0,0 +1,497 @@
package org.jakub1221.herobrineai;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Logger;
import org.bukkit.Bukkit;
import org.bukkit.configuration.InvalidConfigurationException;
import org.bukkit.configuration.file.YamlConfiguration;
import org.jakub1221.herobrineai.misc.CustomID;
public class ConfigDB {
private Logger log;
public YamlConfiguration config;
public int ShowRate=2;
public boolean HitPlayer=true;
public boolean SendMessages=true;
public boolean Lighting=true;
public boolean DestroyTorches=true;
public int DestroyTorchesRadius=5;
public int ShowInterval=30000;
public boolean TotemExplodes=true;
public boolean OnlyWalkingMode=false;
public boolean BuildStuff=true;
public boolean PlaceSigns=true;
public boolean UseTotem=true;
public boolean WriteBooks=true;
public boolean Killable=false;
public boolean UsePotionEffects=true;
public int CaveChance=40;
public int BookChance=5;
public int SignChance=5;
public String DeathMessage="You cannot kill me!";
public List<String> useWorlds = new ArrayList<String>();;
public List<String> useMessages = new ArrayList<String>();;
public List<String> useSignMessages = new ArrayList<String>();;
public List<String> useBookMessages = new ArrayList<String>();;
public boolean BuildPyramids = true;
public boolean UseGraveyardWorld = true;
public boolean BuryPlayers = true;
public boolean SpawnWolves = true;
public boolean SpawnBats = true;
public boolean UseWalkingMode = true;
public int WalkingModeXRadius=1000;
public int WalkingModeZRadius=1000;
public int WalkingModeFromXRadius=0;
public int WalkingModeFromZRadius=0;
public boolean BuildTemples = true;
public boolean UseArtifactBow = true;
public boolean UseArtifactSword = true;
public boolean UseArtifactApple = true;
public boolean AttackCreative = true;
public boolean AttackOP = true;
public boolean SecuredArea_Build = true;
public boolean SecuredArea_Attack = true;
public boolean SecuredArea_Haunt = true;
public boolean SecuredArea_Signs = true;
public boolean SecuredArea_Books = true;
public int HerobrineHP = 150;
public int BuildInterval = 45000;
public boolean UseHeads = true;
public boolean UseCustomItems = false;
public boolean UseAncientSword = true;
public boolean UseNPC_Guardian=true;
public boolean UseNPC_Warrior=true;
public CustomID ItemInHand=null;
public ArrayList<String> UseCustomItemsList = new ArrayList<String>();
public ConfigDB(Logger l){
this.log=l;
}
public File configF = new File("plugins/HerobrineAI/config.yml");
public void Startup(){
new File("plugins/HerobrineAI").mkdirs();
if (!configF.exists())
try {
configF.createNewFile();
} catch (IOException e) {
e.printStackTrace();
}
config = new YamlConfiguration();
try {
config.load(configF);
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} catch (InvalidConfigurationException e) {
e.printStackTrace();
}
if (!config.contains("config.ShowRate")){
useWorlds.add("world");
useMessages.add("Even Notch can´t save you now!");
useMessages.add("Fear me!");
useMessages.add("Welcome to my world!");
useMessages.add("I am your death!");
useMessages.add("Grave awaits you!");
useSignMessages.add("I´m watching.");
useSignMessages.add("Death...");
useSignMessages.add("Eyes in dark...");
useBookMessages.add("White eyes in dark...");
useBookMessages.add("... was last what I saw ...");
useBookMessages.add("... before i was dead.");
UseCustomItemsList.add("ItemExample");
log.info("[HerobrineAI] Creating new Config ...");
config.set("config.ShowInterval", 30000);
config.set("config.ShowRate", 2);
config.set("config.HitPlayer", true);
config.set("config.SendMessages", true);
config.set("config.Lighting", false);
config.set("config.DestroyTorches", true);
config.set("config.DestroyTorchesRadius", 5);
config.set("config.Worlds", useWorlds);
config.set("config.TotemExplodes", true);
config.set("config.OnlyWalkingMode", false);
config.set("config.BuildStuff", true);
config.set("config.PlaceSigns", true);
config.set("config.UseTotem", true);
config.set("config.WriteBooks", true);
config.set("config.Killable", false);
config.set("config.UsePotionEffects", true);
config.set("config.CaveChance", 40);
config.set("config.BookChance", 5);
config.set("config.SignChance", 5);
config.set("config.DeathMessage", "You cannot kill me!");
config.set("config.Messages", useMessages);
config.set("config.SignMessages", useSignMessages);
config.set("config.BookMessages", useBookMessages);
config.set("config.Drops.264.count", 1);
config.set("config.Drops.264.chance", 20);
config.set("config.BuildPyramids", true);
config.set("config.UseGraveyardWorld", true);
config.set("config.BuryPlayers", true);
config.set("config.SpawnWolves", true);
config.set("config.SpawnBats", true);
config.set("config.UseWalkingMode", true);
config.set("config.WalkingModeRadius.X", 1000);
config.set("config.WalkingModeRadius.Z", 1000);
config.set("config.WalkingModeRadius.FromX", 0);
config.set("config.WalkingModeRadius.FromZ", 0);
config.set("config.BuildInterval", 45000);
config.set("config.BuildTemples", true);
config.set("config.UseArtifacts.Bow", true);
config.set("config.UseArtifacts.Sword", true);
config.set("config.UseArtifacts.Apple", true);
config.set("config.HerobrineHP", 200);
config.set("config.AttackCreative", true);
config.set("config.AttackOP", true);
config.set("config.SecuredArea.Build", true);
config.set("config.SecuredArea.Attack", true);
config.set("config.SecuredArea.Haunt", true);
config.set("config.SecuredArea.Signs", true);
config.set("config.SecuredArea.Books", true);
config.set("config.UseHeads", true);
config.set("config.UseCustomItems", false);
config.set("config.CustomItemsList", UseCustomItemsList);
config.set("config.UseAncientSword", true);
config.set("config.UseNPC.Guardian", true);
config.set("config.UseNPC.Warrior", true);
config.set("config.ItemInHand", "0");
try {
config.save(configF);
} catch (IOException e) {
e.printStackTrace();
}
}else{
/* Config Auto-Updater */
boolean hasUpdated=false;
if (!config.contains("config.Worlds")){
hasUpdated=true;
log.info("[HerobrineAI] Updating old config...");
config.set("config.Worlds", useWorlds);
}
if (!config.contains("config.TotemExplodes")){
if (hasUpdated==false){
log.info("[HerobrineAI] Updating old config...");
}
hasUpdated=true;
config.set("config.TotemExplodes", true);
}
if (!config.contains("config.OnlyWalkingMode")){
if (hasUpdated==false){
hasUpdated=true;
log.info("[HerobrineAI] Updating old config...");
}
config.set("config.OnlyWalkingMode", false);
}
if (!config.contains("config.BuildStuff")){
if (hasUpdated==false){
log.info("[HerobrineAI] Updating old config...");
}
hasUpdated=true;
useMessages.add("Even Notch can´t save you now!");
useMessages.add("Fear me!");
useMessages.add("Welcome to my world!");
useMessages.add("I am your death!");
useMessages.add("Grave awaits you!");
useSignMessages.add("I´m watching.");
useSignMessages.add("Death...");
useSignMessages.add("Eyes in dark...");
useBookMessages.add("White eyes in dark...");
useBookMessages.add("... was last what I saw ...");
useBookMessages.add("... before i was dead.");
config.set("config.BuildStuff", true);
config.set("config.PlaceSigns", true);
config.set("config.UseTotem", true);
config.set("config.WriteBooks", true);
config.set("config.Killable", false);
config.set("config.Messages", useMessages);
config.set("config.SignMessages", useSignMessages);
config.set("config.BookMessages", useBookMessages);
config.set("config.Drops.264.count", 1);
config.set("config.Drops.264.chance", 20);
}
if (!config.contains("config.UsePotionEffects")){
if (hasUpdated==false){
log.info("[HerobrineAI] Updating old config...");
}
hasUpdated=true;
config.set("config.UsePotionEffects", true);
config.set("config.CaveChance", 40);
config.set("config.BookChance", 5);
config.set("config.SignChance", 5);
}
if (!config.contains("config.DeathMessage")){
if (hasUpdated==false){
log.info("[HerobrineAI] Updating old config...");
}
hasUpdated=true;
config.set("config.DeathMessage", "You cannot kill me!");
}
if (!config.contains("config.BuildPyramids")){
if (hasUpdated==false){
log.info("[HerobrineAI] Updating old config...");
}
hasUpdated=true;
config.set("config.BuildPyramids", true);
}
if (!config.contains("config.UseGraveyardWorld")){
if (hasUpdated==false){
log.info("[HerobrineAI] Updating old config...");
}
hasUpdated=true;
config.set("config.UseGraveyardWorld", true);
config.set("config.BuryPlayers", true);
config.set("config.SpawnWolves", true);
config.set("config.SpawnBats", true);
if (config.contains("config.UsePoitonEffects")){
config.set("config.UsePoitonEffects", null);
}
}
if (!config.contains("config.DeathMessage")){
if (hasUpdated==false){
log.info("[HerobrineAI] Updating old config...");
}
hasUpdated=true;
config.set("config.DeathMessage", "You cannot kill me!");
}
if (!config.contains("config.UseWalkingMode")){
if (hasUpdated==false){
log.info("[HerobrineAI] Updating old config...");
}
hasUpdated=true;
config.set("config.UseWalkingMode", true);
config.set("config.WalkingModeRadius.X", 1000);
config.set("config.WalkingModeRadius.Z", 1000);
}
if (!config.contains("config.BuildTemples")){
if (hasUpdated==false){
log.info("[HerobrineAI] Updating old config...");
}
hasUpdated=true;
config.set("config.BuildInterval", 45000);
config.set("config.BuildTemples", true);
config.set("config.UseArtifacts.Bow", true);
config.set("config.UseArtifacts.Sword", true);
config.set("config.UseArtifacts.Apple", true);
config.set("config.HerobrineHP", 200);
config.set("config.AttackCreative", true);
config.set("config.AttackOP", true);
config.set("config.SecuredArea.Build", true);
config.set("config.SecuredArea.Attack", true);
config.set("config.SecuredArea.Haunt", true);
config.set("config.SecuredArea.Signs", true);
config.set("config.SecuredArea.Books", true);
}
if (!config.contains("config.UseHeads")){
if (hasUpdated==false){
log.info("[HerobrineAI] Updating old config...");
}
hasUpdated=true;
config.set("config.UseHeads", true);
}
if (!config.contains("config.UseCustomItems")){
if (hasUpdated==false){
log.info("[HerobrineAI] Updating old config...");
}
hasUpdated=true;
UseCustomItemsList.add("ItemExample");
config.set("config.UseCustomItems", false);
config.set("config.CustomItemsList", UseCustomItemsList);
}
if (!config.contains("config.UseAncientSword")){
if (hasUpdated==false){
log.info("[HerobrineAI] Updating old config...");
}
hasUpdated=true;
config.set("config.UseAncientSword", true);
config.set("config.UseNPC.Guardian", true);
config.set("config.UseNPC.Warrior", true);
config.set("config.ItemInHand", "0");
config.set("config.WalkingModeRadius.FromX", 0);
config.set("config.WalkingModeRadius.FromZ", 0);
}
if (hasUpdated==true){
try {
config.save(configF);
} catch (IOException e) {
e.printStackTrace();
}
log.info("[HerobrineAI] Config was updated to v"+HerobrineAI.getPluginCore().getVersionStr()+"!");
}
/* Config Auto-Updater End */
Reload();
}
}
public void Reload(){
try {
config.load(configF);
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} catch (InvalidConfigurationException e) {
e.printStackTrace();
}
ShowInterval=config.getInt("config.ShowInterval");
ShowRate=config.getInt("config.ShowRate");
HitPlayer=config.getBoolean("config.HitPlayer");
SendMessages=config.getBoolean("config.SendMessages");
Lighting=config.getBoolean("config.Lighting");
DestroyTorches=config.getBoolean("config.DestroyTorches");
DestroyTorchesRadius=config.getInt("config.DestroyTorchesRadius");
useWorlds=config.getStringList("config.Worlds");
TotemExplodes=config.getBoolean("config.TotemExplodes");
OnlyWalkingMode=config.getBoolean("config.OnlyWalkingMode");
BuildStuff=config.getBoolean("config.BuildStuff");
PlaceSigns=config.getBoolean("config.PlaceSigns");
UseTotem=config.getBoolean("config.UseTotem");
WriteBooks=config.getBoolean("config.WriteBooks");
Killable=config.getBoolean("config.Killable");
UsePotionEffects=config.getBoolean("config.UsePotionEffects");
CaveChance=config.getInt("config.CaveChance");
BookChance=config.getInt("config.BookChance");
SignChance=config.getInt("config.SignChance");
DeathMessage=config.getString("config.DeathMessage");
useMessages=config.getStringList("config.Messages");
useSignMessages=config.getStringList("config.SignMessages");
useBookMessages=config.getStringList("config.BookMessages");
BuildPyramids=config.getBoolean("config.BuildPyramids");
UseGraveyardWorld=config.getBoolean("config.UseGraveyardWorld");
BuryPlayers=config.getBoolean("config.BuryPlayers");
SpawnWolves=config.getBoolean("config.SpawnWolves");
SpawnBats=config.getBoolean("config.SpawnBats");
UseWalkingMode=config.getBoolean("config.UseWalkingMode");
WalkingModeXRadius=config.getInt("config.WalkingModeRadius.X");
WalkingModeZRadius=config.getInt("config.WalkingModeRadius.Z");
WalkingModeFromXRadius=config.getInt("config.WalkingModeRadius.FromX");
WalkingModeFromZRadius=config.getInt("config.WalkingModeRadius.FromZ");
BuildInterval=config.getInt("config.BuildInterval");
BuildTemples=config.getBoolean("config.BuildTemples");
UseArtifactBow=config.getBoolean("config.UseArtifacts.Bow");
UseArtifactSword=config.getBoolean("config.UseArtifacts.Sword");
UseArtifactApple=config.getBoolean("config.UseArtifacts.Apple");
HerobrineHP=config.getInt("config.HerobrineHP");
AttackCreative=config.getBoolean("config.AttackCreative");
AttackOP=config.getBoolean("config.AttackOP");
SecuredArea_Build=config.getBoolean("config.SecuredArea.Build");
SecuredArea_Attack=config.getBoolean("config.SecuredArea.Attack");
SecuredArea_Haunt=config.getBoolean("config.SecuredArea.Haunt");
SecuredArea_Signs=config.getBoolean("config.SecuredArea.Signs");
SecuredArea_Books=config.getBoolean("config.SecuredArea.Books");
UseHeads=config.getBoolean("config.UseHeads");
UseCustomItems=config.getBoolean("config.UseCustomItems");
UseCustomItemsList=(ArrayList<String>) config.getStringList("config.CustomItemsList");
UseAncientSword=config.getBoolean("config.UseAncientSword");
UseNPC_Guardian=config.getBoolean("config.UseNPC.Guardian");
UseNPC_Warrior=config.getBoolean("config.UseNPC.Warrior");
ItemInHand=new CustomID(config.getString("config.ItemInHand"));
HerobrineAI.HerobrineMaxHP=HerobrineHP;
HerobrineAI.getPluginCore().getAICore().Stop_MAIN();
HerobrineAI.getPluginCore().getAICore().Start_MAIN();
HerobrineAI.getPluginCore().getAICore().Stop_BD();
HerobrineAI.getPluginCore().getAICore().Start_BD();
HerobrineAI.AvailableWorld=false;
if (HerobrineAI.HerobrineNPC!=null){
HerobrineAI.HerobrineNPC.setItemInHand(ItemInHand.getItemStack());
}
for (int i = 0;i<=useWorlds.size()-1;i++){
if (Bukkit.getServer().getWorlds().contains(Bukkit.getServer().getWorld(useWorlds.get(i)))){HerobrineAI.AvailableWorld=true;}
}
}
}

View File

@ -0,0 +1,337 @@
package org.jakub1221.herobrineai;
import java.io.IOException;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.logging.Logger;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.WorldCreator;
import org.bukkit.command.CommandExecutor;
import org.bukkit.entity.Player;
import org.bukkit.event.Listener;
import org.bukkit.plugin.java.JavaPlugin;
import org.jakub1221.herobrineai.NPC.AI.PathManager;
import org.jakub1221.herobrineai.NPC.Entity.HumanNPC;
import org.jakub1221.herobrineai.NPC.NPCCore;
import org.jakub1221.herobrineai.AI.AICore;
import org.jakub1221.herobrineai.AI.extensions.GraveyardWorld;
import org.jakub1221.herobrineai.commands.CmdExecutor;
import org.jakub1221.herobrineai.entity.CustomZombie;
import org.jakub1221.herobrineai.entity.EntityManager;
import org.jakub1221.herobrineai.listeners.BlockListener;
import org.jakub1221.herobrineai.listeners.EntityListener;
import org.jakub1221.herobrineai.listeners.InventoryListener;
import org.jakub1221.herobrineai.listeners.PlayerListener;
import org.jakub1221.herobrineai.listeners.WorldListener;
public class HerobrineAI extends JavaPlugin implements Listener{
private static HerobrineAI pluginCore;
private AICore aicore;
private ConfigDB configdb;
private Support support;
private EntityManager entMng;
private PathManager pathMng;
public int version=3122;
public String versionStr="3.0.0";
public java.io.InputStream data_temple=HerobrineAI.class.getResourceAsStream("/res/temple.yml");
public java.io.InputStream data_graveyard_world=HerobrineAI.class.getResourceAsStream("/res/graveyard_world.yml");
public static int HerobrineHP=200;
public static int HerobrineMaxHP=200;
public static boolean isDebugging=false;
public static NPCCore NPCman;
public static HumanNPC HerobrineNPC;
public static long HerobrineEntityID;
public static boolean AvailableWorld = false;
public static List<Material> AllowedBlocks = new ArrayList<Material>();
public static List<Material> StandBlocks = new ArrayList<Material>();
public static List<Material> NonStandBlocks = new ArrayList<Material>();
public Map<Player,Long> PlayerApple = new HashMap<Player,Long>();
public static Logger log = Logger.getLogger("Minecraft");
public void onEnable(){
NPCman = new NPCCore(this);
HerobrineAI.pluginCore = this;
this.configdb = new ConfigDB(log);
getServer().getPluginManager().registerEvents(new EntityListener(), this);
getServer().getPluginManager().registerEvents(new BlockListener(), this);
getServer().getPluginManager().registerEvents(new InventoryListener(), this);
getServer().getPluginManager().registerEvents(new PlayerListener(), this);
getServer().getPluginManager().registerEvents(new WorldListener(), this);
// Metrics
try {
Metrics metrics = new Metrics(this);
metrics.start();
} catch (IOException e) {
}
// Initialize PathManager
this.pathMng = new PathManager();
// Initialize AICore
this.aicore = new AICore();
// Initialize EntityManager
this.entMng = new EntityManager();
// Config loading
configdb.Startup();
configdb.Reload();
// Spawn Herobrine
Location nowloc = new Location((World) Bukkit.getServer().getWorlds().get(0),(float) 0,(float) -20,(float) 0);
nowloc.setYaw((float) 1);
nowloc.setPitch((float) 1);
HerobrineSpawn(nowloc);
HerobrineNPC.setItemInHand(configdb.ItemInHand.getItemStack());
//Graveyard World
if (this.configdb.UseGraveyardWorld==true){
if (Bukkit.getServer().getWorld("world_herobrineai_graveyard")==null){
log.info("[HerobrineAI] Creating Graveyard world...");
WorldCreator wc = new WorldCreator("world_herobrineai_graveyard");
wc.generateStructures(false);
org.bukkit.WorldType type = org.bukkit.WorldType.FLAT;
wc.type(type);
wc.createWorld();
GraveyardWorld.Create();
}
}
log.info("[HerobrineAI] Plugin loaded! Version: "+versionStr+" / Build: "+version);
// Init Block Types
StandBlocks.add(Material.STONE);
StandBlocks.add(Material.getMaterial(2));
StandBlocks.add(Material.GRAVEL);
StandBlocks.add(Material.SAND);
StandBlocks.add(Material.DIRT);
StandBlocks.add(Material.SANDSTONE);
StandBlocks.add(Material.GLASS);
StandBlocks.add(Material.CLAY);
StandBlocks.add(Material.COBBLESTONE);
StandBlocks.add(Material.ICE);
StandBlocks.add(Material.getMaterial(33));
StandBlocks.add(Material.getMaterial(29));
StandBlocks.add(Material.getMaterial(35));
StandBlocks.add(Material.getMaterial(57));
StandBlocks.add(Material.getMaterial(41));
StandBlocks.add(Material.getMaterial(42));
NonStandBlocks.add(Material.AIR);
NonStandBlocks.add(Material.GRASS);
NonStandBlocks.add(Material.SNOW);
AllowedBlocks.add(Material.AIR);
AllowedBlocks.add(Material.SNOW);
AllowedBlocks.add(Material.getMaterial(31));
AllowedBlocks.add(Material.RAILS);
AllowedBlocks.add(Material.getMaterial(32));
AllowedBlocks.add(Material.getMaterial(37));
AllowedBlocks.add(Material.getMaterial(38));
AllowedBlocks.add(Material.getMaterial(70));
AllowedBlocks.add(Material.getMaterial(72));
AllowedBlocks.add(Material.getMaterial(106));
AllowedBlocks.add(Material.TORCH);
AllowedBlocks.add(Material.REDSTONE);
AllowedBlocks.add(Material.REDSTONE_TORCH_ON);
AllowedBlocks.add(Material.REDSTONE_TORCH_OFF);
AllowedBlocks.add(Material.LEVER);
AllowedBlocks.add(Material.getMaterial(77));
AllowedBlocks.add(Material.LADDER);
for (int i = 0;i<=configdb.useWorlds.size()-1;i++){
if (Bukkit.getServer().getWorlds().contains(Bukkit.getServer().getWorld(configdb.useWorlds.get(i)))){AvailableWorld=true;}
}
if (AvailableWorld==false){
log.info("**********************************************************");
log.info("[HerobrineAI] There are no available worlds for Herobrine!");
log.info("**********************************************************");
}
Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(AICore.plugin, new Runnable() {
public void run() {
}
}, 1 * 35L, 1 * 35L);
Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(this, new Runnable() {
public void run() {
pathMng.update();
}
}, 1 * 5L, 1 * 5L);
//Command Executors
this.getCommand("hb").setExecutor((CommandExecutor) new CmdExecutor(this));
this.getCommand("hb-ai").setExecutor((CommandExecutor) new CmdExecutor(this));
//Support initialize
this.support = new Support();
//Register mobs
try{
@SuppressWarnings("rawtypes")
Class[] args = new Class[3];
args[0] = Class.class;
args[1] = String.class;
args[2] = int.class;
Method a = net.minecraft.server.v1_5_R2.EntityTypes.class.getDeclaredMethod("a", args);
a.setAccessible(true);
a.invoke(a, CustomZombie.class, "Zombie", 54);
}catch (Exception e){
e.printStackTrace();
this.setEnabled(false);
}
}
public void onDisable(){
this.entMng.killAllMobs();
NPCman.DisableTask();
log.info("[HerobrineAI] Plugin disabled!");
}
public AICore getAICore(){
return this.aicore;
}
public EntityManager getEntityManager(){
return this.entMng;
}
public static HerobrineAI getPluginCore(){
return HerobrineAI.pluginCore;
}
public void HerobrineSpawn(Location loc){
HerobrineNPC = (HumanNPC) NPCman.spawnHumanNPC(ChatColor.WHITE+"Herobrine", loc);
HerobrineEntityID=HerobrineNPC.getBukkitEntity().getEntityId();
}
public void HerobrineRemove(){
HerobrineEntityID=0;
HerobrineNPC=null;
NPCman.removeAll();
}
public ConfigDB getConfigDB(){
return this.configdb;
}
public String getVersionStr(){
return versionStr;
}
public Support getSupport(){
return this.support;
}
public PathManager getPathManager(){
return this.pathMng;
}
public boolean canAttackPlayer(Player player,Player sender){
if (player.isOp()){
if (configdb.AttackOP){
if (player.getGameMode()==GameMode.CREATIVE){
if (configdb.AttackCreative){
return true;
}else{sender.sendMessage(ChatColor.RED+"[HerobrineAI] Player is in Creative mode.");return false;}
}
return true;
}else{sender.sendMessage(ChatColor.RED+"[HerobrineAI] Player is OP.");return false;}
}else if (player.getGameMode()==GameMode.CREATIVE){
if (configdb.AttackCreative){
return true;
}else{sender.sendMessage(ChatColor.RED+"[HerobrineAI] Player is in Creative mode.");return false;}
}else{return true;}
}
public boolean canAttackPlayerConsole(Player player){
if (player.isOp()){
if (configdb.AttackOP){
if (player.getGameMode()==GameMode.CREATIVE){
if (configdb.AttackCreative){
return true;
}else{log.info("[HerobrineAI] Player is in Creative mode.");return false;}
}
return true;
}else{log.info("[HerobrineAI] Player is OP.");return false;}
}else if (player.getGameMode()==GameMode.CREATIVE){
if (configdb.AttackCreative){
return true;
}else{log.info("[HerobrineAI] Player is in Creative mode.");return false;}
}else{return true;}
}
public boolean canAttackPlayerNoMSG(Player player){
if (player.isOp()){
if (configdb.AttackOP){
if (player.getGameMode()==GameMode.CREATIVE){
if (configdb.AttackCreative){
return true;
}else{return false;}
}
return true;
}else{return false;}
}else if (player.getGameMode()==GameMode.CREATIVE){
if (configdb.AttackCreative){
return true;
}else{return false;}
}else{return true;}
}
public String getAvailableWorldString(){
if (AvailableWorld){
return "Yes";
}else{
return "No";
}
}
}

View File

@ -0,0 +1,632 @@
/*
* Copyright 2011 Tyler Blair. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ''AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those of the
* authors and contributors and should not be interpreted as representing official policies,
* either expressed or implied, of anybody else.
*/
package org.jakub1221.herobrineai;
import org.bukkit.Bukkit;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.configuration.InvalidConfigurationException;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginDescriptionFile;
import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.UnsupportedEncodingException;
import java.net.Proxy;
import java.net.URL;
import java.net.URLConnection;
import java.net.URLEncoder;
import java.util.Collections;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.Set;
import java.util.UUID;
import java.util.logging.Level;
/**
* <p>
* The metrics class obtains data about a plugin and submits statistics about it to the metrics backend.
* </p>
* <p>
* Public methods provided by this class:
* </p>
* <code>
* Graph createGraph(String name); <br/>
* void addCustomData(Metrics.Plotter plotter); <br/>
* void start(); <br/>
* </code>
*/
public class Metrics {
/**
* The current revision number
*/
private final static int REVISION = 5;
/**
* The base url of the metrics domain
*/
private static final String BASE_URL = "http://mcstats.org";
/**
* The url used to report a server's status
*/
private static final String REPORT_URL = "/report/%s";
/**
* The separator to use for custom data. This MUST NOT change unless you are hosting your own
* version of metrics and want to change it.
*/
private static final String CUSTOM_DATA_SEPARATOR = "~~";
/**
* Interval of time to ping (in minutes)
*/
private static final int PING_INTERVAL = 10;
/**
* The plugin this metrics submits for
*/
private final Plugin plugin;
/**
* All of the custom graphs to submit to metrics
*/
private final Set<Graph> graphs = Collections.synchronizedSet(new HashSet<Graph>());
/**
* The default graph, used for addCustomData when you don't want a specific graph
*/
private final Graph defaultGraph = new Graph("Default");
/**
* The plugin configuration file
*/
private final YamlConfiguration configuration;
/**
* The plugin configuration file
*/
private final File configurationFile;
/**
* Unique server id
*/
private final String guid;
/**
* Lock for synchronization
*/
private final Object optOutLock = new Object();
/**
* Id of the scheduled task
*/
private volatile int taskId = -1;
public Metrics(final Plugin plugin) throws IOException {
if (plugin == null) {
throw new IllegalArgumentException("Plugin cannot be null");
}
this.plugin = plugin;
// load the config
configurationFile = getConfigFile();
configuration = YamlConfiguration.loadConfiguration(configurationFile);
// add some defaults
configuration.addDefault("opt-out", false);
configuration.addDefault("guid", UUID.randomUUID().toString());
// Do we need to create the file?
if (configuration.get("guid", null) == null) {
configuration.options().header("http://mcstats.org").copyDefaults(true);
configuration.save(configurationFile);
}
// Load the guid then
guid = configuration.getString("guid");
}
/**
* Construct and create a Graph that can be used to separate specific plotters to their own graphs
* on the metrics website. Plotters can be added to the graph object returned.
*
* @param name The name of the graph
* @return Graph object created. Will never return NULL under normal circumstances unless bad parameters are given
*/
public Graph createGraph(final String name) {
if (name == null) {
throw new IllegalArgumentException("Graph name cannot be null");
}
// Construct the graph object
final Graph graph = new Graph(name);
// Now we can add our graph
graphs.add(graph);
// and return back
return graph;
}
/**
* Add a Graph object to Metrics that represents data for the plugin that should be sent to the backend
*
* @param graph The name of the graph
*/
public void addGraph(final Graph graph) {
if (graph == null) {
throw new IllegalArgumentException("Graph cannot be null");
}
graphs.add(graph);
}
/**
* Adds a custom data plotter to the default graph
*
* @param plotter The plotter to use to plot custom data
*/
public void addCustomData(final Plotter plotter) {
if (plotter == null) {
throw new IllegalArgumentException("Plotter cannot be null");
}
// Add the plotter to the graph o/
defaultGraph.addPlotter(plotter);
// Ensure the default graph is included in the submitted graphs
graphs.add(defaultGraph);
}
/**
* Start measuring statistics. This will immediately create an async repeating task as the plugin and send
* the initial data to the metrics backend, and then after that it will post in increments of
* PING_INTERVAL * 1200 ticks.
*
* @return True if statistics measuring is running, otherwise false.
*/
public boolean start() {
synchronized (optOutLock) {
// Did we opt out?
if (isOptOut()) {
return false;
}
// Is metrics already running?
if (taskId >= 0) {
return true;
}
// Begin hitting the server with glorious data
taskId = plugin.getServer().getScheduler().scheduleAsyncRepeatingTask(plugin, new Runnable() {
private boolean firstPost = true;
public void run() {
try {
// This has to be synchronized or it can collide with the disable method.
synchronized (optOutLock) {
// Disable Task, if it is running and the server owner decided to opt-out
if (isOptOut() && taskId > 0) {
plugin.getServer().getScheduler().cancelTask(taskId);
taskId = -1;
// Tell all plotters to stop gathering information.
for (Graph graph : graphs){
graph.onOptOut();
}
}
}
// We use the inverse of firstPost because if it is the first time we are posting,
// it is not a interval ping, so it evaluates to FALSE
// Each time thereafter it will evaluate to TRUE, i.e PING!
postPlugin(!firstPost);
// After the first post we set firstPost to false
// Each post thereafter will be a ping
firstPost = false;
} catch (IOException e) {
Bukkit.getLogger().log(Level.INFO, "[Metrics] " + e.getMessage());
}
}
}, 0, PING_INTERVAL * 1200);
return true;
}
}
/**
* Has the server owner denied plugin metrics?
*
* @return true if metrics should be opted out of it
*/
public boolean isOptOut() {
synchronized(optOutLock) {
try {
// Reload the metrics file
configuration.load(getConfigFile());
} catch (IOException ex) {
Bukkit.getLogger().log(Level.INFO, "[Metrics] " + ex.getMessage());
return true;
} catch (InvalidConfigurationException ex) {
Bukkit.getLogger().log(Level.INFO, "[Metrics] " + ex.getMessage());
return true;
}
return configuration.getBoolean("opt-out", false);
}
}
/**
* Enables metrics for the server by setting "opt-out" to false in the config file and starting the metrics task.
*
* @throws IOException
*/
public void enable() throws IOException {
// This has to be synchronized or it can collide with the check in the task.
synchronized (optOutLock) {
// Check if the server owner has already set opt-out, if not, set it.
if (isOptOut()) {
configuration.set("opt-out", false);
configuration.save(configurationFile);
}
// Enable Task, if it is not running
if (taskId < 0) {
start();
}
}
}
/**
* Disables metrics for the server by setting "opt-out" to true in the config file and canceling the metrics task.
*
* @throws IOException
*/
public void disable() throws IOException {
// This has to be synchronized or it can collide with the check in the task.
synchronized (optOutLock) {
// Check if the server owner has already set opt-out, if not, set it.
if (!isOptOut()) {
configuration.set("opt-out", true);
configuration.save(configurationFile);
}
// Disable Task, if it is running
if (taskId > 0) {
this.plugin.getServer().getScheduler().cancelTask(taskId);
taskId = -1;
}
}
}
/**
* Gets the File object of the config file that should be used to store data such as the GUID and opt-out status
*
* @return the File object for the config file
*/
public File getConfigFile() {
// I believe the easiest way to get the base folder (e.g craftbukkit set via -P) for plugins to use
// is to abuse the plugin object we already have
// plugin.getDataFolder() => base/plugins/PluginA/
// pluginsFolder => base/plugins/
// The base is not necessarily relative to the startup directory.
File pluginsFolder = plugin.getDataFolder().getParentFile();
// return => base/plugins/PluginMetrics/config.yml
return new File(new File(pluginsFolder, "PluginMetrics"), "config.yml");
}
/**
* Generic method that posts a plugin to the metrics website
*/
private void postPlugin(final boolean isPing) throws IOException {
// The plugin's description file containg all of the plugin data such as name, version, author, etc
final PluginDescriptionFile description = plugin.getDescription();
// Construct the post data
final StringBuilder data = new StringBuilder();
data.append(encode("guid")).append('=').append(encode(guid));
encodeDataPair(data, "version", description.getVersion());
encodeDataPair(data, "server", Bukkit.getVersion());
encodeDataPair(data, "players", Integer.toString(Bukkit.getServer().getOnlinePlayers().length));
encodeDataPair(data, "revision", String.valueOf(REVISION));
// If we're pinging, append it
if (isPing) {
encodeDataPair(data, "ping", "true");
}
// Acquire a lock on the graphs, which lets us make the assumption we also lock everything
// inside of the graph (e.g plotters)
synchronized (graphs) {
final Iterator<Graph> iter = graphs.iterator();
while (iter.hasNext()) {
final Graph graph = iter.next();
for (Plotter plotter : graph.getPlotters()) {
// The key name to send to the metrics server
// The format is C-GRAPHNAME-PLOTTERNAME where separator - is defined at the top
// Legacy (R4) submitters use the format Custom%s, or CustomPLOTTERNAME
final String key = String.format("C%s%s%s%s", CUSTOM_DATA_SEPARATOR, graph.getName(), CUSTOM_DATA_SEPARATOR, plotter.getColumnName());
// The value to send, which for the foreseeable future is just the string
// value of plotter.getValue()
final String value = Integer.toString(plotter.getValue());
// Add it to the http post data :)
encodeDataPair(data, key, value);
}
}
}
// Create the url
URL url = new URL(BASE_URL + String.format(REPORT_URL, encode(plugin.getDescription().getName())));
// Connect to the website
URLConnection connection;
// Mineshafter creates a socks proxy, so we can safely bypass it
// It does not reroute POST requests so we need to go around it
if (isMineshafterPresent()) {
connection = url.openConnection(Proxy.NO_PROXY);
} else {
connection = url.openConnection();
}
connection.setDoOutput(true);
// Write the data
final OutputStreamWriter writer = new OutputStreamWriter(connection.getOutputStream());
writer.write(data.toString());
writer.flush();
// Now read the response
final BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
final String response = reader.readLine();
// close resources
writer.close();
reader.close();
if (response == null || response.startsWith("ERR")) {
throw new IOException(response); //Throw the exception
} else {
// Is this the first update this hour?
if (response.contains("OK This is your first update this hour")) {
synchronized (graphs) {
final Iterator<Graph> iter = graphs.iterator();
while (iter.hasNext()) {
final Graph graph = iter.next();
for (Plotter plotter : graph.getPlotters()) {
plotter.reset();
}
}
}
}
}
}
/**
* Check if mineshafter is present. If it is, we need to bypass it to send POST requests
*
* @return true if mineshafter is installed on the server
*/
private boolean isMineshafterPresent() {
try {
Class.forName("mineshafter.MineServer");
return true;
} catch (Exception e) {
return false;
}
}
/**
* <p>Encode a key/value data pair to be used in a HTTP post request. This INCLUDES a & so the first
* key/value pair MUST be included manually, e.g:</p>
* <code>
* StringBuffer data = new StringBuffer();
* data.append(encode("guid")).append('=').append(encode(guid));
* encodeDataPair(data, "version", description.getVersion());
* </code>
*
* @param buffer the stringbuilder to append the data pair onto
* @param key the key value
* @param value the value
*/
private static void encodeDataPair(final StringBuilder buffer, final String key, final String value) throws UnsupportedEncodingException {
buffer.append('&').append(encode(key)).append('=').append(encode(value));
}
/**
* Encode text as UTF-8
*
* @param text the text to encode
* @return the encoded text, as UTF-8
*/
private static String encode(final String text) throws UnsupportedEncodingException {
return URLEncoder.encode(text, "UTF-8");
}
/**
* Represents a custom graph on the website
*/
public static class Graph {
/**
* The graph's name, alphanumeric and spaces only :)
* If it does not comply to the above when submitted, it is rejected
*/
private final String name;
/**
* The set of plotters that are contained within this graph
*/
private final Set<Plotter> plotters = new LinkedHashSet<Plotter>();
private Graph(final String name) {
this.name = name;
}
/**
* Gets the graph's name
*
* @return the Graph's name
*/
public String getName() {
return name;
}
/**
* Add a plotter to the graph, which will be used to plot entries
*
* @param plotter the plotter to add to the graph
*/
public void addPlotter(final Plotter plotter) {
plotters.add(plotter);
}
/**
* Remove a plotter from the graph
*
* @param plotter the plotter to remove from the graph
*/
public void removePlotter(final Plotter plotter) {
plotters.remove(plotter);
}
/**
* Gets an <b>unmodifiable</b> set of the plotter objects in the graph
*
* @return an unmodifiable {@link Set} of the plotter objects
*/
public Set<Plotter> getPlotters() {
return Collections.unmodifiableSet(plotters);
}
@Override
public int hashCode() {
return name.hashCode();
}
@Override
public boolean equals(final Object object) {
if (!(object instanceof Graph)) {
return false;
}
final Graph graph = (Graph) object;
return graph.name.equals(name);
}
/**
* Called when the server owner decides to opt-out of Metrics while the server is running.
*/
protected void onOptOut() {
}
}
/**
* Interface used to collect custom data for a plugin
*/
public static abstract class Plotter {
/**
* The plot's name
*/
private final String name;
/**
* Construct a plotter with the default plot name
*/
public Plotter() {
this("Default");
}
/**
* Construct a plotter with a specific plot name
*
* @param name the name of the plotter to use, which will show up on the website
*/
public Plotter(final String name) {
this.name = name;
}
/**
* Get the current value for the plotted point. Since this function defers to an external function
* it may or may not return immediately thus cannot be guaranteed to be thread friendly or safe.
* This function can be called from any thread so care should be taken when accessing resources
* that need to be synchronized.
*
* @return the current value for the point to be plotted.
*/
public abstract int getValue();
/**
* Get the column name for the plotted point
*
* @return the plotted point's column name
*/
public String getColumnName() {
return name;
}
/**
* Called after the website graphs have been updated
*/
public void reset() {
}
@Override
public int hashCode() {
return getColumnName().hashCode();
}
@Override
public boolean equals(final Object object) {
if (!(object instanceof Plotter)) {
return false;
}
final Plotter plotter = (Plotter) object;
return plotter.name.equals(name) && plotter.getValue() == getValue();
}
}
}

View File

@ -0,0 +1,114 @@
package org.jakub1221.herobrineai.NPC.AI;
import java.util.Random;
import org.bukkit.Location;
import org.bukkit.World;
import org.jakub1221.herobrineai.HerobrineAI;
public class Path {
private float x;
private float z;
private boolean xNegative;
private boolean zNegative;
private boolean canContinue=true;
private boolean isCompleted=false;
private int stepNow=0;
private int maxSteps=new Random().nextInt(3)+3;
public Path(float _x,float _z){
x=_x;
z=_z;
if ((x-HerobrineAI.HerobrineNPC.getBukkitEntity().getLocation().getX())<0){xNegative=true;}else{xNegative=false;}
if ((z-HerobrineAI.HerobrineNPC.getBukkitEntity().getLocation().getZ())<0){zNegative=true;}else{zNegative=false;}
}
public void update(){
if (stepNow<=maxSteps){
if (!isCompleted){
if ((x-HerobrineAI.HerobrineNPC.getBukkitEntity().getLocation().getX())<0){xNegative=true;}else{xNegative=false;}
if ((z-HerobrineAI.HerobrineNPC.getBukkitEntity().getLocation().getZ())<0){zNegative=true;}else{zNegative=false;}
Location loc = HerobrineAI.HerobrineNPC.getBukkitEntity().getLocation();
World world = loc.getWorld();
if (loc.getBlockX()>(int)x-1 && loc.getBlockX()<(int)x+1 && loc.getBlockZ()>(int)z-1 && loc.getBlockZ()<(int)z+1){
isCompleted=true;
return;
}
float nX=(float) loc.getX();
float nY=(float) loc.getY();
float nZ=(float) loc.getZ();
float pre_finalX=0.3f;
float pre_finalZ=0.3f;
if (xNegative){pre_finalX=-0.3f;}
if (zNegative){pre_finalZ=-0.3f;}
boolean canGoX=true;
boolean canGoZ=true;
if (world.getHighestBlockYAt((int)(nX+pre_finalX),(int)nZ)>nY+1){
canGoX=false;
}
if (world.getHighestBlockYAt((int)nX,(int)(nZ+pre_finalZ))>nY+1){
canGoZ=false;
}
if (canGoX && canGoZ){
if (world.getHighestBlockYAt((int)(nX+pre_finalX),(int)(nZ+pre_finalZ))>nY+1){
canGoX=false;
canGoZ=false;
}else if (world.getHighestBlockYAt((int)(nX+pre_finalX),(int)(nZ+pre_finalZ))<nY-2){
canGoX=false;
canGoZ=false;
}
}
Location newloc = HerobrineAI.HerobrineNPC.getBukkitEntity().getLocation();
if (canGoX){
newloc.setX(newloc.getX()+pre_finalX);
}
if (canGoZ){
newloc.setZ(newloc.getZ()+pre_finalZ);
}
if (canGoX && canGoZ){
if (xNegative){
}
}
newloc.setY(world.getHighestBlockYAt(newloc)-1);
if (HerobrineAI.StandBlocks.contains(world.getBlockAt(newloc).getType())){
newloc.setY(newloc.getWorld().getHighestBlockYAt(newloc)+1.5f);
HerobrineAI.HerobrineNPC.lookAtPoint(newloc);
newloc.setY(newloc.getWorld().getHighestBlockYAt(newloc));
HerobrineAI.HerobrineNPC.moveTo(newloc);
}
stepNow++;
}
}else{
if (new Random().nextInt(4)==0){
HerobrineAI.HerobrineNPC.setYaw(new Random().nextInt(360));
HerobrineAI.HerobrineNPC.setPitch(0);
}
}
}
public boolean canContinue(){
return this.canContinue;
}
}

View File

@ -0,0 +1,21 @@
package org.jakub1221.herobrineai.NPC.AI;
public class PathManager {
Path pathNow = null;
public void setPath(Path path){
pathNow=path;
}
public void update(){
if (pathNow!=null){
pathNow.update();
}
}
public Path getPath(){
return pathNow;
}
}

View File

@ -0,0 +1,45 @@
package org.jakub1221.herobrineai.NPC.Entity;
import net.minecraft.server.v1_5_R2.Entity;
import net.minecraft.server.v1_5_R2.EntityHuman;
import net.minecraft.server.v1_5_R2.EntityPlayer;
import net.minecraft.server.v1_5_R2.EnumGamemode;
import net.minecraft.server.v1_5_R2.PlayerInteractManager;
import org.bukkit.craftbukkit.v1_5_R2.entity.CraftEntity;
import org.jakub1221.herobrineai.NPC.NPCCore;
import org.jakub1221.herobrineai.NPC.NMS.BWorld;
import org.jakub1221.herobrineai.NPC.Network.NetworkHandler;
public class HumanEntity extends EntityPlayer {
public HumanEntity(NPCCore npcCore, BWorld world, String s, PlayerInteractManager playerInteractManager) {
super(npcCore.getServer().getMCServer(), world.getWorldServer(), s, playerInteractManager);
playerInteractManager.b(EnumGamemode.SURVIVAL);
playerConnection = new NetworkHandler(npcCore, this);
fauxSleeping = true;
}
public void setBukkitEntity(org.bukkit.entity.Entity entity) {
bukkitEntity = (CraftEntity) entity;
}
@Override
public void move(double arg0, double arg1, double arg2) {
setPosition(arg0, arg1, arg2);
}
@Override
public boolean a(EntityHuman entity) {
return super.a(entity);
}
@Override
public void c(Entity entity) {
super.c(entity);
}
}

View File

@ -0,0 +1,107 @@
package org.jakub1221.herobrineai.NPC.Entity;
import net.minecraft.server.v1_5_R2.EntityPlayer;
import net.minecraft.server.v1_5_R2.Packet18ArmAnimation;
import net.minecraft.server.v1_5_R2.WorldServer;
import net.minecraft.server.v1_5_R2.Entity;
import org.bukkit.Location;
import org.bukkit.entity.LivingEntity;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.PlayerInventory;
public class HumanNPC {
private Entity entity;
private final int id;
public HumanNPC(HumanEntity humanEntity,int id) {
this.entity=humanEntity;
this.id=id;
}
public int getID(){
return this.id;
}
public Entity getEntity(){
return this.entity;
}
public void ArmSwingAnimation() {
((WorldServer) getEntity().world).tracker.a(getEntity(), new Packet18ArmAnimation(getEntity(), 1));
}
public void HurtAnimation() {
((WorldServer) getEntity().world).tracker.a(getEntity(), new Packet18ArmAnimation(getEntity(), 2));
}
public void setItemInHand(ItemStack item) {
if (item!=null){
((org.bukkit.entity.HumanEntity) getEntity().getBukkitEntity()).setItemInHand(item);
}
}
public String getName() {
return ((HumanEntity) getEntity()).name;
}
public void setPitch(float pitch){
((HumanEntity) getEntity()).pitch=pitch;
}
public void moveTo(Location loc){
Teleport(loc);
}
public void Teleport(Location loc){
getEntity().getBukkitEntity().teleport(loc);
}
public PlayerInventory getInventory() {
return ((org.bukkit.entity.HumanEntity) getEntity().getBukkitEntity()).getInventory();
}
public void removeFromWorld() {
try {
entity.world.removeEntity(entity);
} catch (Exception e) {
e.printStackTrace();
}
}
public void setYaw(float yaw){
((EntityPlayer) getEntity()).yaw=yaw;
((EntityPlayer) getEntity()).aA=yaw;
}
public void lookAtPoint(Location point) {
if (getEntity().getBukkitEntity().getWorld() != point.getWorld()) {
return;
}
Location npcLoc = ((LivingEntity) getEntity().getBukkitEntity()).getEyeLocation();
double xDiff = point.getX() - npcLoc.getX();
double yDiff = point.getY() - npcLoc.getY();
double zDiff = point.getZ() - npcLoc.getZ();
double DistanceXZ = Math.sqrt(xDiff * xDiff + zDiff * zDiff);
double DistanceY = Math.sqrt(DistanceXZ * DistanceXZ + yDiff * yDiff);
double newYaw = Math.acos(xDiff / DistanceXZ) * 180 / Math.PI;
double newPitch = Math.acos(yDiff / DistanceY) * 180 / Math.PI - 90;
if (zDiff < 0.0) {
newYaw = newYaw + Math.abs(180 - newYaw) * 2;
}
((EntityPlayer) getEntity()).yaw = (float) (newYaw - 90);
((EntityPlayer) getEntity()).pitch = (float) newPitch;
((EntityPlayer) getEntity()).aA = (float) (newYaw - 90);
}
public org.bukkit.entity.Entity getBukkitEntity() {
return entity.getBukkitEntity();
}
}

View File

@ -0,0 +1,75 @@
package org.jakub1221.herobrineai.NPC.NMS;
import java.util.HashMap;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import net.minecraft.server.v1_5_R2.DedicatedServer;
import net.minecraft.server.v1_5_R2.MinecraftServer;
import net.minecraft.server.v1_5_R2.WorldServer;
import org.bukkit.Bukkit;
import org.bukkit.Server;
import org.bukkit.craftbukkit.v1_5_R2.CraftServer;
public class BServer {
private static BServer ins;
private MinecraftServer mcServer;
private CraftServer cServer;
private Server server;
private HashMap<String, BWorld> worlds = new HashMap<String, BWorld>();
private BServer() {
server = Bukkit.getServer();
try {
cServer = (CraftServer) server;
mcServer = cServer.getServer();
} catch (Exception ex) {
Logger.getLogger("Minecraft").log(Level.SEVERE, null, ex);
}
}
public void stop() {
mcServer.safeShutdown();
}
public void sendConsoleCommand(String cmd) {
if (mcServer.isRunning()) {
((DedicatedServer) mcServer).issueCommand(cmd, mcServer);
}
}
public Logger getLogger() {
return cServer.getLogger();
}
public List<WorldServer> getWorldServers() {
return mcServer.worlds;
}
public Server getServer() {
return server;
}
public BWorld getWorld(String worldName) {
if (worlds.containsKey(worldName)) {
return worlds.get(worldName);
}
BWorld w = new BWorld(this, worldName);
worlds.put(worldName, w);
return w;
}
public static BServer getInstance() {
if (ins == null) {
ins = new BServer();
}
return ins;
}
public MinecraftServer getMCServer() {
return mcServer;
}
}

View File

@ -0,0 +1,91 @@
package org.jakub1221.herobrineai.NPC.NMS;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.Callable;
import java.util.logging.Level;
import java.util.logging.Logger;
import net.minecraft.server.v1_5_R2.AxisAlignedBB;
import net.minecraft.server.v1_5_R2.Entity;
import net.minecraft.server.v1_5_R2.EntityPlayer;
import net.minecraft.server.v1_5_R2.PlayerChunkMap;
import net.minecraft.server.v1_5_R2.WorldProvider;
import net.minecraft.server.v1_5_R2.WorldServer;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.craftbukkit.v1_5_R2.CraftWorld;
import org.bukkit.craftbukkit.v1_5_R2.entity.CraftPlayer;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
public class BWorld {
private BServer server;
private World world;
private CraftWorld cWorld;
private WorldServer wServer;
private WorldProvider wProvider;
public BWorld(BServer server, String worldName) {
this.server = server;
world = server.getServer().getWorld(worldName);
try {
cWorld = (CraftWorld) world;
wServer = cWorld.getHandle();
wProvider = wServer.worldProvider;
} catch (Exception ex) {
Logger.getLogger("Minecraft").log(Level.SEVERE, null, ex);
}
}
public BWorld(World world) {
this.world = world;
try {
cWorld = (CraftWorld) world;
wServer = cWorld.getHandle();
wProvider = wServer.worldProvider;
} catch (Exception ex) {
Logger.getLogger("Minecraft").log(Level.SEVERE, null, ex);
}
}
public PlayerChunkMap getPlayerManager() {
return wServer.getPlayerChunkMap();
}
public CraftWorld getCraftWorld() {
return cWorld;
}
public WorldServer getWorldServer() {
return wServer;
}
@SuppressWarnings("unchecked")
public void removeEntity(String name, final Player player, JavaPlugin plugin) {
server.getServer().getScheduler().callSyncMethod(plugin, new Callable<Object>() {
@Override
public Object call() throws Exception {
Location loc = player.getLocation();
CraftWorld craftWorld = (CraftWorld) player.getWorld();
CraftPlayer craftPlayer = (CraftPlayer) player;
double x = loc.getX() + 0.5;
double y = loc.getY() + 0.5;
double z = loc.getZ() + 0.5;
double radius = 10;
List<Entity> entities = new ArrayList<Entity>();
AxisAlignedBB bb = AxisAlignedBB.a(x - radius, y - radius, z - radius, x + radius, y + radius, z + radius);
entities = craftWorld.getHandle().getEntities(craftPlayer.getHandle(), bb);
for (Entity o : entities) {
if (!(o instanceof EntityPlayer)) {
o.getBukkitEntity().remove();
}
}
return null;
}
});
}
}

View File

@ -0,0 +1,154 @@
package org.jakub1221.herobrineai.NPC;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import net.minecraft.server.v1_5_R2.Entity;
import net.minecraft.server.v1_5_R2.PlayerInteractManager;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.event.EventException;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.world.ChunkLoadEvent;
import org.bukkit.event.world.ChunkUnloadEvent;
import org.bukkit.plugin.java.JavaPlugin;
import org.jakub1221.herobrineai.NPC.Entity.HumanEntity;
import org.jakub1221.herobrineai.NPC.Entity.HumanNPC;
import org.jakub1221.herobrineai.NPC.NMS.BServer;
import org.jakub1221.herobrineai.NPC.NMS.BWorld;
import org.jakub1221.herobrineai.NPC.Network.NetworkCore;
public class NPCCore {
private ArrayList<HumanNPC> npcs = new ArrayList<HumanNPC>();
private BServer server;
private int taskid;
private Map<World, BWorld> bworlds = new HashMap<World, BWorld>();
private NetworkCore networkCore;
public static JavaPlugin plugin;
public boolean isInLoaded=false;
private int lastID=0;
public NPCCore(JavaPlugin plugin) {
server = BServer.getInstance();
try {
networkCore = new NetworkCore();
} catch (IOException e) {
e.printStackTrace();
}
taskid = Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable() {
@Override
public void run() {
ArrayList<HumanNPC> toRemove = new ArrayList<HumanNPC>();
for (HumanNPC i : npcs) {
Entity j = i.getEntity();
if (j.dead) {
toRemove.add(i);
}
}
for (HumanNPC n : toRemove) {
npcs.remove(n);
}
}
}, 1L, 1L);
Bukkit.getServer().getPluginManager().registerEvents(new WorldL(), plugin);
}
public void removeAll() {
for (HumanNPC humannpc : npcs) {
if (humannpc != null) {
humannpc.removeFromWorld();
}
}
npcs.clear();
}
public BWorld getBWorld(World world) {
BWorld bworld = bworlds.get(world);
if (bworld != null) {
return bworld;
}
bworld = new BWorld(world);
bworlds.put(world, bworld);
return bworld;
}
public void DisableTask(){
Bukkit.getServer().getScheduler().cancelTask(taskid);
}
private class WorldL implements Listener {
@SuppressWarnings("unused")
@EventHandler
public void onChunkLoad(ChunkLoadEvent event) throws EventException {
for (HumanNPC humannpc : npcs) {
if (humannpc != null && event.getChunk() == humannpc.getBukkitEntity().getLocation().getBlock().getChunk()) {
if (isInLoaded==false){
BWorld world = getBWorld(event.getWorld());
isInLoaded=true;
}}
}
}
@EventHandler
public void onChunkUnload(ChunkUnloadEvent event){
for (HumanNPC humannpc : npcs) {
if (humannpc != null && event.getChunk() == humannpc.getBukkitEntity().getLocation().getBlock().getChunk()) {
}
}
}
}
public HumanNPC spawnHumanNPC(String name, Location l) {
lastID++;
int id = lastID;
return spawnHumanNPC(name, l, id);
}
public HumanNPC spawnHumanNPC(String name, Location l, int id) {
BWorld world = getBWorld(l.getWorld());
HumanEntity humanEntity = new HumanEntity(this, world, name, new PlayerInteractManager(world.getWorldServer()));
((Entity) humanEntity).setLocation(l.getX(), l.getY(), l.getZ(),l.getYaw(),l.getPitch());
world.getWorldServer().addEntity(humanEntity);
HumanNPC humannpc = new HumanNPC(humanEntity,id);
npcs.add(humannpc);
return humannpc;
}
public HumanNPC getHumanNPC(int id) {
for(HumanNPC n : npcs){
if (n.getID()==id){
return n;
}
}
return null;
}
public BServer getServer() {
return server;
}
public NetworkCore getNetworkCore() {
return networkCore;
}
}

View File

@ -0,0 +1,39 @@
package org.jakub1221.herobrineai.NPC.Network;
import java.io.IOException;
import net.minecraft.server.v1_5_R2.Connection;
import net.minecraft.server.v1_5_R2.NetworkManager;
import net.minecraft.server.v1_5_R2.Packet;
public class NetworkCore extends NetworkManager{
public NetworkCore() throws IOException {
super(null, new NullSocket(), "NPCCore", new Connection() {
@Override
public boolean a() {
return true;
}
}, null);
}
@Override
public void queue(Packet packet) {
}
@Override
public void a() {
}
@Override
public void a(String s, Object... aobject) {
}
@Override
public void a(Connection nethandler) {
}
}

View File

@ -0,0 +1,120 @@
package org.jakub1221.herobrineai.NPC.Network;
import net.minecraft.server.v1_5_R2.EntityPlayer;
import net.minecraft.server.v1_5_R2.Packet;
import net.minecraft.server.v1_5_R2.Packet101CloseWindow;
import net.minecraft.server.v1_5_R2.Packet102WindowClick;
import net.minecraft.server.v1_5_R2.Packet106Transaction;
import net.minecraft.server.v1_5_R2.Packet10Flying;
import net.minecraft.server.v1_5_R2.Packet130UpdateSign;
import net.minecraft.server.v1_5_R2.Packet14BlockDig;
import net.minecraft.server.v1_5_R2.Packet15Place;
import net.minecraft.server.v1_5_R2.Packet16BlockItemSwitch;
import net.minecraft.server.v1_5_R2.Packet18ArmAnimation;
import net.minecraft.server.v1_5_R2.Packet19EntityAction;
import net.minecraft.server.v1_5_R2.Packet255KickDisconnect;
import net.minecraft.server.v1_5_R2.Packet3Chat;
import net.minecraft.server.v1_5_R2.Packet7UseEntity;
import net.minecraft.server.v1_5_R2.Packet9Respawn;
import net.minecraft.server.v1_5_R2.PlayerConnection;
import org.bukkit.Bukkit;
import org.bukkit.craftbukkit.v1_5_R2.CraftServer;
import org.bukkit.craftbukkit.v1_5_R2.entity.CraftPlayer;
import org.jakub1221.herobrineai.NPC.NPCCore;
public class NetworkHandler extends PlayerConnection {
public NetworkHandler(NPCCore npcCore, EntityPlayer entityPlayer) {
super(npcCore.getServer().getMCServer(), npcCore.getNetworkCore(), entityPlayer);
}
@Override
public CraftPlayer getPlayer() {
return new CraftPlayer((CraftServer) Bukkit.getServer(), player);
}
@Override
public void d() {
};
@Override
public void a(Packet10Flying packet10flying) {
};
@Override
public void a(double d0, double d1, double d2, float f, float f1) {
};
@Override
public void a(Packet14BlockDig packet14blockdig) {
};
@Override
public void a(Packet15Place packet15place) {
};
@Override
public void a(String s, Object[] aobject) {
};
@Override
public void onUnhandledPacket(Packet packet) {
};
@Override
public void a(Packet16BlockItemSwitch packet16blockitemswitch) {
};
@Override
public void a(Packet3Chat packet3chat) {
};
@Override
public void handleContainerClose(Packet101CloseWindow packet101closewindow) {
};
@Override
public void a(Packet102WindowClick packet102windowclick) {
};
@Override
public void a(Packet106Transaction packet106transaction) {
};
@Override
public int lowPriorityCount() {
return super.lowPriorityCount();
}
@Override
public void a(Packet130UpdateSign packet130updatesign) {
};
@Override
public void a(Packet18ArmAnimation packet18armanimation) {
};
@Override
public void a(Packet19EntityAction packet19entityaction) {
};
@Override
public void a(Packet255KickDisconnect packet255kickdisconnect) {
};
@Override
public void sendPacket(Packet packet) {
};
@Override
public void a(Packet7UseEntity packet7useentity) {
};
@Override
public void a(Packet9Respawn packet9respawn) {
};
}

View File

@ -0,0 +1,38 @@
package org.jakub1221.herobrineai.NPC.Network;
import net.minecraft.server.v1_5_R2.Packet;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.craftbukkit.v1_5_R2.entity.CraftPlayer;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
public class NetworkUtils {
public static void sendPacketNearby(Location location, Packet packet) {
sendPacketNearby(location, packet, 64);
}
public static void sendPacketNearby(Location location, Packet packet, double radius) {
radius *= radius;
final World world = location.getWorld();
for (Player p : Bukkit.getServer().getOnlinePlayers()) {
if (p == null || world != p.getWorld()) {
continue;
}
if (location.distanceSquared(p.getLocation()) > radius) {
continue;
}
((CraftPlayer)p).getHandle().playerConnection.sendPacket(packet);
}
}
public static ItemStack[] combineItemStackArrays(Object[] a, Object[] b) {
ItemStack[] c = new ItemStack[a.length+b.length];
System.arraycopy(a, 0, c, 0, a.length);
System.arraycopy(b, 0, c, a.length, b.length);
return c;
}
}

View File

@ -0,0 +1,22 @@
package org.jakub1221.herobrineai.NPC.Network;
import java.io.ByteArrayInputStream;
import java.io.OutputStream;
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import java.net.Socket;
public class NullSocket extends Socket {
@Override
public InputStream getInputStream() {
byte[] buffer = new byte[5];
return new ByteArrayInputStream(buffer);
}
@Override
public OutputStream getOutputStream() {
return new ByteArrayOutputStream();
}
}

View File

@ -0,0 +1,168 @@
package org.jakub1221.herobrineai;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.jakub1221.herobrineai.support._CustomItems;
import org.jakub1221.herobrineai.support._GriefPrevention;
import org.jakub1221.herobrineai.support._PreciousStones;
import org.jakub1221.herobrineai.support._Residence;
import org.jakub1221.herobrineai.support._Towny;
import org.jakub1221.herobrineai.support._WorldGuard;
public class Support {
private boolean B_Residence=false;
private boolean B_GriefPrevention=false;
private boolean B_Towny=false;
private boolean B_CustomItems=false;
private boolean B_WorldGuard=false;
private boolean B_PreciousStones=false;
private _Residence ResidenceCore=null;
private _GriefPrevention GriefPreventionCore=null;
private _Towny TownyCore=null;
private _CustomItems CustomItems=null;
private _WorldGuard WorldGuard=null;
private _PreciousStones PreciousStones=null;
public Support(){
ResidenceCore=new _Residence();
GriefPreventionCore=new _GriefPrevention();
TownyCore=new _Towny();
CustomItems=new _CustomItems();
WorldGuard=new _WorldGuard();
PreciousStones=new _PreciousStones();
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(HerobrineAI.getPluginCore(), new Runnable() {
public void run() {
CheckForPlugins();
}
}, 1 * 10L);
}
public boolean isPreciousStones(){
return B_PreciousStones;
}
public boolean isWorldGuard(){
return B_WorldGuard;
}
public boolean isResidence(){
return B_Residence;
}
public boolean isGriefPrevention(){
return B_GriefPrevention;
}
public boolean isTowny(){
return B_Towny;
}
public void CheckForPlugins(){
if (ResidenceCore.Check()){
B_Residence=true;
HerobrineAI.log.info("[HerobrineAI] Residence plugin detected!");
}
if (GriefPreventionCore.Check()){
B_GriefPrevention=true;
HerobrineAI.log.info("[HerobrineAI] GriefPrevention plugin detected!");
}
if (TownyCore.Check()){
B_Towny=true;
HerobrineAI.log.info("[HerobrineAI] Towny plugin detected!");
}
if (CustomItems.Check()){
B_CustomItems=true;
HerobrineAI.log.info("[HerobrineAI] CustomItems plugin detected!");
CustomItems.init();
}
if (WorldGuard.Check()){
B_WorldGuard=true;
HerobrineAI.log.info("[HerobrineAI] WorldGuard plugin detected!");
}
if (PreciousStones.Check()){
B_PreciousStones=true;
HerobrineAI.log.info("[HerobrineAI] PreciousStones plugin detected!");
}
}
public boolean isSecuredArea(Location loc){
if (B_Residence){
if (ResidenceCore.isSecuredArea(loc)){
return true;
}else{return false;}
}else if (B_GriefPrevention){
if (GriefPreventionCore.isSecuredArea(loc)){
return true;
}else{return false;}
}else if (B_Towny){
if (TownyCore.isSecuredArea(loc)){
return true;
}else{return false;}
}else if (B_WorldGuard){
if (WorldGuard.isSecuredArea(loc)){
return true;
}else{return false;}
}else if (B_PreciousStones){
if (PreciousStones.isSecuredArea(loc)){
return true;
}else{return false;}
}
return false;
}
public boolean checkBuild(Location loc){
if (HerobrineAI.getPluginCore().getConfigDB().SecuredArea_Build){
return true;
}else{
if (isSecuredArea(loc)){
return false;
}else{return true;}
}
}
public boolean checkAttack(Location loc){
if (HerobrineAI.getPluginCore().getConfigDB().SecuredArea_Attack){
return true;
}else{
if (isSecuredArea(loc)){
return false;
}else{return true;}
}
}
public boolean checkHaunt(Location loc){
if (HerobrineAI.getPluginCore().getConfigDB().SecuredArea_Haunt){
return true;
}else{
if (isSecuredArea(loc)){
return false;
}else{return true;}
}
}
public boolean checkSigns(Location loc){
if (HerobrineAI.getPluginCore().getConfigDB().SecuredArea_Signs){
return true;
}else{
if (isSecuredArea(loc)){
return false;
}else{return true;}
}
}
public boolean checkBooks(Location loc){
if (HerobrineAI.getPluginCore().getConfigDB().SecuredArea_Books){
return true;
}else{
if (isSecuredArea(loc)){
return false;
}else{return true;}
}
}
public boolean isCustomItems(){
return B_CustomItems;
}
public _CustomItems getCustomItems(){
if (B_CustomItems){
return CustomItems;
}
return null;
}
}

View File

@ -0,0 +1,488 @@
package org.jakub1221.herobrineai.commands;
import java.util.logging.Logger;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.jakub1221.herobrineai.HerobrineAI;
import org.jakub1221.herobrineai.AI.AICore;
import org.jakub1221.herobrineai.AI.Core.CoreType;
public class CmdExecutor implements CommandExecutor{
private HerobrineAI P_Core = null;
private Logger log = null;
public CmdExecutor(HerobrineAI i){
P_Core=i;
log=i.log;
}
@Override
public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args){
if (sender instanceof Player){
Player player = (Player) sender;
if (player.isOp()){
if (args.length>0){
if (args[0].equalsIgnoreCase("attack")){
if (args.length>1){
if (Bukkit.getServer().getPlayer(args[1])!=null){
if (Bukkit.getServer().getPlayer(args[1]).isOnline()){
if (P_Core.getSupport().checkAttack(Bukkit.getServer().getPlayer(args[1]).getLocation())){
if (P_Core.canAttackPlayer(Bukkit.getServer().getPlayer(args[1]), player)){
if (AICore.isTarget==false){
P_Core.getAICore().setAttackTarget(Bukkit.getServer().getPlayer(args[1]));
player.sendMessage(ChatColor.RED+"[HerobrineAI] Herobrine is now attacking the "+args[1]+"!");
}else{player.sendMessage(ChatColor.RED+"[HerobrineAI] Herobrine already has target! Use "+ChatColor.GREEN+"/hb-ai cancel"+ChatColor.RED+" to cancel actual target");}
}
}else{player.sendMessage(ChatColor.RED+"[HerobrineAI] Player is in secure area.");}
}else{player.sendMessage(ChatColor.RED+"[HerobrineAI] Player is offline.");}
}else{player.sendMessage(ChatColor.RED+"[HerobrineAI] Player is offline.");}
}else{player.sendMessage(ChatColor.RED+"Usage: "+ChatColor.GREEN+"/hb-ai attack <player name>");}
}else if (args[0].equalsIgnoreCase("pyramid")){
if (args.length>1){
if (Bukkit.getServer().getPlayer(args[1])!=null){
if (Bukkit.getServer().getPlayer(args[1]).isOnline()){
if (P_Core.getSupport().checkBuild(Bukkit.getServer().getPlayer(args[1]).getLocation())){
Object[] data = {Bukkit.getServer().getPlayer(args[1])};
if(P_Core.getAICore().getCore(CoreType.PYRAMID).RunCore(data).getResult()){
player.sendMessage(ChatColor.RED+"[HerobrineAI] Creating pyramind near "+args[1]+"!");
}else{player.sendMessage(ChatColor.RED+"[HerobrineAI] Cannot find good place for pyramid!");}
}else{player.sendMessage(ChatColor.RED+"[HerobrineAI] Player is in secure area.");}
}else{player.sendMessage(ChatColor.RED+"[HerobrineAI] Player is offline.");}
}else{player.sendMessage(ChatColor.RED+"[HerobrineAI] Player is offline.");}
}else{player.sendMessage(ChatColor.RED+"Usage: "+ChatColor.GREEN+"/hb-ai pyramid <player name>");}
}
else if (args[0].equalsIgnoreCase("bury")){
if (args.length>1){
if (Bukkit.getServer().getPlayer(args[1])!=null){
if (Bukkit.getServer().getPlayer(args[1]).isOnline()){
if (P_Core.getSupport().checkHaunt(Bukkit.getServer().getPlayer(args[1]).getLocation())){
Object[] data = {Bukkit.getServer().getPlayer(args[1])};
if(P_Core.getAICore().getCore(CoreType.BURY_PLAYER).RunCore(data).getResult()){
player.sendMessage(ChatColor.RED+"[HerobrineAI] Buried "+args[1]+"!");
}else{player.sendMessage(ChatColor.RED+"[HerobrineAI] Cannot find good place!");}
}else{player.sendMessage(ChatColor.RED+"[HerobrineAI] Player is in secure area.");}
}else{player.sendMessage(ChatColor.RED+"[HerobrineAI] Player is offline.");}
}else{player.sendMessage(ChatColor.RED+"[HerobrineAI] Player is offline.");}
}else{player.sendMessage(ChatColor.RED+"Usage: "+ChatColor.GREEN+"/hb-ai bury <player name>");}
}else if (args[0].equalsIgnoreCase("temple")){
if (args.length>1){
if (Bukkit.getServer().getPlayer(args[1])!=null){
if (Bukkit.getServer().getPlayer(args[1]).isOnline()){
if (P_Core.getSupport().checkBuild(Bukkit.getServer().getPlayer(args[1]).getLocation())){
Object[] data = {Bukkit.getServer().getPlayer(args[1])};
if(P_Core.getAICore().getCore(CoreType.TEMPLE).RunCore(data).getResult()){
player.sendMessage(ChatColor.RED+"[HerobrineAI] Creating temple near "+args[1]+"!");
}else{player.sendMessage(ChatColor.RED+"[HerobrineAI] Cannot find good place for temple!");}
}else{player.sendMessage(ChatColor.RED+"[HerobrineAI] Player is in secure area.");}
}else{player.sendMessage(ChatColor.RED+"[HerobrineAI] Player is offline.");}
}else{player.sendMessage(ChatColor.RED+"[HerobrineAI] Player is offline.");}
}else{player.sendMessage(ChatColor.RED+"Usage: "+ChatColor.GREEN+"/hb-ai temple <player name>");}
}else if (args[0].equalsIgnoreCase("heads")){
if (args.length>1){
if (Bukkit.getServer().getPlayer(args[1])!=null){
Object[] data = {args[1]};
player.sendMessage(ChatColor.RED+"[HerobrineAI] "+P_Core.getAICore().getCore(CoreType.HEADS).RunCore(data).getResultString());
}else{player.sendMessage(ChatColor.RED+"[HerobrineAI] Player is offline.");}
}else{player.sendMessage(ChatColor.RED+"Usage: "+ChatColor.GREEN+"/hb-ai heads <player name>");}
}else if (args[0].equalsIgnoreCase("cave")){
if (args.length>1){
if (Bukkit.getServer().getPlayer(args[1])!=null){
Object[] data = {Bukkit.getServer().getPlayer(args[1]).getLocation(),true};
player.sendMessage(ChatColor.RED+"[HerobrineAI] "+P_Core.getAICore().getCore(CoreType.BUILD_STUFF).RunCore(data).getResultString());
}else{player.sendMessage(ChatColor.RED+"[HerobrineAI] Player is offline.");}
}else{player.sendMessage(ChatColor.RED+"Usage: "+ChatColor.GREEN+"/hb-ai cave <player name>");}
}
else if (args[0].equalsIgnoreCase("graveyard")){
if (args.length>1){
if (Bukkit.getServer().getPlayer(args[1])!=null){
if (Bukkit.getServer().getPlayer(args[1]).isOnline()){
if (AICore.isTarget==false){
P_Core.getAICore().GraveyardTeleport(Bukkit.getServer().getPlayer(args[1]));
player.sendMessage(ChatColor.RED+"[HerobrineAI] "+args[1]+" is now in the Graveyard world!");
}else{player.sendMessage(ChatColor.RED+"[HerobrineAI] Herobrine already has target! Use "+ChatColor.GREEN+"/hb-ai cancel"+ChatColor.RED+" to cancel actual target");}
}else{player.sendMessage(ChatColor.RED+"[HerobrineAI] Player is offline.");}
}else{player.sendMessage(ChatColor.RED+"[HerobrineAI] Player is offline.");}
}else{player.sendMessage(ChatColor.RED+"Usage: "+ChatColor.GREEN+"/hb-ai graveyard <player name>");}
}else if (args[0].equalsIgnoreCase("haunt")){
if (args.length>1){
if (Bukkit.getServer().getPlayer(args[1])!=null){
if (Bukkit.getServer().getPlayer(args[1]).isOnline()){
if (P_Core.canAttackPlayer(Bukkit.getServer().getPlayer(args[1]), player)){
if (AICore.isTarget==false){
P_Core.getAICore().setHauntTarget(Bukkit.getServer().getPlayer(args[1]));
player.sendMessage(ChatColor.RED+"[HerobrineAI] Herobrine now haunts the "+args[1]+"!");
}else{player.sendMessage(ChatColor.RED+"[HerobrineAI] Herobrine already has target! Use "+ChatColor.GREEN+"/hb-ai cancel"+ChatColor.RED+" to cancel actual target.");}
}
}else{player.sendMessage(ChatColor.RED+"[HerobrineAI] Player is offline.");}
}else{player.sendMessage(ChatColor.RED+"[HerobrineAI] Player is offline.");}
}else{player.sendMessage(ChatColor.RED+"Usage: "+ChatColor.GREEN+"/hb-ai haunt <player name>");}
}else if (args[0].equalsIgnoreCase("cancel")){
P_Core.getAICore().CancelTarget(CoreType.ANY);
player.sendMessage(ChatColor.RED+"[HerobrineAI] Target cancelled!");
}else if (args[0].equalsIgnoreCase("reload")){
P_Core.getConfigDB().Reload();
player.sendMessage(ChatColor.RED+"[HerobrineAI] Config reloaded!");
}else if (args[0].equalsIgnoreCase("help")){
player.sendMessage(ChatColor.RED+"[HerobrineAI] Command list");
player.sendMessage(ChatColor.GREEN+"/hb-ai help - shows all commands");
player.sendMessage(ChatColor.GREEN+"/hb-ai attack <player name> - herobrine attacks the player");
player.sendMessage(ChatColor.GREEN+"/hb-ai haunt <player name> - herobrine haunts the player");
player.sendMessage(ChatColor.GREEN+"/hb-ai cancel - cancel herobrine´s actual target");
player.sendMessage(ChatColor.GREEN+"/hb-ai reload - reload config");
player.sendMessage(ChatColor.GREEN+"/hb-ai position - gets actual position of Herobrine");
player.sendMessage(ChatColor.GREEN+"/hb-ai pyramid <player name> - build pyramid near the player");
player.sendMessage(ChatColor.GREEN+"/hb-ai bury <player name> - bury player");
player.sendMessage(ChatColor.GREEN+"/hb-ai graveyard <player name> - teleport player to the Graveyard world");
player.sendMessage(ChatColor.GREEN+"/hb-ai temple <player name> - build temple near the player");
player.sendMessage(ChatColor.GREEN+"/hb-ai heads <player name> - place heads near the player");
player.sendMessage(ChatColor.GREEN+"/hb-ai cave <player name> - create cave near the player");
}else if (args[0].equalsIgnoreCase("position")){
player.sendMessage(ChatColor.RED+"[HerobrineAI] Position");
player.sendMessage(ChatColor.RED+"World: "+P_Core.HerobrineNPC.getBukkitEntity().getLocation().getWorld().getName()+" X: "+((int)P_Core.HerobrineNPC.getBukkitEntity().getLocation().getX())+
" Y: "+((int)P_Core.HerobrineNPC.getBukkitEntity().getLocation().getY())+" Z: "+((int)P_Core.HerobrineNPC.getBukkitEntity().getLocation().getZ()));
player.sendMessage(ChatColor.RED+"InWalkingMode: "+AICore.getStringWalkingMode());
player.sendMessage(ChatColor.RED+"Available World: "+HerobrineAI.getPluginCore().getAvailableWorldString());
}else{player.sendMessage(ChatColor.RED+"Usage: /hb-ai help");}
}else{player.sendMessage(ChatColor.RED+"Usage: /hb-ai help");}
}else{
/* PERMISSION NODE */
if (args.length>0){
if (args[0].equalsIgnoreCase("attack")){
if (args.length>1){
if (player.hasPermission("hb-ai.attack")){
if (Bukkit.getServer().getPlayer(args[1])!=null){
if (Bukkit.getServer().getPlayer(args[1]).isOnline()){
if (P_Core.getSupport().checkAttack(Bukkit.getServer().getPlayer(args[1]).getLocation())){
if (P_Core.canAttackPlayer(Bukkit.getServer().getPlayer(args[1]), player)){
if (AICore.isTarget==false){
P_Core.getAICore().setAttackTarget(Bukkit.getServer().getPlayer(args[1]));
player.sendMessage(ChatColor.RED+"[HerobrineAI] Herobrine is now attacking the "+args[1]+"!");
}else{player.sendMessage(ChatColor.RED+"[HerobrineAI] Herobrine already has target! Use "+ChatColor.GREEN+"/hb-ai cancel"+ChatColor.RED+" to cancel actual target");}
}
}else{player.sendMessage(ChatColor.RED+"[HerobrineAI] Player is in secure area.");}
}else{player.sendMessage(ChatColor.RED+"[HerobrineAI] Player is offline.");}
}else{player.sendMessage(ChatColor.RED+"[HerobrineAI] Player is offline.");}
}else{player.sendMessage(ChatColor.RED+"You don´t have permissions to do that.");}
}else{player.sendMessage(ChatColor.RED+"Usage: "+ChatColor.GREEN+"/hb-ai attack <player name>");}
}else if (args[0].equalsIgnoreCase("pyramid")){
if (args.length>1){
if(player.hasPermission("hb-ai.pyramid")){
if (Bukkit.getServer().getPlayer(args[1])!=null){
if (Bukkit.getServer().getPlayer(args[1]).isOnline()){
if (P_Core.getSupport().checkBuild(Bukkit.getServer().getPlayer(args[1]).getLocation())){
Object[] data = {Bukkit.getServer().getPlayer(args[1])};
if(P_Core.getAICore().getCore(CoreType.PYRAMID).RunCore(data).getResult()){
player.sendMessage(ChatColor.RED+"[HerobrineAI] Creating pyramind near "+args[1]+"!");
}else{player.sendMessage(ChatColor.RED+"[HerobrineAI] Cannot find good place for pyramid!");}
}else{player.sendMessage(ChatColor.RED+"[HerobrineAI] Player is in secure area.");}
}else{player.sendMessage(ChatColor.RED+"[HerobrineAI] Player is offline.");}
}else{player.sendMessage(ChatColor.RED+"[HerobrineAI] Player is offline.");}
}else{player.sendMessage(ChatColor.RED+"You don´t have permissions to do that.");}
}else{player.sendMessage(ChatColor.RED+"Usage: "+ChatColor.GREEN+"/hb-ai pyramid <player name>");}
}else if (args[0].equalsIgnoreCase("temple")){
if (args.length>1){
if(player.hasPermission("hb-ai.temple")){
if (Bukkit.getServer().getPlayer(args[1])!=null){
if (Bukkit.getServer().getPlayer(args[1]).isOnline()){
if (P_Core.getSupport().checkBuild(Bukkit.getServer().getPlayer(args[1]).getLocation())){
Object[] data = {Bukkit.getServer().getPlayer(args[1])};
if(P_Core.getAICore().getCore(CoreType.TEMPLE).RunCore(data).getResult()){
player.sendMessage(ChatColor.RED+"[HerobrineAI] Creating temple near "+args[1]+"!");
}else{player.sendMessage(ChatColor.RED+"[HerobrineAI] Cannot find good place for temple!");}
}else{player.sendMessage(ChatColor.RED+"[HerobrineAI] Player is in secure area.");}
}else{player.sendMessage(ChatColor.RED+"[HerobrineAI] Player is offline.");}
}else{player.sendMessage(ChatColor.RED+"[HerobrineAI] Player is offline.");}
}else{player.sendMessage(ChatColor.RED+"You don´t have permissions to do that.");}
}else{player.sendMessage(ChatColor.RED+"Usage: "+ChatColor.GREEN+"/hb-ai temple <player name>");}
}else if (args[0].equalsIgnoreCase("bury")){
if (args.length>1){
if (player.hasPermission("hb-ai.bury")){
if (Bukkit.getServer().getPlayer(args[1])!=null){
if (Bukkit.getServer().getPlayer(args[1]).isOnline()){
if (P_Core.getSupport().checkBuild(Bukkit.getServer().getPlayer(args[1]).getLocation())){
Object[] data = {Bukkit.getServer().getPlayer(args[1])};
if(P_Core.getAICore().getCore(CoreType.BURY_PLAYER).RunCore(data).getResult()){
player.sendMessage(ChatColor.RED+"[HerobrineAI] Buried "+args[1]+"!");
}else{player.sendMessage(ChatColor.RED+"[HerobrineAI] Cannot find good place!");}
}else{player.sendMessage(ChatColor.RED+"[HerobrineAI] Player is in secure area.");}
}else{player.sendMessage(ChatColor.RED+"[HerobrineAI] Player is offline.");}
}else{player.sendMessage(ChatColor.RED+"[HerobrineAI] Player is offline.");}
}else{player.sendMessage(ChatColor.RED+"You don´t have permissions to do that.");}
}else{player.sendMessage(ChatColor.RED+"Usage: "+ChatColor.GREEN+"/hb-ai bury <player name>");}
}
else if (args[0].equalsIgnoreCase("cave")){
if (args.length>1){
if (player.hasPermission("hb-ai.cave")){
if (Bukkit.getServer().getPlayer(args[1])!=null){
Object[] data = {Bukkit.getServer().getPlayer(args[1]).getLocation(),true};
player.sendMessage(ChatColor.RED+"[HerobrineAI] "+P_Core.getAICore().getCore(CoreType.BUILD_STUFF).RunCore(data).getResultString());
}else{player.sendMessage(ChatColor.RED+"[HerobrineAI] Player is offline.");}
}else{player.sendMessage(ChatColor.RED+"You don´t have permissions to do that.");}
}else{player.sendMessage(ChatColor.RED+"Usage: "+ChatColor.GREEN+"/hb-ai cave <player name>");}
}else if (args[0].equalsIgnoreCase("heads")){
if (args.length>1){
if (player.hasPermission("hb-ai.heads")){
if (Bukkit.getServer().getPlayer(args[1])!=null){
Object[] data = {args[1]};
player.sendMessage(ChatColor.RED+"[HerobrineAI] "+P_Core.getAICore().getCore(CoreType.HEADS).RunCore(data).getResultString());
}else{player.sendMessage(ChatColor.RED+"[HerobrineAI] Player is offline.");}
}else{player.sendMessage(ChatColor.RED+"You don´t have permissions to do that.");}
}else{player.sendMessage(ChatColor.RED+"Usage: "+ChatColor.GREEN+"/hb-ai heads <player name>");}
}
else if (args[0].equalsIgnoreCase("graveyard")){
if (args.length>1){
if (player.hasPermission("hb-ai.graveyard")){
if (Bukkit.getServer().getPlayer(args[1])!=null){
if (Bukkit.getServer().getPlayer(args[1]).isOnline()){
if (AICore.isTarget==false){
P_Core.getAICore().GraveyardTeleport(Bukkit.getServer().getPlayer(args[1]));
player.sendMessage(ChatColor.RED+"[HerobrineAI] "+args[1]+" is now in the Graveyard world!");
}else{player.sendMessage(ChatColor.RED+"[HerobrineAI] Herobrine already has target! Use "+ChatColor.GREEN+"/hb-ai cancel"+ChatColor.RED+" to cancel actual target");}
}else{player.sendMessage(ChatColor.RED+"[HerobrineAI] Player is offline.");}
}else{player.sendMessage(ChatColor.RED+"[HerobrineAI] Player is offline.");}
}else{player.sendMessage(ChatColor.RED+"You don´t have permissions to do that.");}
}else{player.sendMessage(ChatColor.RED+"Usage: "+ChatColor.GREEN+"/hb-ai graveyard <player name>");}
}else if (args[0].equalsIgnoreCase("haunt")){
if (args.length>1){
if (player.hasPermission("hb-ai.haunt")){
if (Bukkit.getServer().getPlayer(args[1])!=null){
if (Bukkit.getServer().getPlayer(args[1]).isOnline()){
if (P_Core.getSupport().checkHaunt(Bukkit.getServer().getPlayer(args[1]).getLocation())){
if (P_Core.canAttackPlayer(Bukkit.getServer().getPlayer(args[1]), player)){
if (AICore.isTarget==false){
P_Core.getAICore().setHauntTarget(Bukkit.getServer().getPlayer(args[1]));
player.sendMessage(ChatColor.RED+"[HerobrineAI] Herobrine now haunts the "+args[1]+"!");
}else{player.sendMessage(ChatColor.RED+"[HerobrineAI] Herobrine already has target! Use "+ChatColor.GREEN+"/hb-ai cancel"+ChatColor.RED+" to cancel actual target.");}
}
}else{player.sendMessage(ChatColor.RED+"[HerobrineAI] Player is in secure area.");}
}else{player.sendMessage(ChatColor.RED+"[HerobrineAI] Player is offline.");}
}else{player.sendMessage(ChatColor.RED+"[HerobrineAI] Player is offline.");}
}else{player.sendMessage(ChatColor.RED+"You don´t have permissions to do that.");}
}else{player.sendMessage(ChatColor.RED+"Usage: "+ChatColor.GREEN+"/hb-ai haunt <player name>");}
}else if (args[0].equalsIgnoreCase("cancel")){
if (player.hasPermission("hb-ai.cancel")){
P_Core.getAICore().CancelTarget(CoreType.ANY);
player.sendMessage(ChatColor.RED+"[HerobrineAI] Target cancelled!");
}else{player.sendMessage(ChatColor.RED+"You don´t have permissions to do that.");}
}else if (args[0].equalsIgnoreCase("reload")){
if (player.hasPermission("hb-ai.reload")){
P_Core.getConfigDB().Reload();
player.sendMessage(ChatColor.RED+"[HerobrineAI] Config reloaded!");
}else{player.sendMessage(ChatColor.RED+"You don´t have permissions to do that.");}
}else if (args[0].equalsIgnoreCase("help")){
if (player.hasPermission("hb-ai.help")){
player.sendMessage(ChatColor.RED+"[HerobrineAI] Command list");
player.sendMessage(ChatColor.GREEN+"/hb-ai help - shows all commands");
player.sendMessage(ChatColor.GREEN+"/hb-ai attack <player name> - herobrine attacks the player");
player.sendMessage(ChatColor.GREEN+"/hb-ai haunt <player name> - herobrine haunts the player");
player.sendMessage(ChatColor.GREEN+"/hb-ai cancel - cancel herobrine´s actual target");
player.sendMessage(ChatColor.GREEN+"/hb-ai reload - reload config");
player.sendMessage(ChatColor.GREEN+"/hb-ai position - gets actual position of Herobrine");
player.sendMessage(ChatColor.GREEN+"/hb-ai pyramid <player name> - build pyramid near the player");
player.sendMessage(ChatColor.GREEN+"/hb-ai bury <player name> - bury player");
player.sendMessage(ChatColor.GREEN+"/hb-ai graveyard <player name> - teleport player to the Graveyard world");
player.sendMessage(ChatColor.GREEN+"/hb-ai temple <player name> - build temple near the player");
player.sendMessage(ChatColor.GREEN+"/hb-ai heads <player name> - place heads near the player");
player.sendMessage(ChatColor.GREEN+"/hb-ai cave <player name> - create cave near the player");
}else{player.sendMessage(ChatColor.RED+"You don´t have permissions to do that.");}
}else if (args[0].equalsIgnoreCase("position")){
if (player.hasPermission("hb-ai.position")){
player.sendMessage(ChatColor.RED+"[HerobrineAI] Position");
player.sendMessage(ChatColor.RED+"World: "+P_Core.HerobrineNPC.getBukkitEntity().getLocation().getWorld().getName()+" X: "+((int)P_Core.HerobrineNPC.getBukkitEntity().getLocation().getX())+
" Y: "+((int)P_Core.HerobrineNPC.getBukkitEntity().getLocation().getY())+" Z: "+((int)P_Core.HerobrineNPC.getBukkitEntity().getLocation().getZ()));
player.sendMessage(ChatColor.RED+"InWalkingMode: "+AICore.getStringWalkingMode());
player.sendMessage(ChatColor.RED+"Available World: "+HerobrineAI.getPluginCore().getAvailableWorldString());
}else{player.sendMessage(ChatColor.RED+"You don´t have permissions to do that.");}
}else{player.sendMessage(ChatColor.RED+"Usage: /hb-ai help");}
}else{player.sendMessage(ChatColor.RED+"Usage: /hb-ai help");}
}
return true;
}else{
// CONSOLE
if (args.length>0){
if (args[0].equalsIgnoreCase("attack")){
if (args.length>1){
if (Bukkit.getServer().getPlayer(args[1])!=null){
if (Bukkit.getServer().getPlayer(args[1]).isOnline()){
if (P_Core.getSupport().checkAttack(Bukkit.getServer().getPlayer(args[1]).getLocation())){
if (P_Core.canAttackPlayerConsole(Bukkit.getServer().getPlayer(args[1]))){
if (AICore.isTarget==false){
P_Core.getAICore().setAttackTarget(Bukkit.getServer().getPlayer(args[1]));
log.info("[HerobrineAI] Herobrine is now attacking the "+args[1]+"!");
}else{log.info("[HerobrineAI] Herobrine already has target! Use /hb-ai cancel to cancel actual target");}
}
}else{log.info("[HerobrineAI] Player is in secured area.");}
}else{log.info("[HerobrineAI] Player is offline.");}
}else{log.info("[HerobrineAI] Player is offline.");}
}else{log.info("Usage: /hb-ai attack <player name>");}
}else if (args[0].equalsIgnoreCase("pyramid")){
if (args.length>1){
if (Bukkit.getServer().getPlayer(args[1])!=null){
if (Bukkit.getServer().getPlayer(args[1]).isOnline()){
if (P_Core.getSupport().checkBuild(Bukkit.getServer().getPlayer(args[1]).getLocation())){
Object[] data = {Bukkit.getServer().getPlayer(args[1])};
if(P_Core.getAICore().getCore(CoreType.PYRAMID).RunCore(data).getResult()){
log.info("[HerobrineAI] Creating pyramind near "+args[1]+"!");
}else{log.info("[HerobrineAI] Cannot find good place for pyramid!");}
}else{log.info("[HerobrineAI] Player is in secure area.");}
}else{log.info("[HerobrineAI] Player is offline.");}
}else{log.info("[HerobrineAI] Player is offline.");}
}else{log.info("Usage: "+ChatColor.GREEN+"/hb-ai pyramid <player name>");}
}else if (args[0].equalsIgnoreCase("temple")){
if (args.length>1){
if (Bukkit.getServer().getPlayer(args[1])!=null){
if (Bukkit.getServer().getPlayer(args[1]).isOnline()){
if (P_Core.getSupport().checkBuild(Bukkit.getServer().getPlayer(args[1]).getLocation())){
Object[] data = {Bukkit.getServer().getPlayer(args[1])};
if(P_Core.getAICore().getCore(CoreType.TEMPLE).RunCore(data).getResult()){
log.info("[HerobrineAI] Creating temple near "+args[1]+"!");
}else{log.info("[HerobrineAI] Cannot find good place for temple!");}
}else{log.info("[HerobrineAI] Player is in secure area.");}
}else{log.info("[HerobrineAI] Player is offline.");}
}else{log.info("[HerobrineAI] Player is offline.");}
}else{log.info("Usage: "+ChatColor.GREEN+"/hb-ai temple <player name>");}
}else if (args[0].equalsIgnoreCase("bury")){
if (args.length>1){
if (Bukkit.getServer().getPlayer(args[1])!=null){
if (Bukkit.getServer().getPlayer(args[1]).isOnline()){
if (P_Core.getSupport().checkBuild(Bukkit.getServer().getPlayer(args[1]).getLocation())){
Object[] data = {Bukkit.getServer().getPlayer(args[1])};
if(P_Core.getAICore().getCore(CoreType.BURY_PLAYER).RunCore(data).getResult()){
log.info("[HerobrineAI] Buried "+args[1]+"!");
}else{log.info("[HerobrineAI] Cannot find good place!");}
}else{log.info("[HerobrineAI] Player is in secure area.");}
}else{log.info("[HerobrineAI] Player is offline.");}
}else{log.info("[HerobrineAI] Player is offline.");}
}else{log.info("Usage: /hb-ai bury <player name>");}
}else if (args[0].equalsIgnoreCase("cave")){
if (args.length>1){
if (Bukkit.getServer().getPlayer(args[1])!=null){
Object[] data = {Bukkit.getServer().getPlayer(args[1]).getLocation(),true};
log.info(ChatColor.RED+"[HerobrineAI] "+P_Core.getAICore().getCore(CoreType.BUILD_STUFF).RunCore(data).getResultString());
}else{log.info(ChatColor.RED+"[HerobrineAI] Player is offline.");}
}else{log.info("Usage: /hb-ai cave <player name>");}
}else if (args[0].equalsIgnoreCase("heads")){
if (args.length>1){
if (Bukkit.getServer().getPlayer(args[1])!=null){
Object[] data = {args[1]};
log.info("[HerobrineAI] "+P_Core.getAICore().getCore(CoreType.HEADS).RunCore(data).getResultString());
}else{log.info("[HerobrineAI] Player is offline.");}
}else{log.info("Usage: "+ChatColor.GREEN+"/hb-ai heads <player name>");}
}
else if (args[0].equalsIgnoreCase("graveyard")){
if (args.length>1){
if (Bukkit.getServer().getPlayer(args[1])!=null){
if (Bukkit.getServer().getPlayer(args[1]).isOnline()){
if (AICore.isTarget==false){
P_Core.getAICore().GraveyardTeleport(Bukkit.getServer().getPlayer(args[1]));
log.info("[HerobrineAI] "+args[1]+" is now in the Graveyard world!");
}else{log.info("[HerobrineAI] Herobrine already has target! Use "+ChatColor.GREEN+"/hb-ai cancel"+ChatColor.RED+" to cancel actual target");}
}else{log.info("[HerobrineAI] Player is offline.");}
}else{log.info("[HerobrineAI] Player is offline.");}
}else{log.info("Usage: /hb-ai graveyard <player name>");}
}else if (args[0].equalsIgnoreCase("haunt")){
if (args.length>1){
if (Bukkit.getServer().getPlayer(args[1])!=null){
if (Bukkit.getServer().getPlayer(args[1]).isOnline()){
if (P_Core.getSupport().checkHaunt(Bukkit.getServer().getPlayer(args[1]).getLocation())){
if (P_Core.canAttackPlayerConsole(Bukkit.getServer().getPlayer(args[1]))){
if (AICore.isTarget==false){
P_Core.getAICore().setHauntTarget(Bukkit.getServer().getPlayer(args[1]));
log.info("[HerobrineAI] Herobrine now haunts the "+args[1]+"!");
}else{log.info("[HerobrineAI] Herobrine already has target! Use /hb-ai cancel to cancel actual target.");}
}
}else{log.info("[HerobrineAI] Player is in secure area.");}
}else{log.info("[HerobrineAI] Player is offline.");}
}else{log.info("[HerobrineAI] Player is offline.");}
}else{log.info("Usage: /hb-ai haunt <player name>");}
}else if (args[0].equalsIgnoreCase("cancel")){
P_Core.getAICore().CancelTarget(CoreType.ANY);
log.info(ChatColor.RED+"[HerobrineAI] Target cancelled!");
}else if (args[0].equalsIgnoreCase("reload")){
P_Core.getConfigDB().Reload();
log.info("[HerobrineAI] Config reloaded!");
}else if (args[0].equalsIgnoreCase("help")){
log.info("[HerobrineAI] Command list");
log.info("/hb-ai help - shows all commands");
log.info("/hb-ai attack <player name> - herobrine attacks the player");
log.info("/hb-ai haunt <player name> - herobrine haunts the player");
log.info("/hb-ai cancel - cancel herobrine´s actual target");
log.info("/hb-ai reload - reload config");
log.info("/hb-ai position - gets actual position of Herobrine");
log.info("/hb-ai pyramid <player name> - build pyramid near the player");
log.info("/hb-ai bury <player name> - bury player");
log.info("/hb-ai graveyard <player name> - teleport player to the Graveyard world");
log.info("/hb-ai temple <player name> - build temple near the player");
log.info("/hb-ai heads <player name> - place heads near the player");
log.info("/hb-ai cave <player name> - create cave near the player");
}else if (args[0].equalsIgnoreCase("position")){
log.info("[HerobrineAI] Position");
log.info("World: "+P_Core.HerobrineNPC.getBukkitEntity().getLocation().getWorld().getName()+" X: "+((int)P_Core.HerobrineNPC.getBukkitEntity().getLocation().getX())+
" Y: "+((int)P_Core.HerobrineNPC.getBukkitEntity().getLocation().getY())+" Z: "+((int)P_Core.HerobrineNPC.getBukkitEntity().getLocation().getZ()));
log.info("InWalkingMode: "+AICore.getStringWalkingMode());
log.info("Available World: "+HerobrineAI.getPluginCore().getAvailableWorldString());
}else{log.info("Usage: /hb-ai help");}
}else{log.info("Usage: /hb-ai help");}
return true;
}
}
}

View File

@ -0,0 +1,8 @@
package org.jakub1221.herobrineai.entity;
public interface CustomEntity {
public void Kill();
public MobType getMobType();
}

View File

@ -0,0 +1,68 @@
package org.jakub1221.herobrineai.entity;
import org.bukkit.Location;
import net.minecraft.server.v1_5_R2.ItemStack;
import net.minecraft.server.v1_5_R2.World;
public class CustomZombie extends net.minecraft.server.v1_5_R2.EntityZombie implements CustomEntity{
private MobType mobType=null;
public CustomZombie(World world,Location loc,MobType mbt) {
super(world);
this.mobType=mbt;
if (mbt==MobType.ARTIFACT_GUARDIAN){
spawnArtifactGuardian(loc);
}else if (mbt==MobType.HEROBRINE_WARRIOR){
spawnHerobrineWarrior(loc);
}
}
private void spawnArtifactGuardian(Location loc){
this.health=50;
this.setCustomName("Artifact Guardian");
this.maxHealth=50;
this.setEquipment(0, new ItemStack(net.minecraft.server.v1_5_R2.Item.GOLD_SWORD));
this.setEquipment(1, new ItemStack(net.minecraft.server.v1_5_R2.Item.GOLD_BOOTS));
this.setEquipment(2, new ItemStack(net.minecraft.server.v1_5_R2.Item.GOLD_LEGGINGS));
this.setEquipment(3, new ItemStack(net.minecraft.server.v1_5_R2.Item.GOLD_CHESTPLATE));
this.setEquipment(4, new ItemStack(net.minecraft.server.v1_5_R2.Item.GOLD_HELMET));
this.getBukkitEntity().teleport(loc);
}
private void spawnHerobrineWarrior(Location loc){
this.health=25;
this.setCustomName("Herobrine´s Warrior");
this.maxHealth=25;
this.setEquipment(0, new ItemStack(net.minecraft.server.v1_5_R2.Item.IRON_SWORD));
this.setEquipment(1, new ItemStack(net.minecraft.server.v1_5_R2.Item.IRON_BOOTS));
this.setEquipment(2, new ItemStack(net.minecraft.server.v1_5_R2.Item.IRON_LEGGINGS));
this.setEquipment(3, new ItemStack(net.minecraft.server.v1_5_R2.Item.IRON_CHESTPLATE));
this.setEquipment(4, new ItemStack(net.minecraft.server.v1_5_R2.Item.IRON_HELMET));
this.getBukkitEntity().teleport(loc);
}
public CustomZombie(World world) {
super(world);
}
@Override
public void Kill() {
this.health=0;
}
@Override
public MobType getMobType() {
return this.mobType;
}
}

View File

@ -0,0 +1,46 @@
package org.jakub1221.herobrineai.entity;
import java.util.HashMap;
import java.util.Map;
import org.bukkit.Location;
import org.bukkit.World;
public class EntityManager {
private HashMap<Integer,CustomEntity> mobList = new HashMap<Integer,CustomEntity>();
public void spawnCustomZombie(Location loc,MobType mbt){
World world = loc.getWorld();
net.minecraft.server.v1_5_R2.World mcWorld = ((org.bukkit.craftbukkit.v1_5_R2.CraftWorld) world).getHandle();
CustomZombie zmb = new CustomZombie(mcWorld,loc,mbt);
mcWorld.addEntity(zmb);
mobList.put(new Integer(zmb.getBukkitEntity().getEntityId()),zmb);
}
public boolean isCustomMob(int id){
return mobList.containsKey(new Integer(id));
}
public CustomEntity getMobType(int id){
return mobList.get(new Integer(id));
}
public void removeMob(int id){
mobList.remove(new Integer(id));
}
public void removeAllMobs(){
mobList.clear();
}
public void killAllMobs(){
for(Map.Entry<Integer, CustomEntity> s : mobList.entrySet()){
s.getValue().Kill();
}
removeAllMobs();
}
}

View File

@ -0,0 +1,6 @@
package org.jakub1221.herobrineai.entity;
public enum MobType {
ARTIFACT_GUARDIAN,
HEROBRINE_WARRIOR;
}

View File

@ -0,0 +1,103 @@
package org.jakub1221.herobrineai.listeners;
import java.util.ArrayList;
import java.util.logging.Logger;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockIgniteEvent;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockPlaceEvent;
import org.jakub1221.herobrineai.AI.*;
import org.jakub1221.herobrineai.AI.Core.CoreType;
import org.jakub1221.herobrineai.AI.cores.Heads;
import org.jakub1221.herobrineai.HerobrineAI;
public class BlockListener implements Listener{
Logger log = Logger.getLogger("Minecraft");
@EventHandler
public void onBlockIgnite(BlockIgniteEvent event){
if (event.getBlock()!=null){
Block blockt = (Block) event.getBlock();
Location blockloc = (Location) blockt.getLocation();
if (event.getPlayer()!=null){
blockloc.setY(blockloc.getY()-1);
Block block = (Block) blockloc.getWorld().getBlockAt(blockloc);
if (block.getType() == Material.NETHERRACK){
if (block.getWorld().getBlockAt(blockloc.getBlockX(), blockloc.getBlockY()-1, blockloc.getBlockZ()).getType() == Material.NETHERRACK){
if (block.getWorld().getBlockAt(blockloc.getBlockX()-1, blockloc.getBlockY()-1, blockloc.getBlockZ()).getType() == Material.GOLD_BLOCK){
if (block.getWorld().getBlockAt(blockloc.getBlockX()-1, blockloc.getBlockY()-1, blockloc.getBlockZ()-1).getType() == Material.GOLD_BLOCK){
if (block.getWorld().getBlockAt(blockloc.getBlockX()-1, blockloc.getBlockY()-1, blockloc.getBlockZ()+1).getType() == Material.GOLD_BLOCK){
if (block.getWorld().getBlockAt(blockloc.getBlockX()+1, blockloc.getBlockY()-1, blockloc.getBlockZ()).getType() == Material.GOLD_BLOCK){
if (block.getWorld().getBlockAt(blockloc.getBlockX()+1, blockloc.getBlockY()-1, blockloc.getBlockZ()-1).getType() == Material.GOLD_BLOCK){
if (block.getWorld().getBlockAt(blockloc.getBlockX()+1, blockloc.getBlockY()-1, blockloc.getBlockZ()+1).getType() == Material.GOLD_BLOCK){
if (block.getWorld().getBlockAt(blockloc.getBlockX(), blockloc.getBlockY()-1, blockloc.getBlockZ()-1).getType() == Material.GOLD_BLOCK){
if (block.getWorld().getBlockAt(blockloc.getBlockX(), blockloc.getBlockY()-1, blockloc.getBlockZ()+1).getType() == Material.GOLD_BLOCK){
if (block.getWorld().getBlockAt(blockloc.getBlockX(), blockloc.getBlockY(), blockloc.getBlockZ()+1).getType() == Material.REDSTONE_TORCH_ON){
if (block.getWorld().getBlockAt(blockloc.getBlockX(), blockloc.getBlockY(), blockloc.getBlockZ()-1).getType() == Material.REDSTONE_TORCH_ON){
if (block.getWorld().getBlockAt(blockloc.getBlockX()+1, blockloc.getBlockY(), blockloc.getBlockZ()).getType() == Material.REDSTONE_TORCH_ON){
if (block.getWorld().getBlockAt(blockloc.getBlockX()-1, blockloc.getBlockY(), blockloc.getBlockZ()).getType() == Material.REDSTONE_TORCH_ON){
if (HerobrineAI.getPluginCore().getConfigDB().UseTotem==true && AICore.isTotemCalled==false){
HerobrineAI.getPluginCore().getAICore().PlayerCallTotem(event.getPlayer());
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
if (event.getBlock().getWorld()==Bukkit.getServer().getWorld("world_herobrineai_graveyard")){
event.setCancelled(true);
return;
}
}
@EventHandler
public void onBlockBreak(BlockBreakEvent event){
if (event.getBlock().getWorld()==Bukkit.getServer().getWorld("world_herobrineai_graveyard")){
event.setCancelled(true);
return;
}else{
Heads h = (Heads) HerobrineAI.getPluginCore().getAICore().getCore(CoreType.HEADS);
ArrayList<Block> list = h.getHeadList();
if (list.contains(event.getBlock())){
event.setCancelled(true);
return;
}
}
}
@EventHandler
public void onBlockPlace(BlockPlaceEvent event){
if (event.getBlock().getWorld()==Bukkit.getServer().getWorld("world_herobrineai_graveyard")){
event.setCancelled(true);
return;
}
}
}

View File

@ -0,0 +1,278 @@
package org.jakub1221.herobrineai.listeners;
import java.util.ArrayList;
import java.util.Random;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.entity.Arrow;
import org.bukkit.entity.CreatureType;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.entity.Projectile;
import org.bukkit.entity.Zombie;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.CreatureSpawnEvent;
import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.event.entity.EntityDamageByBlockEvent;
import org.bukkit.event.entity.EntityDeathEvent;
import org.bukkit.event.entity.ProjectileHitEvent;
import org.bukkit.inventory.ItemStack;
import org.jakub1221.herobrineai.HerobrineAI;
import org.jakub1221.herobrineai.AI.*;
import org.jakub1221.herobrineai.AI.Core.CoreType;
import org.jakub1221.herobrineai.entity.CustomZombie;
import org.jakub1221.herobrineai.entity.MobType;
import org.jakub1221.herobrineai.misc.ItemName;
import org.bukkit.event.entity.EntityTargetLivingEntityEvent;
public class EntityListener implements Listener{
private ItemStack itemInHand=null;
private ArrayList<String> equalsLore = new ArrayList<String>();
private ArrayList<String> equalsLoreS = new ArrayList<String>();
private ArrayList<String> getLore = new ArrayList<String>();
public EntityListener(){
equalsLore.add("Herobrine´s artifact");
equalsLore.add("Bow of Teleporting");
equalsLoreS.add("Herobrine´s artifact");
equalsLoreS.add("Sword of Lighting");
}
@EventHandler
public void onCreatureSpawn(CreatureSpawnEvent event){
if (HerobrineAI.getPluginCore().getConfigDB().UseNPC_Warrior){
if (new Random().nextInt(100)>95){
if (event.isCancelled()) return;
Location location = event.getLocation();
Entity entity = event.getEntity();
CreatureType creatureType = event.getCreatureType();
World world = location.getWorld();
net.minecraft.server.v1_5_R2.World mcWorld = ((org.bukkit.craftbukkit.v1_5_R2.CraftWorld) world).getHandle();
if (creatureType == CreatureType.ZOMBIE && HerobrineAI.getPluginCore().getEntityManager().isCustomMob(entity.getEntityId())==false){
LivingEntity ent = (LivingEntity) entity;
ent.setHealth(0);
HerobrineAI.getPluginCore().getEntityManager().spawnCustomZombie(event.getLocation(),MobType.HEROBRINE_WARRIOR);
return;
}
}
}
}
@EventHandler
public void onEntityDeathEvent(EntityDeathEvent event){
if (HerobrineAI.getPluginCore().getEntityManager().isCustomMob(event.getEntity().getEntityId())){
HerobrineAI.getPluginCore().getEntityManager().removeMob(event.getEntity().getEntityId());
}
}
@EventHandler
public void EntityTargetEvent(EntityTargetLivingEntityEvent e){
LivingEntity lv = e.getTarget();
if (lv.getEntityId()==HerobrineAI.HerobrineEntityID){
e.setCancelled(true);
return;
}
}
@EventHandler
public void onProjectileHit(ProjectileHitEvent event){
if (event.getEntity() instanceof Arrow){
Arrow arrow = (Arrow) event.getEntity();
if (arrow.getShooter() instanceof Player){
Player player = (Player) arrow.getShooter();
if (player.getItemInHand() != null){
itemInHand = player.getItemInHand();
if (itemInHand.getType()!=null){
if (itemInHand.getType() == Material.BOW){
getLore=ItemName.getLore(itemInHand);
if (getLore!=null){
if (getLore.containsAll(equalsLore)){
if (HerobrineAI.getPluginCore().getConfigDB().UseArtifactBow){
player.teleport(arrow.getLocation());
}
}
}
}
}
}
}
}
}
@EventHandler
public void onEntityDamageByBlock(EntityDamageByBlockEvent event){
if (event.getEntity().getEntityId() == HerobrineAI.HerobrineEntityID){
event.setCancelled(true);
event.setDamage(0);
return;
}
}
@SuppressWarnings("static-access")
@EventHandler
public void onEntityDamage(EntityDamageEvent event){
if (event.getEntity().getEntityId() == HerobrineAI.HerobrineEntityID){
if (event instanceof EntityDamageByEntityEvent){
EntityDamageByEntityEvent dEvent = (EntityDamageByEntityEvent) event;
if (HerobrineAI.getPluginCore().getConfigDB().Killable==true && HerobrineAI.getPluginCore().getAICore().getCoreTypeNow()!=CoreType.GRAVEYARD){
if (dEvent.getDamager() instanceof Player){
if (event.getDamage()>=HerobrineAI.HerobrineHP){
int i=1;
for(i=1;i<=2500;i++){
if (HerobrineAI.getPluginCore().getConfigDB().config.contains("config.Drops."+Integer.toString(i))==true){
Random randgen = new Random();
int chance=randgen.nextInt(100);
if (chance<=HerobrineAI.getPluginCore().getConfigDB().config.getInt("config.Drops."+Integer.toString(i)+".chance")){
HerobrineAI.HerobrineNPC.getBukkitEntity().getLocation().getWorld().dropItemNaturally(HerobrineAI.HerobrineNPC.getBukkitEntity().getLocation(), new ItemStack(Material.getMaterial(i),HerobrineAI.getPluginCore().getConfigDB().config.getInt("config.Drops."+Integer.toString(i)+".count")));
}
}
}
HerobrineAI.getPluginCore().getAICore().CancelTarget(CoreType.ANY);
HerobrineAI.HerobrineHP=HerobrineAI.HerobrineMaxHP;
Player player = (Player) dEvent.getDamager();
player.sendMessage("<Herobrine> "+HerobrineAI.getPluginCore().getConfigDB().DeathMessage);
}else{HerobrineAI.HerobrineHP-=event.getDamage();HerobrineAI.HerobrineNPC.HurtAnimation();AICore.log.info("HIT: "+event.getDamage());}
}else if(dEvent.getDamager() instanceof Projectile){
Arrow arrow = (Arrow) dEvent.getDamager();
if (arrow.getShooter() instanceof Player){
if (HerobrineAI.getPluginCore().getAICore().getCoreTypeNow() == CoreType.RANDOM_POSITION){
HerobrineAI.getPluginCore().getAICore().CancelTarget(CoreType.ANY);
HerobrineAI.getPluginCore().getAICore().setAttackTarget((Player) arrow.getShooter());
}else{
if (event.getDamage()>=HerobrineAI.HerobrineHP){
int i=1;
for(i=1;i<=2500;i++){
if (HerobrineAI.getPluginCore().getConfigDB().config.contains("config.Drops."+Integer.toString(i))==true){
Random randgen = new Random();
int chance=randgen.nextInt(100);
if (chance<=HerobrineAI.getPluginCore().getConfigDB().config.getInt("config.Drops."+Integer.toString(i)+".chance")){
HerobrineAI.HerobrineNPC.getBukkitEntity().getLocation().getWorld().dropItemNaturally(HerobrineAI.HerobrineNPC.getBukkitEntity().getLocation(), new ItemStack(Material.getMaterial(i),HerobrineAI.getPluginCore().getConfigDB().config.getInt("config.Drops."+Integer.toString(i)+".count")));
}
}
}
HerobrineAI.getPluginCore().getAICore().CancelTarget(CoreType.ANY);
HerobrineAI.HerobrineHP=HerobrineAI.HerobrineMaxHP;
Player player = (Player) arrow.getShooter();
player.sendMessage("<Herobrine> "+HerobrineAI.getPluginCore().getConfigDB().DeathMessage);
}else{HerobrineAI.HerobrineHP-=event.getDamage();HerobrineAI.HerobrineNPC.HurtAnimation();AICore.log.info("HIT: "+event.getDamage());}
}
}else{if (HerobrineAI.getPluginCore().getAICore().getCoreTypeNow() == CoreType.RANDOM_POSITION){
Location newloc = (Location) HerobrineAI.HerobrineNPC.getBukkitEntity().getLocation();
newloc.setY(-20);
HerobrineAI.HerobrineNPC.moveTo(newloc);
HerobrineAI.getPluginCore().getAICore().CancelTarget(CoreType.ANY);
}}
}else{
if (HerobrineAI.getPluginCore().getAICore().getCoreTypeNow() == CoreType.RANDOM_POSITION){
Location newloc = (Location) HerobrineAI.HerobrineNPC.getBukkitEntity().getLocation();
newloc.setY(-20);
HerobrineAI.HerobrineNPC.moveTo(newloc);
HerobrineAI.getPluginCore().getAICore().CancelTarget(CoreType.ANY);
}
}
}
}
event.setCancelled(true);
event.setDamage(0);
return;
}else{
if (event instanceof EntityDamageByEntityEvent){
EntityDamageByEntityEvent dEvent = (EntityDamageByEntityEvent) event;
if (dEvent.getDamager() instanceof Player){
Player player = (Player) dEvent.getDamager();
if (player.getItemInHand() != null){
if (player.getItemInHand().getType() == Material.DIAMOND_SWORD){
if (ItemName.getLore(player.getItemInHand())!=null){
itemInHand = player.getItemInHand();
getLore=ItemName.getLore(itemInHand);
if (getLore.containsAll(equalsLoreS)){
if (HerobrineAI.getPluginCore().getConfigDB().UseArtifactSword){
if (new Random().nextBoolean()){
player.getLocation().getWorld().strikeLightning(event.getEntity().getLocation());
}
}
}
}
}
}
}else if (dEvent.getDamager() instanceof Zombie){
Zombie zmb = (Zombie) dEvent.getDamager();
if (zmb.getCustomName()=="Artifact Guardian" || zmb.getCustomName()=="Herobrine´s Warrior"){
dEvent.setDamage(dEvent.getDamage()*3);
HerobrineAI.getPluginCore().log.info("GHf");
}
}
}
if (event.getCause()!=null){
if (event.getCause() == DamageCause.LIGHTNING){
if (event.getEntity() instanceof Player){
if (event.getEntity().getEntityId()!=HerobrineAI.HerobrineEntityID){
Player player = (Player) event.getEntity();
if (player.getItemInHand() != null){
if (player.getItemInHand().getType() == Material.DIAMOND_SWORD){
if (ItemName.getLore(player.getItemInHand())!=null){
itemInHand = player.getItemInHand();
getLore=ItemName.getLore(itemInHand);
if (getLore.containsAll(equalsLoreS)){
if (HerobrineAI.getPluginCore().getConfigDB().UseArtifactSword){
event.setDamage(0);
event.setCancelled(true);
return;
}
}
}
}
}
}
}
}
}
}
}
}

View File

@ -0,0 +1,54 @@
package org.jakub1221.herobrineai.listeners;
import java.util.Random;
import java.util.logging.Logger;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.inventory.InventoryCloseEvent;
import org.bukkit.event.inventory.InventoryOpenEvent;
import org.bukkit.event.inventory.InventoryType;
import org.jakub1221.herobrineai.AI.Core.CoreType;
import org.jakub1221.herobrineai.HerobrineAI;
import org.jakub1221.herobrineai.misc.ItemName;
public class InventoryListener implements Listener{
Logger log = Logger.getLogger("Minecraft");
@EventHandler
public void onInventoryClose(InventoryCloseEvent event){
if (event.getInventory().getType() == InventoryType.CHEST){
Object[] data = {event.getPlayer(),event.getInventory()};
HerobrineAI.getPluginCore().getAICore().getCore(CoreType.BOOK).RunCore(data);
if (new Random().nextInt(100)>97){
if (HerobrineAI.getPluginCore().getConfigDB().UseHeads){
if (event.getInventory().firstEmpty()!=-1){
event.getInventory().setItem(event.getInventory().firstEmpty(),ItemName.CreateSkull(event.getPlayer().getName()));
}
}
}
}
}
@EventHandler
public void onInventoryOpen(InventoryOpenEvent event){
if (event.getInventory().getType() == InventoryType.CHEST || event.getInventory().getType() == InventoryType.FURNACE || event.getInventory().getType() == InventoryType.WORKBENCH){
if (HerobrineAI.getPluginCore().getConfigDB().useWorlds.contains(event.getPlayer().getLocation().getWorld().getName())){
if (HerobrineAI.getPluginCore().getConfigDB().PlaceSigns==true && HerobrineAI.getPluginCore().getSupport().checkSigns(event.getPlayer().getLocation())){
Object[] data = {event.getPlayer().getLocation(),event.getPlayer().getLocation()};
HerobrineAI.getPluginCore().getAICore().getCore(CoreType.SIGNS).RunCore(data);
}
}
}
}
}

View File

@ -0,0 +1,202 @@
package org.jakub1221.herobrineai.listeners;
import java.util.ArrayList;
import java.util.Random;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.Jukebox;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.EventHandler;
import org.bukkit.event.block.Action;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerKickEvent;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.event.player.PlayerTeleportEvent;
import org.bukkit.inventory.ItemStack;
import org.jakub1221.herobrineai.HerobrineAI;
import org.jakub1221.herobrineai.AI.AICore;
import org.jakub1221.herobrineai.AI.Core.CoreType;
import org.jakub1221.herobrineai.misc.ItemName;
public class PlayerListener implements Listener{
private ItemStack itemInHand=null;
private ArrayList<String> equalsLoreS = new ArrayList<String>();
private ArrayList<String> equalsLoreA = new ArrayList<String>();
private ArrayList<String> getLore = new ArrayList<String>();
private ArrayList<LivingEntity> LivingEntities = new ArrayList<LivingEntity>();
private Location le_loc = null;
private Location p_loc = null;
private long timestamp = 0;
private boolean canUse = false;
public PlayerListener(){
equalsLoreS.add("Herobrine´s artifact");
equalsLoreS.add("Sword of Lighting");
equalsLoreA.add("Herobrine´s artifact");
equalsLoreA.add("Apple of Death");
}
@EventHandler
public void onPlayerInteract(PlayerInteractEvent event){
if (event.getAction() == Action.LEFT_CLICK_BLOCK || event.getAction() == Action.RIGHT_CLICK_BLOCK){
if (event.getClickedBlock()!=null && event.getPlayer().getItemInHand()!=null){
ItemStack itemInHand = event.getPlayer().getItemInHand();
if (event.getPlayer().getItemInHand().getType()!=null){
if (itemInHand.getType() == Material.DIAMOND_SWORD || itemInHand.getType() == Material.GOLDEN_APPLE){
if (ItemName.getLore(itemInHand)!=null){
if (ItemName.getLore(itemInHand).containsAll(equalsLoreS) && HerobrineAI.getPluginCore().getConfigDB().UseArtifactSword){
if (new Random().nextBoolean()){
event.getPlayer().getLocation().getWorld().strikeLightning(event.getClickedBlock().getLocation());
}
}else if (ItemName.getLore(itemInHand).containsAll(equalsLoreA) && HerobrineAI.getPluginCore().getConfigDB().UseArtifactApple){
timestamp = System.currentTimeMillis() / 1000;
canUse=false;
if (HerobrineAI.getPluginCore().PlayerApple.containsKey(event.getPlayer())){
if (HerobrineAI.getPluginCore().PlayerApple.get(event.getPlayer()) < timestamp){
HerobrineAI.getPluginCore().PlayerApple.remove(event.getPlayer());
canUse=true;
}else{canUse=false;}
}else{canUse=true;}
if (canUse==true){
event.getPlayer().getWorld().createExplosion(event.getPlayer().getLocation(), 0F);
LivingEntities = (ArrayList<LivingEntity>) event.getPlayer().getLocation().getWorld().getLivingEntities();
HerobrineAI.getPluginCore().PlayerApple.put(event.getPlayer(), timestamp+60);
for (int i=0;i<=LivingEntities.size()-1;i++){
if (LivingEntities.get(i) instanceof Player || LivingEntities.get(i).getEntityId() == HerobrineAI.HerobrineEntityID){}else{
le_loc=LivingEntities.get(i).getLocation();
p_loc=event.getPlayer().getLocation();
if (le_loc.getBlockX() < p_loc.getBlockX()+20 && le_loc.getBlockX() > p_loc.getBlockX()-20){
if (le_loc.getBlockY() < p_loc.getBlockY()+10 && le_loc.getBlockY() > p_loc.getBlockY()-10){
if (le_loc.getBlockZ() < p_loc.getBlockZ()+20 && le_loc.getBlockZ() > p_loc.getBlockZ()-20){
event.getPlayer().getWorld().createExplosion(LivingEntities.get(i).getLocation(), 0F);
LivingEntities.get(i).damage(10000);
}
}
}
}
}
}else{
event.getPlayer().sendMessage(ChatColor.RED+"Apple of Death is recharging!");
}
}
}
}
}
}
}
if (event.getClickedBlock()!=null){
if (event.getPlayer().getItemInHand()!=null){
if (event.getClickedBlock().getType()==Material.JUKEBOX){
ItemStack item = event.getPlayer().getItemInHand();
Jukebox block = (Jukebox) event.getClickedBlock().getState();
if (!block.isPlaying()){
if (item.getType()==Material.getMaterial(2266)){
if (!HerobrineAI.getPluginCore().getAICore().isDiscCalled){
final Player player = event.getPlayer();
HerobrineAI.getPluginCore().getAICore().isDiscCalled=true;
HerobrineAI.getPluginCore().getAICore().CancelTarget(CoreType.ANY);
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(AICore.plugin, new Runnable() {
public void run() {
HerobrineAI.getPluginCore().getAICore().callByDisc(player);
}
}, 1 * 50L);
}
}
}
}
}
}
}
@EventHandler(priority = EventPriority.HIGHEST)
public void onPlayerQuit(PlayerQuitEvent event){
if(event.getPlayer().getEntityId()!=HerobrineAI.HerobrineEntityID){
if (HerobrineAI.getPluginCore().getAICore().PlayerTarget==event.getPlayer() && HerobrineAI.getPluginCore().getAICore().getCoreTypeNow() == CoreType.GRAVEYARD && event.getPlayer().getLocation().getWorld()==Bukkit.getServer().getWorld("world_herobrineai_graveyard") && HerobrineAI.getPluginCore().getAICore().isTarget){
if (new Random().nextBoolean()){
event.getPlayer().teleport( HerobrineAI.getPluginCore().getAICore().getGraveyard().getSavedLocation());
}
}
}
}
@EventHandler(priority = EventPriority.HIGHEST)
public void onPlayerKick(PlayerKickEvent event){
if (event.getPlayer().getEntityId()==HerobrineAI.HerobrineEntityID){
event.setCancelled(true);
return;
}
}
@EventHandler(priority = EventPriority.HIGHEST)
public void onPlayerTeleport(PlayerTeleportEvent event){
if(event.getPlayer().getEntityId()==HerobrineAI.HerobrineEntityID){
if (event.getFrom().getWorld()!=event.getTo().getWorld()){
HerobrineAI.getPluginCore().HerobrineRemove();
HerobrineAI.getPluginCore().HerobrineSpawn(event.getTo());
event.setCancelled(true);
return;
}
if (HerobrineAI.getPluginCore().getAICore().getCoreTypeNow() == CoreType.RANDOM_POSITION){
if (HerobrineAI.HerobrineNPC.getEntity().getBukkitEntity().getLocation().getBlockX() > HerobrineAI.getPluginCore().getConfigDB().WalkingModeXRadius){
if (HerobrineAI.HerobrineNPC.getEntity().getBukkitEntity().getLocation().getBlockX() < (-HerobrineAI.getPluginCore().getConfigDB().WalkingModeXRadius)){
if (HerobrineAI.HerobrineNPC.getEntity().getBukkitEntity().getLocation().getBlockZ() > HerobrineAI.getPluginCore().getConfigDB().WalkingModeZRadius){
if (HerobrineAI.HerobrineNPC.getEntity().getBukkitEntity().getLocation().getBlockZ() < (-HerobrineAI.getPluginCore().getConfigDB().WalkingModeZRadius)){
HerobrineAI.getPluginCore().getAICore().CancelTarget(CoreType.RANDOM_POSITION);
HerobrineAI.HerobrineNPC.moveTo(new Location(Bukkit.getServer().getWorlds().get(0),0,-20,0));
}
}
}
}
}
}
}
@EventHandler
public void onPlayerDeathEvent(PlayerDeathEvent event){
if (event.getEntity().getEntityId() == HerobrineAI.HerobrineEntityID){
event.setDeathMessage("");
HerobrineAI.getPluginCore().HerobrineRemove();
Location nowloc = new Location((World) Bukkit.getServer().getWorlds().get(0),(float) 0,(float) -20,(float) 0);
nowloc.setYaw((float) 1);
nowloc.setPitch((float) 1);
HerobrineAI.getPluginCore().HerobrineSpawn(nowloc);
}
}
@EventHandler
public void onPlayerMoveEvent(PlayerMoveEvent event){
if (event.getPlayer().getEntityId()!=HerobrineAI.HerobrineEntityID){
if (event.getPlayer().getWorld()==Bukkit.getServer().getWorld("world_herobrineai_graveyard")){
Player player = (Player) event.getPlayer();
player.teleport(new Location(Bukkit.getServer().getWorld("world_herobrineai_graveyard"),-2.49,4,10.69,(float)-179.85,(float) 0.44999));
}
}
}
}

View File

@ -0,0 +1,45 @@
package org.jakub1221.herobrineai.listeners;
import java.util.Random;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.world.ChunkLoadEvent;
import org.jakub1221.herobrineai.HerobrineAI;
import org.jakub1221.herobrineai.AI.Core.CoreType;
public class WorldListener implements Listener{
@EventHandler
public void onChunkLoad(ChunkLoadEvent event){
if (event.isNewChunk()){
World world = event.getWorld();
if (HerobrineAI.getPluginCore().getConfigDB().useWorlds.contains(world.getName())){
if (HerobrineAI.getPluginCore().getConfigDB().BuildTemples==true){
if (new Random().nextInt(2)==1){
Object[] data = {event.getChunk()};
HerobrineAI.getPluginCore().getAICore().getCore(CoreType.TEMPLE).RunCore(data);
}
}
if (HerobrineAI.getPluginCore().getConfigDB().BuildPyramids==true){
if (new Random().nextInt(15)==1){
Object[] data = {event.getChunk()};
HerobrineAI.getPluginCore().getAICore().getCore(CoreType.PYRAMID).RunCore(data);
}
}
}
}
}
}

View File

@ -0,0 +1,70 @@
package org.jakub1221.herobrineai.misc;
import java.util.Random;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.SkullType;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.block.Skull;
public class BlockChanger {
public static BlockFace getPlayerBlockFace(Location loc)
{
BlockFace dir = null;
float y = loc.getYaw();
if( y < 0 ){y += 360;}
y %= 360;
int i = (int)((y+8) / 22.5);
switch(i){
case 0: dir = BlockFace.WEST; break;
case 1: dir = BlockFace.WEST_NORTH_WEST; break;
case 2: dir = BlockFace.NORTH_WEST; break;
case 3: dir = BlockFace.NORTH_NORTH_WEST; break;
case 4: dir = BlockFace.NORTH; break;
case 5: dir = BlockFace.NORTH_NORTH_EAST; break;
case 6: dir = BlockFace.NORTH_EAST; break;
case 7: dir = BlockFace.EAST_NORTH_EAST; break;
case 8: dir = BlockFace.EAST; break;
case 9: dir = BlockFace.EAST_SOUTH_EAST; break;
case 10: dir = BlockFace.SOUTH_EAST; break;
case 11: dir = BlockFace.SOUTH_SOUTH_EAST; break;
case 12: dir = BlockFace.SOUTH; break;
case 13: dir = BlockFace.SOUTH_SOUTH_WEST; break;
case 14: dir = BlockFace.SOUTH_WEST; break;
case 15: dir = BlockFace.WEST_SOUTH_WEST; break;
default: dir = BlockFace.WEST; break;
}
return dir;
}
public static void PlaceSkull(Location loc, String name){
int chance = new Random().nextInt(7);
Block b = loc.getBlock();
b.setType(Material.SKULL);
Skull skull = (Skull)b.getState();
skull.setSkullType(SkullType.PLAYER);
skull.setOwner(name);
BlockFace bface = BlockFace.EAST;
if (chance==0){bface=BlockFace.WEST;}
else if (chance==1){bface=BlockFace.EAST;}
else if (chance==2){bface=BlockFace.SOUTH;}
else if (chance==3){bface=BlockFace.NORTH;}
skull.setRawData((byte) bface.ordinal());
skull.update(true);
}
}

View File

@ -0,0 +1,63 @@
package org.jakub1221.herobrineai.misc;
import org.bukkit.inventory.ItemStack;
public class CustomID {
private int ID;
private int DATA;
public CustomID(String _data){
if (_data!=null){
if (!_data.equals("0")){
if (_data!=null && _data.length()>0){
String[] both = _data.split(":");
ID=Integer.parseInt(both[0]);
if (both.length>1){
DATA=Integer.parseInt(both[1]);
}else{
DATA=0;
}
}else{
ID=0;
DATA=0;
}
}else{
ID=0;
DATA=0;
}
}else{
ID=0;
DATA=0;
}
}
public int getID(){
return ID;
}
public int getDATA(){
return DATA;
}
public boolean isData(){
if (DATA>0){
return true;
}
return false;
}
public ItemStack getItemStack(){
ItemStack item = null;
if (ID!=0){
if (DATA>0){
item = new ItemStack(ID,1,(byte) DATA);
}else{
item = new ItemStack(ID);
}
}
return item;
}
}

View File

@ -0,0 +1,58 @@
package org.jakub1221.herobrineai.misc;
import java.util.ArrayList;
import java.util.Random;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.SkullType;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.block.Skull;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.inventory.meta.SkullMeta;
public class ItemName {
public static ItemMeta meta=null;
public static SkullMeta skullmeta=null;
public static ItemStack setName(ItemStack item, String name){
meta=item.getItemMeta();
meta.setDisplayName(name);
item.setItemMeta(meta);
return item;
}
public static ItemStack setLore(ItemStack item, ArrayList<String> lore){
meta=item.getItemMeta();
meta.setLore(lore);
item.setItemMeta(meta);
return item;
}
public static ItemStack setNameAndLore(ItemStack item, String name,ArrayList<String> lore){
meta=item.getItemMeta();
meta.setDisplayName(name);
meta.setLore(lore);
item.setItemMeta(meta);
return item;
}
public static ArrayList<String> getLore(ItemStack item){
return (ArrayList<String>) item.getItemMeta().getLore();
}
public static String getName(ItemStack item){
return item.getItemMeta().getDisplayName();
}
public static ItemStack CreateSkull(String data){
ItemStack skull = new ItemStack(Material.SKULL_ITEM, 1, (short)SkullType.PLAYER.ordinal());
SkullMeta skullmeta = (SkullMeta)skull.getItemMeta();
skullmeta.setOwner(data);
skullmeta.setDisplayName(ChatColor.RESET+data);
skull.setItemMeta(skullmeta);
return skull;
}
}

View File

@ -0,0 +1,47 @@
package org.jakub1221.herobrineai.misc;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import org.bukkit.World;
import org.bukkit.configuration.InvalidConfigurationException;
import org.bukkit.configuration.file.YamlConfiguration;
public class StructureLoader {
private int current=0;
private int length=0;
private InputStream inp;
private YamlConfiguration file;
public StructureLoader(InputStream in){
inp=in;
file = new YamlConfiguration();
try {
file.load(inp);
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} catch (InvalidConfigurationException e) {
e.printStackTrace();
}
}
public void Build(World world,int MainX,int MainY,int MainZ){
length=file.getInt("DATA.LENGTH")-1;
for (current=0;current<=length;current++){
world.getBlockAt(MainX+file.getInt("DATA."+current+".X"), MainY+file.getInt("DATA."+current+".Y"), MainZ+file.getInt("DATA."+current+".Z")).setTypeIdAndData(+file.getInt("DATA."+current+".ID"),(byte) +file.getInt("DATA."+current+".DATA"),false);
}
}
}

View File

@ -0,0 +1,32 @@
package org.jakub1221.herobrineai.support;
import org.bukkit.Bukkit;
import org.bukkit.inventory.ItemStack;
import org.jakub1221.customitems.API;
import org.jakub1221.customitems.CustomItems;
public class _CustomItems {
private CustomItems ci=null;
private API api=null;
public void init(){
ci = (CustomItems) Bukkit.getServer().getPluginManager().getPlugin("CustomItems");
api = ci.getAPI();
}
public boolean Check(){
return (Bukkit.getServer().getPluginManager().getPlugin("CustomItems")!=null);
}
public boolean checkItem(String name){
if (ci!=null){
return api.itemExist(name);
}
return false;
}
public ItemStack getItem(String name){
return api.createItem(name);
}
}

View File

@ -0,0 +1,19 @@
package org.jakub1221.herobrineai.support;
import me.ryanhamshire.GriefPrevention.Claim;
import me.ryanhamshire.GriefPrevention.GriefPrevention;
import org.bukkit.Bukkit;
import org.bukkit.Location;
public class _GriefPrevention {
public boolean Check(){
return (Bukkit.getServer().getPluginManager().getPlugin("GriefPrevention")!=null);
}
public boolean isSecuredArea(Location loc){
GriefPrevention griefprevention = (GriefPrevention) Bukkit.getServer().getPluginManager().getPlugin("GriefPrevention");
Claim claim = griefprevention.instance.dataStore.getClaimAt(loc, false, null);
return (claim!=null);
}
}

View File

@ -0,0 +1,20 @@
package org.jakub1221.herobrineai.support;
import net.sacredlabyrinth.Phaed.PreciousStones.FieldFlag;
import net.sacredlabyrinth.Phaed.PreciousStones.PreciousStones;
import org.bukkit.Bukkit;
import org.bukkit.Location;
public class _PreciousStones {
public boolean Check(){
return (Bukkit.getServer().getPluginManager().getPlugin("PreciousStones")!=null);
}
public boolean isSecuredArea(Location loc){
PreciousStones preciousStones = (PreciousStones) Bukkit.getServer().getPluginManager().getPlugin("PreciousStones");
return preciousStones.API().isFieldProtectingArea(FieldFlag.ALL, loc);
}
}

View File

@ -0,0 +1,21 @@
package org.jakub1221.herobrineai.support;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import com.bekvon.bukkit.residence.Residence;
import com.bekvon.bukkit.residence.protection.ClaimedResidence;
public class _Residence {
public boolean Check(){
return (Bukkit.getServer().getPluginManager().getPlugin("Residence")!=null);
}
public boolean isSecuredArea(Location loc){
Residence residence = (Residence) Bukkit.getServer().getPluginManager().getPlugin("Residence");
ClaimedResidence res = residence.getResidenceManager().getByLoc(loc);
return (res!=null);
}
}

View File

@ -0,0 +1,22 @@
package org.jakub1221.herobrineai.support;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.jakub1221.customitems.API;
import org.jakub1221.customitems.CustomItems;
import com.palmergames.bukkit.towny.Towny;
import com.palmergames.bukkit.towny.object.TownBlock;
public class _Towny {
public boolean Check(){
return (Bukkit.getServer().getPluginManager().getPlugin("Towny")!=null);
}
public boolean isSecuredArea(Location loc){
Towny towny = (Towny) Bukkit.getServer().getPluginManager().getPlugin("Towny");
TownBlock block = towny.getTownyUniverse().getTownBlock(loc);
return (block!=null);
}
}

View File

@ -0,0 +1,35 @@
package org.jakub1221.herobrineai.support;
import java.util.Map;
import java.util.Map.Entry;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
import com.sk89q.worldguard.protection.managers.RegionManager;
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
public class _WorldGuard {
public boolean Check(){
return (Bukkit.getServer().getPluginManager().getPlugin("WorldGuard")!=null);
}
public boolean isSecuredArea(Location loc){
WorldGuardPlugin worldGuard = (WorldGuardPlugin) Bukkit.getServer().getPluginManager().getPlugin("WorldGuard");
RegionManager rm = worldGuard.getRegionManager(loc.getWorld());
if (rm!=null){
Map<String, ProtectedRegion> mp = rm.getRegions();
if (mp!=null){
for(Entry<String, ProtectedRegion> s : mp.entrySet()){
if (s.getValue().contains(loc.getBlockX(),loc.getBlockY(),loc.getBlockZ())){
return true;
}
}
}
}
return false;
}
}