Code cleanup

This commit is contained in:
jakub1221 2017-02-04 14:58:50 +01:00
parent c1d6286bc1
commit 3e6fa271e9
58 changed files with 4932 additions and 3846 deletions

BIN
lib/Factions.jar Normal file

Binary file not shown.

Binary file not shown.

View File

@ -1,6 +1,6 @@
name: HerobrineAI
main: org.jakub1221.herobrineai.HerobrineAI
version: 3.1.0
version: 3.2.2
commands:
hb-ai:
description: Main command.

91
pom.xml Normal file
View File

@ -0,0 +1,91 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.jakub1221.herobrineai</groupId>
<artifactId>HerobrineAI</artifactId>
<version>3.5.0</version>
<name>HerobrineAI</name>
<url>http://dev.bukkit.org/projects/herobrine-ai</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<bukkitVersion>1.11-R0.1-SNAPSHOT</bukkitVersion>
</properties>
<scm>
<url>https://github.com/jakub1221/HerobrineAI</url>
<connection>scm:git:git://github.com:jakub1221/HerobrineAI.git</connection>
<developerConnection>scm:git:git@github.com:jakub1221/HerobrineAI.git</developerConnection>
</scm>
<issueManagement>
<system>GitHub</system>
<url>https://github.com/jakub1221/HerobrineAI/issues</url>
</issueManagement>
<repositories>
<repository>
<id>spigot-repo</id>
<url>https://hub.spigotmc.org/nexus/content/groups/public/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.bukkit</groupId>
<artifactId>bukkit</artifactId>
<version>${bukkitVersion}</version>
<type>jar</type>
</dependency>
<!-- Test Dependency -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<type>jar</type>
<scope>test</scope>
<optional>true</optional>
</dependency>
</dependencies>
<build>
<defaultGoal>clean install</defaultGoal>
<sourceDirectory>src/</sourceDirectory>
<resources>
<resource>
<directory>${project.basedir}</directory>
<filtering>true</filtering>
<includes>
<include>plugin.yml</include>
</includes>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.0.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.3</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<description>
HerobrineAI is Minecraft server plugin for bukkit/spigot that brings Herobrine to life.
</description>
</project>

File diff suppressed because it is too large Load Diff

View File

@ -6,11 +6,13 @@ public abstract class Core {
private final AppearType Appear;
private final CoreType coreType;
private CoreResult nowData=null;
private CoreResult nowData = null;
protected HerobrineAI PluginCore = null;
public Core(CoreType cp,AppearType ap){
public Core(CoreType cp,AppearType ap, HerobrineAI hb){
this.coreType=cp;
this.Appear=ap;
this.PluginCore = hb;
}
public AppearType getAppear(){
@ -21,7 +23,7 @@ public abstract class Core {
return coreType;
}
public abstract CoreResult CallCore(Object[] data);
protected abstract CoreResult CallCore(Object[] data);
public CoreResult RunCore(Object[] data){
@ -53,7 +55,8 @@ public abstract class Core {
RANDOM_SOUND,
RANDOM_EXPLOSION,
BURN,
CURSE;
CURSE,
STARE;
}
public enum AppearType{

View File

@ -4,15 +4,17 @@ public class CoreResult {
private final boolean bo;
private final String text;
public CoreResult(boolean b,String t){
this.bo=b;
this.text=t;
public CoreResult(boolean b, String t) {
this.bo = b;
this.text = t;
}
public boolean getResult(){
public boolean getResult() {
return this.bo;
}
public String getResultString(){
public String getResultString() {
return this.text;
}
}

View File

@ -6,19 +6,18 @@ 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){
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));
Random randgen = new Random();
int randmsg = randgen.nextInt(count);
player.sendMessage("<Herobrine> " + HerobrineAI.getPluginCore().getConfigDB().useMessages.get(randmsg));
}
}
}
}

View File

@ -0,0 +1,72 @@
package org.jakub1221.herobrineai.AI;
import org.bukkit.Bukkit;
import org.jakub1221.herobrineai.HerobrineAI;
public class ResetLimits {
private int taskID = 0;
private int books = 0;
private int signs = 0;
private int heads = 0;
public int maxBooks = 1;
public int maxSigns = 1;
public int maxHeads = 1;
public ResetLimits() {
taskID = Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(HerobrineAI.getPluginCore(),
new Runnable() {
public void run() {
resetAll();
}
}, 1 * 72000L, 1 * 72000L);
}
public void disable() {
Bukkit.getServer().getScheduler().cancelTask(taskID);
}
public boolean isBook() {
if (books < maxBooks) {
books++;
return true;
}
return false;
}
public boolean isSign() {
if (signs < maxSigns) {
signs++;
return true;
}
return false;
}
public boolean isHead() {
if (heads < maxHeads) {
heads++;
return true;
}
return false;
}
public void resetAll() {
books = 0;
signs = 0;
heads = 0;
}
public void updateFromConfig() {
maxBooks = HerobrineAI.getPluginCore().getConfigDB().maxBooks;
maxSigns = HerobrineAI.getPluginCore().getConfigDB().maxSigns;
maxHeads = HerobrineAI.getPluginCore().getConfigDB().maxHeads;
}
}

View File

@ -11,230 +11,223 @@ import org.bukkit.entity.Player;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import org.jakub1221.herobrineai.HerobrineAI;
import org.jakub1221.herobrineai.Utils;
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{
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]);
private int HandlerINT = 0;
private boolean isHandler = false;
public Attack() {
super(CoreType.ATTACK, AppearType.APPEAR, HerobrineAI.getPluginCore());
}
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.");
public CoreResult CallCore(Object[] data) {
return setAttackTarget((Player) data[0]);
}
}else{
return new CoreResult(false,"Player has Ancient Sword.");
}
}
public void StopHandler(){
if (isHandler){
Bukkit.getScheduler().cancelTask(HandlerINT);
isHandler=false;
public CoreResult setAttackTarget(Player player) {
if (!PluginCore.getAICore().checkAncientSword(player.getInventory())) {
if (PluginCore.getSupport().checkAttack(player.getLocation())) {
if (!PluginCore.canAttackPlayerNoMSG(player)) {
return new CoreResult(false, "This player is protected.");
}
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 };
PluginCore.getAICore().getCore(CoreType.DESTROY_TORCHES).RunCore(data);
if (PluginCore.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 StartHandler(){
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);
isHandler = true;
HandlerINT = Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(AICore.plugin, new Runnable() {
public void run() {
Handler();
}
}, 1 * 5L, 1 * 5L);
}
private void Handler(){
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){
if (ticksToEnd == 1 || ticksToEnd % 16 == 0)
FollowHideRepeat();
}
public void KeepLooking() {
if (AICore.PlayerTarget.isOnline() && AICore.isTarget
&& PluginCore.getAICore().getCoreTypeNow() == CoreType.ATTACK) {
if (AICore.PlayerTarget.isDead() == false) {
if (ticksToEnd == 160) {
PluginCore.getAICore().CancelTarget(CoreType.ATTACK);
} else {
ticksToEnd++;
Location ploc = (Location) AICore.PlayerTarget.getLocation();
ploc.setY(ploc.getY() + 1.5);
HerobrineAI.HerobrineNPC.lookAtPoint(ploc);
if (PluginCore.getConfigDB().Lighting == true) {
int lchance = Utils.getRandomGen().nextInt(100);
if (lchance > 75) {
Location newloc = (Location) ploc;
int randx = Utils.getRandomGen().nextInt(50);
int randz = Utils.getRandomGen().nextInt(50);
if (Utils.getRandomGen().nextBoolean()) {
newloc.setX(newloc.getX() + randx);
} else {
newloc.setX(newloc.getX() - randx);
}
if (Utils.getRandomGen().nextBoolean()) {
newloc.setZ(newloc.getZ() + randz);
} else {
newloc.setZ(newloc.getZ() - randz);
}
newloc.setY(250);
newloc.getWorld().strikeLightning(newloc);
}
}
}
} else {
PluginCore.getAICore().CancelTarget(CoreType.ATTACK);
}
} else {
PluginCore.getAICore().CancelTarget(CoreType.ATTACK);
}
}
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){
int lchance= new Random().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);
public void Follow() {
if (AICore.PlayerTarget.isOnline()
&& AICore.isTarget
&& PluginCore.getAICore().getCoreTypeNow() == CoreType.ATTACK) {
if (AICore.PlayerTarget.isDead() == false) {
if (PluginCore.getConfigDB().useWorlds.contains(AICore.PlayerTarget.getWorld().getName())
&& PluginCore.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.ENTITY_PLAYER_BREATH, 0.75f, 0.75f);
if (PluginCore.getConfigDB().HitPlayer == true) {
int hitchance = Utils.getRandomGen().nextInt(100);
if (hitchance < 55) {
AICore.PlayerTarget.playSound(AICore.PlayerTarget.getLocation(), Sound.ENTITY_PLAYER_HURT, 0.75f, 0.75f);
AICore.PlayerTarget.damage(4);
}
}
} else {
PluginCore.getAICore().CancelTarget(CoreType.ATTACK);
}
newloc.setY(250);
newloc.getWorld().strikeLightning(newloc);
}
}
}
}else{HerobrineAI.getPluginCore().getAICore().CancelTarget(CoreType.ATTACK);}
}else{HerobrineAI.getPluginCore().getAICore().CancelTarget(CoreType.ATTACK);}
} else {
PluginCore.getAICore().CancelTarget(CoreType.ATTACK);
}
} else {
PluginCore.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){
int hitchance= new Random().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
&& PluginCore.getAICore().getCoreTypeNow() == CoreType.ATTACK) {
if (AICore.PlayerTarget.isDead() == false) {
Location ploc = (Location) AICore.PlayerTarget.getLocation();
ploc.setY(-20);
for(int i=0; i < 5; i++){
for(float j=0; j < 2; j+= 0.5f){
Location hbloc = (Location) HerobrineAI.HerobrineNPC.getBukkitEntity().getLocation();
hbloc.setY(hbloc.getY() + j);
hbloc.getWorld().playEffect(hbloc, Effect.SMOKE, 80);
}
}
if (PluginCore.getConfigDB().SpawnBats) {
Location hbloc = (Location) HerobrineAI.HerobrineNPC.getBukkitEntity().getLocation();
ploc.getWorld().spawnEntity(hbloc, EntityType.BAT);
ploc.getWorld().spawnEntity(hbloc, EntityType.BAT);
}
HerobrineAI.HerobrineNPC.moveTo(ploc);
} else {
PluginCore.getAICore().CancelTarget(CoreType.ATTACK);
}
} else {
PluginCore.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);}
public void FollowHideRepeat() {
if (AICore.PlayerTarget.isOnline() && AICore.isTarget
&& PluginCore.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 {
PluginCore.getAICore().CancelTarget(CoreType.ATTACK);
}
} else {
PluginCore.getAICore().CancelTarget(CoreType.ATTACK);
}
}
}

View File

@ -9,61 +9,66 @@ 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.Utils;
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 class Book extends Core {
public Book() {
super(CoreType.BOOK, AppearType.NORMAL, HerobrineAI.getPluginCore());
}
public CoreResult CallCore(Object[] data){
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())){
int chance=new Random().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!");
if (HerobrineAI.getPluginCore().getConfigDB().useWorlds.contains(player.getLocation().getWorld().getName())) {
if (HerobrineAI.getPluginCore().getConfigDB().WriteBooks == true
&& HerobrineAI.getPluginCore().getSupport().checkBooks(player.getLocation())) {
int chance = Utils.getRandomGen().nextInt(100);
if (chance > (100 - HerobrineAI.getPluginCore().getConfigDB().BookChance)) {
Inventory chest = (Inventory) data[1];
if (chest.firstEmpty() != -1) {
if (HerobrineAI.getPluginCore().getAICore().getResetLimits().isBook()) {
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!");
return new CoreResult(false, "Book create failed!");
}
public ItemStack newBook(){
public ItemStack newBook() {
int count = HerobrineAI.getPluginCore().getConfigDB().useBookMessages.size();
int chance=new Random().nextInt(count);
int chance = Utils.getRandomGen().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;
return (ItemStack) book;
}
}

View File

@ -7,141 +7,144 @@ import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.jakub1221.herobrineai.HerobrineAI;
import org.jakub1221.herobrineai.Utils;
import org.jakub1221.herobrineai.AI.*;
public class BuildStuff extends Core {
public class BuildStuff extends Core{
public BuildStuff(){
super(CoreType.BUILD_STUFF,AppearType.NORMAL);
public BuildStuff() {
super(CoreType.BUILD_STUFF, AppearType.NORMAL, HerobrineAI.getPluginCore());
}
public CoreResult CallCore(Object[] data){
if (data.length==2){
return BuildCave((Location) data[0],true);
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){
int chance=new Random().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 CoreResult BuildCave(Location loc) {
if (HerobrineAI.getPluginCore().getConfigDB().BuildStuff == true) {
if (HerobrineAI.getPluginCore().getSupport().checkBuild(loc)) {
if (loc.getBlockY() < 60) {
int chance = Utils.getRandomGen().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 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;
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>();
Random rand = Utils.getRandomGen();
boolean goByX = rand.nextBoolean();
boolean goNegative = rand.nextBoolean();
int baseX = loc.getBlockX();
int baseZ = loc.getBlockZ();
int baseY = loc.getBlockY();
int finalX = 0;
int finalZ = 0;
int maxL = rand.nextInt(10) + 4;
int iR = rand.nextInt(3) + 4;
int iNow = 0;
while (iNow != iR) {
iNow++;
goByX = rand.nextBoolean();
goNegative = rand.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 (rand.nextBoolean()) {
redstoneTorchList.add(new Location(loc.getWorld(), baseX, baseY + 1, baseZ));
}
}
}
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());
}
}
}
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);
AICore.log.info("Cave created!");
}
}
public void PlaceRedstoneTorch(World world, int x, int y, int z) {
Random randgen = Utils.getRandomGen();
int chance = randgen.nextInt(100);
if (chance > 70) {
world.getBlockAt(x, y, z).setType(Material.REDSTONE_TORCH_ON);
}
}
}

View File

@ -1,13 +1,14 @@
package org.jakub1221.herobrineai.AI.cores;
import org.bukkit.entity.Player;
import org.jakub1221.herobrineai.HerobrineAI;
import org.jakub1221.herobrineai.AI.Core;
import org.jakub1221.herobrineai.AI.CoreResult;
public class Burn extends Core {
public Burn() {
super(CoreType.BURN, AppearType.NORMAL);
super(CoreType.BURN, AppearType.NORMAL, HerobrineAI.getPluginCore());
}
@Override

View File

@ -10,77 +10,83 @@ import org.jakub1221.herobrineai.HerobrineAI;
import org.jakub1221.herobrineai.AI.Core;
import org.jakub1221.herobrineai.AI.CoreResult;
public class BuryPlayer extends Core{
public class BuryPlayer extends Core {
public Block savedBlock1=null;
public Block savedBlock2=null;
public BuryPlayer(){
super(CoreType.BURY_PLAYER,AppearType.NORMAL);
public Block savedBlock1 = null;
public Block savedBlock2 = null;
public BuryPlayer() {
super(CoreType.BURY_PLAYER, AppearType.NORMAL, HerobrineAI.getPluginCore());
}
public CoreResult CallCore(Object[] data){
return FindPlace((Player)data[0]);
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!");
}
}
}
}
}
}
}
}
}
}
if(HerobrineAI.getPluginCore().getSupport().checkBuild(player.getLocation())){
Location loc = (Location) player.getLocation();
int[][] blocks = {
{-1, 0},
{-2, 0},
{-1,-1},
{-2,-1},
{-3, 0},
{-3,-1},
{-1,-1},
{-2,-1},
{-1,-2},
{ 0,-2},
};
for (int i = 0; i < blocks.length; i++){
Material mat = loc.getWorld().getBlockAt(
loc.getBlockX(),
loc.getBlockY() + blocks[i][0],
loc.getBlockZ() + blocks[i][1]
).getType();
if(!HerobrineAI.StandBlocks.contains(mat))
return new CoreResult(false,"Cannot find suitable location!");
}
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!");
return new CoreResult(false,"Cannot find suitable 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 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();
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);
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

@ -12,36 +12,34 @@ import org.jakub1221.herobrineai.AI.CoreResult;
public class Curse extends Core {
public Curse() {
super(CoreType.CURSE, AppearType.NORMAL);
super(CoreType.CURSE, AppearType.NORMAL, HerobrineAI.getPluginCore());
}
@Override
public CoreResult CallCore(Object[] data) {
final Player player = (Player) data[0];
player.addPotionEffect(new PotionEffect(PotionEffectType.CONFUSION, 1000, 1));
player.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, 1000, 1));
player.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 1000, 1));
player.addPotionEffect(new PotionEffect(PotionEffectType.POISON, 50, 1));
player.addPotionEffect(new PotionEffect(PotionEffectType.WEAKNESS, 1000, 1));
int i = 0;
while(i!=3){
i++;
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(HerobrineAI.getPluginCore(), new Runnable(){
@Override
public void run() {
player.getLocation().getWorld().strikeLightning(new Location(player.getLocation().getWorld(),player.getLocation().getX(),player.getLocation().getY()+1,player.getLocation().getZ()));
player.addPotionEffect(new PotionEffect(PotionEffectType.POISON, 50, 1));
}
}, i*150L);
}
return new CoreResult(true,"Player cursed!");
final Player player = (Player) data[0];
player.addPotionEffect(new PotionEffect(PotionEffectType.CONFUSION, 1000, 1));
player.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, 1000, 1));
player.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 1000, 1));
player.addPotionEffect(new PotionEffect(PotionEffectType.POISON, 50, 1));
player.addPotionEffect(new PotionEffect(PotionEffectType.WEAKNESS, 1000, 1));
for (int i=0; i< 3 ; i++) {
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(HerobrineAI.getPluginCore(), new Runnable() {
@Override
public void run() {
player.getLocation().getWorld().strikeLightning(new Location(player.getLocation().getWorld(),
player.getLocation().getX(), player.getLocation().getY() + 1, player.getLocation().getZ()));
player.addPotionEffect(new PotionEffect(PotionEffectType.POISON, 50, 1));
}
}, i * 150L);
}
return new CoreResult(true, "Player cursed!");
}
}

View File

@ -8,43 +8,44 @@ import org.jakub1221.herobrineai.HerobrineAI;
import org.jakub1221.herobrineai.AI.Core;
import org.jakub1221.herobrineai.AI.CoreResult;
public class DestroyTorches extends Core{
public class DestroyTorches extends Core {
public DestroyTorches(){
super(CoreType.DESTROY_TORCHES,AppearType.NORMAL);
public DestroyTorches() {
super(CoreType.DESTROY_TORCHES, AppearType.NORMAL, HerobrineAI.getPluginCore());
}
public CoreResult CallCore(Object[] data){
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!");
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.");
return new CoreResult(false, "Cannot destroy torches.");
}
}

View File

@ -9,134 +9,155 @@ import org.bukkit.World;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.jakub1221.herobrineai.HerobrineAI;
import org.jakub1221.herobrineai.Utils;
import org.jakub1221.herobrineai.AI.AICore;
import org.jakub1221.herobrineai.AI.Core;
import org.jakub1221.herobrineai.AI.CoreResult;
public class Graveyard extends Core{
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);
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, HerobrineAI.getPluginCore());
}
public CoreResult CallCore(Object[] data){
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{
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(-179.85f);
loc.setPitch(0.44999f);
player.teleport(loc);
LivingEntities.get(i).remove();
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.");
}
}
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!");
}
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));
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();
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){
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{
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));
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));
}
Random randomGen = Utils.getRandomGen();
if (randomGen.nextInt(4) == 1) {
Location newloc = new Location(Bukkit.getServer().getWorld("world_herobrineai_graveyard"),
(double) randomGen.nextInt(400), (double) Utils.getRandomGen().nextInt(20) + 20,
(double) randomGen.nextInt(400));
Bukkit.getServer().getWorld("world_herobrineai_graveyard").strikeLightning(newloc);
}
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);
public Location getSavedLocation() {
return new Location(savedWorld, savedX, savedY, savedZ);
}
}

View File

@ -1,254 +1,305 @@
package org.jakub1221.herobrineai.AI.cores;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Random;
import java.util.Set;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.entity.CreatureType;
import org.bukkit.block.Block;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.entity.Wolf;
import org.jakub1221.herobrineai.HerobrineAI;
import org.jakub1221.herobrineai.Utils;
import org.jakub1221.herobrineai.AI.AICore;
import org.jakub1221.herobrineai.AI.Core;
import org.jakub1221.herobrineai.AI.CoreResult;
public class Haunt extends Core{
import com.google.common.collect.Sets;
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);
private int KL_INT = 0;
private int PS_INT = 0;
private boolean isHandler = false;
private boolean isFirst = true;
public Haunt() {
super(CoreType.HAUNT, AppearType.APPEAR, HerobrineAI.getPluginCore());
}
public CoreResult CallCore(Object[] data){
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()+"!");
public CoreResult setHauntTarget(Player player) {
if (PluginCore.getSupport().checkHaunt(player.getLocation())) {
if (!PluginCore.canAttackPlayerNoMSG(player)) {
return new CoreResult(false, "This player is protected.");
}
spawnedWolves = 0;
spawnedBats = 0;
_ticks = 0;
isFirst = true;
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!");
}
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 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;
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());
}
}
public void PlaySounds() {
if (AICore.PlayerTarget.isOnline() && AICore.isTarget
&& PluginCore.getAICore().getCoreTypeNow() == CoreType.HAUNT) {
if (AICore.PlayerTarget.isDead() == false) {
if (_ticks > 290) {
PluginCore.getAICore().CancelTarget(CoreType.HAUNT);
} else {
Object[] data = { AICore.PlayerTarget };
PluginCore.getAICore().getCore(CoreType.SOUNDF).RunCore(data);
Location ploc = (Location) AICore.PlayerTarget.getLocation();
Random randxgen = Utils.getRandomGen();
int randx = randxgen.nextInt(100);
if (randx < 70) {
} else if (randx < 80 && spawnedBats < 2) {
if (PluginCore.getConfigDB().SpawnBats) {
ploc.getWorld().spawnEntity(ploc, EntityType.BAT);
spawnedBats++;
}
} else if (randx < 90 && spawnedWolves < 1) {
if (PluginCore.getConfigDB().SpawnWolves) {
Wolf wolf = (Wolf) ploc.getWorld().spawnEntity(ploc, EntityType.WOLF);
wolf.setAdult();
wolf.setAngry(true);
spawnedWolves++;
}
}
if (PluginCore.getConfigDB().Lighting == true) {
int lchance = randxgen.nextInt(100);
if (lchance > 75) {
Location newloc = (Location) ploc;
int randz = randxgen.nextInt(50);
int randxp = randxgen.nextInt(1);
int randzp = randxgen.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 (isFirst) {
Object[] data2 = { AICore.PlayerTarget.getLocation() };
PluginCore.getAICore().getCore(CoreType.BUILD_STUFF).RunCore(data2);
}
isFirst = false;
}
} else {
PluginCore.getAICore().CancelTarget(CoreType.HAUNT);
}
} else {
PluginCore.getAICore().CancelTarget(CoreType.HAUNT);
}
}
public void KeepLookingHaunt() {
if (AICore.PlayerTarget.isOnline() && AICore.isTarget
&& PluginCore.getAICore().getCoreTypeNow() == CoreType.HAUNT) {
if (AICore.PlayerTarget.isDead() == false) {
Location loc = (Location) HerobrineAI.HerobrineNPC.getBukkitEntity().getLocation();
if (Bukkit.getServer().getOnlinePlayers().size() > 0) {
Player player = Utils.getRandomPlayer();
if(player == null)
return;
Location ploc = (Location) player.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()) {
PluginCore.getAICore().DisappearEffect();
}
}
}
return false;
HerobrineAI.HerobrineHP = HerobrineAI.HerobrineMaxHP;
loc = AICore.PlayerTarget.getLocation();
loc.setY(loc.getY() + 1.5);
HerobrineAI.HerobrineNPC.lookAtPoint(loc);
_ticks++;
AICore _aicore = PluginCore.getAICore();
if(_ticks % 30 == 0)
HauntTP();
else if(_ticks % 20 == 0)
_aicore.DisappearEffect();
} else {
PluginCore.getAICore().CancelTarget(CoreType.HAUNT);
}
} else {
PluginCore.getAICore().CancelTarget(CoreType.HAUNT);
}
}
public void Teleport(World world,int X,int Y,int Z){
public void HauntTP() {
if (AICore.PlayerTarget.isOnline() && AICore.isTarget
&& PluginCore.getAICore().getCoreTypeNow() == CoreType.HAUNT) {
if (AICore.PlayerTarget.isDead() == false) {
if (PluginCore.getConfigDB().useWorlds
.contains(AICore.PlayerTarget.getWorld().getName())) {
FindAndTeleport(AICore.PlayerTarget);
Location ploc = (Location) AICore.PlayerTarget.getLocation();
ploc.setY(ploc.getY() + 1.5);
HerobrineAI.HerobrineNPC.lookAtPoint(ploc);
} else {
PluginCore.getAICore().CancelTarget(CoreType.HAUNT);
}
} else {
PluginCore.getAICore().CancelTarget(CoreType.HAUNT);
}
} else {
PluginCore.getAICore().CancelTarget(CoreType.HAUNT);
}
}
public boolean FindAndTeleport(Player player) {
Location loc = (Location) player.getLocation();
int x = 0;
int z = 0;
int y = 0;
Random randGen = Utils.getRandomGen();
int xMax = randGen.nextInt(10) + 10;
int zMax = randGen.nextInt(10) + 10;
int randY = randGen.nextInt(5) + 5;
xMax = randGen.nextBoolean() ? -xMax : xMax;
zMax = randGen.nextBoolean() ? -zMax : zMax;
for (y = -randY; y <= randY; y++) {
for (x = -xMax; xMax > 0 ? x <= xMax : x >= xMax; x += xMax > 0 ? 1 : -1) {
for (z = -zMax; zMax > 0 ? z <= zMax : z >= zMax; z += zMax > 0 ? 1 : -1) {
if (!(x >= -4 && x <= 4 && z >= -4 && z <= 4)) {
Material blockBottom = loc.getWorld().getBlockAt(
x + loc.getBlockX(),
y + loc.getBlockY() - 1,
z + loc.getBlockZ()).getType();
Material blockMiddle = loc.getWorld().getBlockAt(
x + loc.getBlockX(),
y + loc.getBlockY(),
z + loc.getBlockZ()).getType();
Material blockTop = loc.getWorld().getBlockAt(
x + loc.getBlockX(),
y + loc.getBlockY() + 1,
z + loc.getBlockZ()).getType();
List<Material> mats = new ArrayList<Material>();
mats.add(blockBottom);
mats.add(blockMiddle);
mats.add(blockTop);
if (HerobrineAI.StandBlocks.containsAll(mats)){
Teleport(loc.getWorld(), x + loc.getBlockX(), y + loc.getBlockY(), z + loc.getBlockZ());
return true;
}
}
}
}
}
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

@ -10,77 +10,88 @@ import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.jakub1221.herobrineai.HerobrineAI;
import org.jakub1221.herobrineai.Utils;
import org.jakub1221.herobrineai.AI.AICore;
import org.jakub1221.herobrineai.AI.Core;
import org.jakub1221.herobrineai.AI.CoreResult;
import org.jakub1221.herobrineai.misc.BlockChanger;
public class Heads extends Core{
public class Heads extends Core {
private boolean isCalled=false;
private boolean isCalled = false;
private List<Block> headList = new ArrayList<Block>();
public Heads(){
super(CoreType.HEADS,AppearType.NORMAL);
public Heads() {
super(CoreType.HEADS, AppearType.NORMAL, HerobrineAI.getPluginCore());
}
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;
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 (PluginCore.getSupport().checkBuild(player.getLocation())) {
if (PluginCore.getConfigDB().UseHeads) {
Location loc = player.getLocation();
int px = loc.getBlockX();
int pz = loc.getBlockZ();
int y = 0;
int x = -7;
int z = -7;
Random randomGen = Utils.getRandomGen();
for (x = -7; x <= 7; x++) {
for (z = -7; z <= 7; z++) {
if (randomGen.nextInt(7) == randomGen.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);
}
}
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!");
}
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.");
} 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){
public void RemoveHeads() {
for (Block h : headList) {
h.setType(Material.AIR);
}
headList.clear();
isCalled=false;
isCalled = false;
}
public ArrayList<Block> getHeadList(){
public ArrayList<Block> getHeadList() {
return (ArrayList<Block>) headList;
}
}

View File

@ -8,191 +8,228 @@ import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.entity.Player;
import org.jakub1221.herobrineai.HerobrineAI;
import org.jakub1221.herobrineai.Utils;
import org.jakub1221.herobrineai.AI.AICore;
import org.jakub1221.herobrineai.AI.Core;
import org.jakub1221.herobrineai.AI.CoreResult;
public class Pyramid extends Core{
public class Pyramid extends Core {
public Pyramid(){
super(CoreType.PYRAMID,AppearType.NORMAL);
public Pyramid() {
super(CoreType.PYRAMID, AppearType.NORMAL, HerobrineAI.getPluginCore());
}
public CoreResult CallCore(Object[] data){
if (data[0] instanceof Player){
return FindPlace((Player) data[0]);
}else{
return FindPlace((Chunk) data[0]);
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){
public CoreResult FindPlace(Chunk chunk) {
if (PluginCore.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;
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;}
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;
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 (PluginCore.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 = Utils.getRandomGen().nextInt(15) - 10;
int zMax = Utils.getRandomGen().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;}
}
} 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 (canBuild == true) {
BuildPyramid(
loc.getWorld(),
i2 + loc.getBlockX(),
i1 + loc.getBlockY(),
i3 + loc.getBlockZ()
);
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;}
}
}
}
return new CoreResult(true, "Creating a pyramid!");
}
}
}
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!");
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);
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;
// TODO CHANGE THIS
// 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

@ -5,35 +5,36 @@ import java.util.Random;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.jakub1221.herobrineai.HerobrineAI;
import org.jakub1221.herobrineai.Utils;
import org.jakub1221.herobrineai.AI.Core;
import org.jakub1221.herobrineai.AI.CoreResult;
public class RandomExplosion extends Core {
public RandomExplosion() {
super(CoreType.RANDOM_EXPLOSION,AppearType.NORMAL);
super(CoreType.RANDOM_EXPLOSION, AppearType.NORMAL, HerobrineAI.getPluginCore());
}
@Override
public CoreResult CallCore(Object[] data) {
Player player = (Player) data[0];
if (HerobrineAI.getPluginCore().getConfigDB().Explosions){
if (HerobrineAI.getPluginCore().getSupport().checkBuild(player.getLocation())){
Location loc = player.getLocation();
int x=loc.getBlockX()+(new Random().nextInt(16)-8);
int y=loc.getBlockY();
int z=loc.getBlockZ()+(new Random().nextInt(16)-8);
loc.getWorld().createExplosion(new Location(loc.getWorld(),x,y,z), 1.0f);
}else{
return new CoreResult(true,"Player is in secure area!");
if (PluginCore.getConfigDB().Explosions) {
if (PluginCore.getSupport().checkBuild(player.getLocation())) {
Location loc = player.getLocation();
int x = loc.getBlockX() + (Utils.getRandomGen().nextInt(16) - 8);
int y = loc.getBlockY();
int z = loc.getBlockZ() + (Utils.getRandomGen().nextInt(16) - 8);
loc.getWorld().createExplosion(new Location(loc.getWorld(), x, y, z), 1.0f);
} else {
return new CoreResult(true, "Player is in secure area!");
}
} else {
return new CoreResult(true, "Explosions are not allowed!");
}
}else{
return new CoreResult(true,"Explosions are not allowed!");
}
return new CoreResult(true,"Explosion near the player!");
return new CoreResult(true, "Explosion near the player!");
}
}

View File

@ -1,5 +1,6 @@
package org.jakub1221.herobrineai.AI.cores;
import java.util.Collection;
import java.util.Random;
import org.bukkit.Bukkit;
@ -9,192 +10,233 @@ import org.bukkit.World;
import org.bukkit.entity.Player;
import org.jakub1221.herobrineai.ConfigDB;
import org.jakub1221.herobrineai.HerobrineAI;
import org.jakub1221.herobrineai.Utils;
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{
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);
private int randomTicks = 0;
private int randomMoveTicks = 0;
private boolean RandomMoveIsPlayer = false;
public RandomPosition() {
super(CoreType.RANDOM_POSITION, AppearType.APPEAR, HerobrineAI.getPluginCore());
}
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 int getRandomTicks() {
return this.randomTicks;
}
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 int getRandomMoveTicks() {
return this.randomMoveTicks;
}
public Location getRandomLocation(World world){
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 (PluginCore.getConfigDB().UseWalkingMode) {
if (randomTicks != 3) {
randomTicks++;
if (PluginCore.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.");
PluginCore.getAICore().Start_RM();
PluginCore.getAICore().Start_RS();
PluginCore.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;
for (i = 0; i <= 100; i++) {
int r_nxtX = PluginCore.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 r_nxtZ = PluginCore.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{
int randx = Utils.getRandomGen().nextInt(nxtX);
int randy = 0;
int randz = Utils.getRandomGen().nextInt(nxtZ);
int randxp = Utils.getRandomGen().nextInt(1);
int randzp = Utils.getRandomGen().nextInt(1);
if (randxp == 0 && randx != 0) {
randx = -(randx);
}
if (randzp == 0 && randz != 0) {
randz = -(randz);
}
randx = randx + PluginCore.getConfigDB().WalkingModeFromXRadius;
randz = randz + PluginCore.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);
}
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){
public void RandomMove() {
if (PluginCore.getAICore().getCoreTypeNow() == CoreType.RANDOM_POSITION && AICore.isTarget == false
&& RandomMoveIsPlayer == false) {
HerobrineAI.HerobrineHP = HerobrineAI.HerobrineMaxHP;
if (Utils.getRandomGen().nextInt(5) == 3) {
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);
}
Path path = new Path((float) loc.getX() + Utils.getRandomGen().nextInt(30) - 15,
(float) loc.getZ() + Utils.getRandomGen().nextInt(30) - 15);
PluginCore.getPathManager().setPath(path);
}
}
}
public void CheckGravity(){
if (HerobrineAI.getPluginCore().getAICore().getCoreTypeNow()==CoreType.RANDOM_POSITION && AICore.isTarget==false){
public void CheckGravity() {
if (PluginCore.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);
ConfigDB config = PluginCore.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 {
PluginCore.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;
}
public void CheckPlayerPosition() {
boolean isThere = false;
Location loc = (Location) HerobrineAI.HerobrineNPC.getBukkitEntity().getLocation();
Collection<? extends Player> onlinePlayers = Bukkit.getServer().getOnlinePlayers();
if (Bukkit.getServer().getOnlinePlayers().size() > 0) {
for (Player player : onlinePlayers) {
if (HerobrineAI.HerobrineEntityID != player.getEntityId()) {
Location ploc = (Location) player.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);
PluginCore.getAICore().CancelTarget(CoreType.RANDOM_POSITION);
RandomMoveIsPlayer = false;
PluginCore.getAICore().setAttackTarget(player);
break;
} 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);
PluginCore.getPathManager().setPath(null);
isThere = true;
break;
}
}
}
}
}
if (isThere) {
RandomMoveIsPlayer = true;
} else {
RandomMoveIsPlayer = false;
}
}
}

View File

@ -8,29 +8,29 @@ import org.jakub1221.herobrineai.AI.CoreResult;
public class RandomSound extends Core {
public RandomSound() {
super(CoreType.RANDOM_SOUND, AppearType.NORMAL);
super(CoreType.RANDOM_SOUND, AppearType.NORMAL, HerobrineAI.getPluginCore());
}
@Override
public CoreResult CallCore(final Object[] data) {
int multip=1;
while(multip!=7){
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(HerobrineAI.getPluginCore(), new Runnable(){
int multip = 1;
@Override
public void run() {
HerobrineAI.getPluginCore().getAICore().getCore(CoreType.SOUNDF).RunCore(data);
}
},multip*30L);
multip++;
while (multip != 7) {
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(HerobrineAI.getPluginCore(), new Runnable() {
@Override
public void run() {
HerobrineAI.getPluginCore().getAICore().getCore(CoreType.SOUNDF).RunCore(data);
}
}, multip * 30L);
multip++;
}
return new CoreResult(true,"Starting sound play to target!");
return new CoreResult(true, "Starting sound play to target!");
}
}

View File

@ -7,74 +7,84 @@ import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.Sign;
import org.jakub1221.herobrineai.HerobrineAI;
import org.jakub1221.herobrineai.Utils;
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 class Signs extends Core {
public Signs() {
super(CoreType.SIGNS, AppearType.NORMAL, HerobrineAI.getPluginCore());
}
public CoreResult CallCore(Object[] data){
return placeSign((Location) data[0],(Location) data[1]);
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;
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 (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!");
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();
public void createSign(Location loc, Location ploc) {
Random randcgen = Utils.getRandomGen();
int chance = randcgen.nextInt(100);
if (chance > (100 - HerobrineAI.getPluginCore().getConfigDB().SignChance)) {
Random randgen = Utils.getRandomGen();
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

@ -4,13 +4,15 @@ import java.util.Random;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
import org.jakub1221.herobrineai.HerobrineAI;
import org.jakub1221.herobrineai.Utils;
import org.jakub1221.herobrineai.AI.Core;
import org.jakub1221.herobrineai.AI.CoreResult;
public class SoundF extends Core{
public SoundF(){
super(CoreType.SOUNDF,AppearType.NORMAL);
super(CoreType.SOUNDF,AppearType.NORMAL, HerobrineAI.getPluginCore());
}
public CoreResult CallCore(Object[] data){
@ -19,32 +21,19 @@ public class SoundF extends Core{
public CoreResult playRandom(Player player){
Sound[] sounds = new Sound[15];
sounds[0]=Sound.STEP_STONE;
sounds[1]=Sound.STEP_WOOD;
sounds[2]=Sound.STEP_GRASS;
sounds[3]=Sound.STEP_SAND;
sounds[4]=Sound.STEP_GRAVEL;
sounds[5]=Sound.BREATH;
sounds[6]=Sound.BREATH;
sounds[7]=Sound.BREATH;
sounds[8]=Sound.BREATH;
sounds[9]=Sound.DOOR_OPEN;
sounds[10]=Sound.DOOR_CLOSE;
sounds[11]=Sound.GHAST_SCREAM;
sounds[12]=Sound.GHAST_SCREAM2;
sounds[13]=Sound.WITHER_DEATH;
sounds[14]=Sound.WITHER_HURT;
Sound[] sounds = {
Sound.ENTITY_GHAST_SCREAM,
Sound.ENTITY_WITHER_DEATH,
Sound.ENTITY_WITHER_HURT,
Sound.ENTITY_BAT_HURT,
Sound.ENTITY_PLAYER_BREATH,
Sound.ENTITY_PLAYER_HURT,
Sound.BLOCK_IRON_DOOR_OPEN,
Sound.BLOCK_IRON_DOOR_CLOSE
};
int chance=new Random().nextInt(14);
int randx=new Random().nextInt(3);
int randz=new Random().nextInt(3);
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));}
player.playSound(player.getLocation(),sounds[chance],(float) 0.75,(float) 0.75);
player.playSound(player.getLocation(),sounds[Utils.getRandomGen().nextInt(sounds.length)],(float) 0.75,(float) 0.75);
return new CoreResult(true,"SoundF is starting!");
}

View File

@ -12,216 +12,260 @@ import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.jakub1221.herobrineai.HerobrineAI;
import org.jakub1221.herobrineai.Utils;
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 class Temple extends Core {
public Temple(){
super(CoreType.TEMPLE,AppearType.NORMAL);
public Temple() {
super(CoreType.TEMPLE, AppearType.NORMAL, HerobrineAI.getPluginCore());
}
public CoreResult CallCore(Object[] data){
if (data[0] instanceof Player){
return FindPlacePlayer((Player)data[0]);
}else{
return FindPlacePlayer((Chunk)data[0]);
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){
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;}
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() + "!");
}
}
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.");
return new CoreResult(false, "Cannot find a good place for Temple.");
}
public CoreResult FindPlacePlayer(Chunk chunk){
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;
loc = loc.getWorld().getHighestBlockAt(loc).getLocation();
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;}
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().getInputStreamData("/res/temple.yml")).Build(loc.getWorld(),
MainX, MainY, MainZ);
loc.getWorld().getBlockAt(MainX + 6, MainY + 0, MainZ + 2).setType(Material.CHEST);
// Mob spawn
if (!HerobrineAI.isNPCDisabled) {
if (HerobrineAI.getPluginCore().getConfigDB().UseNPC_Guardian) {
Location mobloc = new Location(loc.getWorld(), MainX + 6, MainY + 0, MainZ + 4);
for (int i = 1; i <= HerobrineAI.getPluginCore().getConfigDB().npc
.getInt("npc.Guardian.SpawnCount"); i++) {
HerobrineAI.getPluginCore().getEntityManager().spawnCustomZombie(mobloc,
MobType.ARTIFACT_GUARDIAN);
}
}
if (canBuild==true){
Create(loc.getWorld(),i2+loc.getBlockX(),i1+loc.getBlockY(),i3+loc.getBlockZ());
return new CoreResult(true,"Creating temple!");
}
// 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));
}
}
}
}
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);
loc.getWorld().getBlockAt(MainX+6, MainY+0, MainZ+2).setType(Material.CHEST);
//Mob spawn
if (HerobrineAI.getPluginCore().getConfigDB().UseNPC_Guardian){
Location mobloc = new Location(loc.getWorld(),MainX+6, MainY+0, MainZ+4);
for (int i=1;i<=HerobrineAI.getPluginCore().getConfigDB().npc.getInt("npc.Guardian.SpawnCount");i++){
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 = Utils.getRandomGen();
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<EFBFBD>s artifact");
newLore.add("Bow of Teleporting");
item = ItemName.setNameAndLore(item, "Bow of Teleporting", newLore);
item.addEnchantment(Enchantment.ARROW_FIRE, 1);
item.addEnchantment(Enchantment.ARROW_KNOCKBACK, 1);
} else if (chance < 8 && HerobrineAI.getPluginCore().getConfigDB().UseArtifactSword) {
item = new ItemStack(Material.DIAMOND_SWORD);
newLore.add("Herobrine<EFBFBD>s artifact");
newLore.add("Sword of Lighting");
item = ItemName.setNameAndLore(item, "Sword of Lighting", newLore);
item.addEnchantment(Enchantment.KNOCKBACK, 2);
item.addEnchantment(Enchantment.DAMAGE_ALL, 2);
item.addEnchantment(Enchantment.DURABILITY, 3);
} else if (chance < 12 && HerobrineAI.getPluginCore().getConfigDB().UseArtifactApple) {
item = new ItemStack(Material.GOLDEN_APPLE);
newLore.add("Herobrine<EFBFBD>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();
item.addEnchantment(Enchantment.KNOCKBACK, 2);
item.addEnchantment(Enchantment.DAMAGE_ALL, 2);
}
}
Chest chest = (Chest) loc.getWorld().getBlockAt(MainX + 6, MainY + 0, MainZ + 2).getState();
chest.getBlockInventory().setItem(chest.getInventory().firstEmpty(), item);
}
}
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);
item.addEnchantment(Enchantment.ARROW_FIRE, 1);
item.addEnchantment(Enchantment.ARROW_KNOCKBACK, 1);
}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);
item.addEnchantment(Enchantment.KNOCKBACK, 2);
item.addEnchantment(Enchantment.DAMAGE_ALL, 2);
item.addEnchantment(Enchantment.DURABILITY, 3);
}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();
item.addEnchantment(Enchantment.KNOCKBACK, 2);
item.addEnchantment(Enchantment.DAMAGE_ALL, 2);
}
}
Chest chest = (Chest) loc.getWorld().getBlockAt(MainX+6, MainY+0, MainZ+2).getState();
chest.getBlockInventory().setItem(chest.getInventory().firstEmpty(), item);
}
}
}
}

View File

@ -1,5 +1,7 @@
package org.jakub1221.herobrineai.AI.cores;
import java.util.Collection;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.entity.Player;
@ -11,139 +13,105 @@ import org.jakub1221.herobrineai.AI.Core;
import org.jakub1221.herobrineai.AI.CoreResult;
import org.jakub1221.herobrineai.AI.Message;
public class Totem extends Core{
public Totem(){
super(CoreType.TOTEM,AppearType.APPEAR);
public class Totem extends Core {
public Totem() {
super(CoreType.TOTEM, AppearType.APPEAR, HerobrineAI.getPluginCore());
}
public CoreResult CallCore(Object[] data){
return TotemCall((Location)data[0],(String)data[1]);
public CoreResult CallCore(Object[] data) {
return TotemCall((Location) data[0], (String) data[1]);
}
public CoreResult TotemCall(Location loc,String caller){
AICore.isTotemCalled=false;
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 (PluginCore.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));
if (Bukkit.getServer().getPlayer(caller) != null) {
if (Bukkit.getServer().getPlayer(caller).isOnline()) {
PluginCore.getAICore().setCoreTypeNow(CoreType.TOTEM);
PluginCore.getAICore().setAttackTarget(Bukkit.getServer().getPlayer(caller));
Player player = (Player) Bukkit.getServer().getPlayer(caller);
Collection<? extends Player> onlinePlayers = Bukkit.getServer().getOnlinePlayers();
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;
if (Bukkit.getServer().getOnlinePlayers().size() > 0) {
for(Player onlinePlayer : onlinePlayers) {
Location ploc = (Location) onlinePlayer.getLocation();
if (onlinePlayer.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(onlinePlayer);
if (PluginCore.getConfigDB().UsePotionEffects) {
onlinePlayer.addPotionEffect(new PotionEffect(PotionEffectType.CONFUSION, 1000, 1));
onlinePlayer.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, 1000, 1));
onlinePlayer.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 1000, 1));
}
}
}
}
} else {
Player target = null;
Collection<? extends Player> onlinePlayers = Bukkit.getServer().getOnlinePlayers();
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 (Bukkit.getServer().getOnlinePlayers().size() > 0) {
for(Player onlinePlayer : onlinePlayers) {
Location ploc = (Location) onlinePlayer.getLocation();
if (ploc.getX() + 10 > loc.getX() && ploc.getX() - 10 < loc.getX()
&& ploc.getZ() + 10 > loc.getZ() && ploc.getZ() - 10 < loc.getZ()) {
target = onlinePlayer;
break;
}
}
}
}
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()){
if (target != null) {
PluginCore.getAICore().CancelTarget(CoreType.TOTEM);
PluginCore.getAICore().setAttackTarget(target);
Player player = (Player) target;
if (Bukkit.getServer().getOnlinePlayers().size() > 0) {
for(Player onlinePlayer : onlinePlayers) {
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));
}
}
}
}
Location ploc = (Location) onlinePlayer.getLocation();
if (onlinePlayer.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(onlinePlayer);
onlinePlayer.addPotionEffect(new PotionEffect(PotionEffectType.CONFUSION, 1000, 1));
onlinePlayer.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, 1000, 1));
onlinePlayer.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!");
return new CoreResult(false, "Totem called!");
}
}

View File

@ -5,30 +5,27 @@ 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++) {
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);
int MainX = -10;
int MainY = 3;
int MainZ = -10;
StructureLoader structLoader = new StructureLoader(HerobrineAI.getPluginCore().getInputStreamData("/res/graveyard_world.yml"));
structLoader.Build(loc.getWorld(), MainX, MainY, MainZ);
}
}

View File

@ -1,132 +1,30 @@
package org.jakub1221.herobrineai.AI.extensions;
import java.util.Random;
import org.bukkit.Location;
import org.jakub1221.herobrineai.HerobrineAI;
import org.bukkit.Material;
public class Position {
public class Position{
public static Location getTeleportPosition(Location ploc) {
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{
}
for(int y = -2; y < 2; y++)
{
for(int x = -2; x < 2; x++)
{
for(int z = -2; z < 2; z++)
{
Material bottomBlock = ploc.clone().add(new Location(ploc.getWorld(), x, y - 1 ,z)).getBlock().getType();
Material middleBlock = ploc.clone().add(new Location(ploc.getWorld(), x, y ,z)).getBlock().getType();
Material topBlock = ploc.clone().add(new Location(ploc.getWorld(), x, y + 1 ,z)).getBlock().getType();
if (bottomBlock.isSolid() && !middleBlock.isSolid() && !topBlock.isSolid())
return ploc.clone().add(new Location(ploc.getWorld(), x, y - 1 ,z));
}
}
}
return newloc;
return ploc;
}
}

View File

@ -8,6 +8,7 @@ import java.util.List;
import java.util.logging.Logger;
import org.bukkit.Bukkit;
import org.bukkit.World;
import org.bukkit.configuration.InvalidConfigurationException;
import org.bukkit.configuration.file.YamlConfiguration;
import org.jakub1221.herobrineai.misc.CustomID;
@ -23,7 +24,7 @@ public class ConfigDB {
public boolean Lighting=true;
public boolean DestroyTorches=true;
public int DestroyTorchesRadius=5;
public int ShowInterval=30000;
public int ShowInterval=144000;
public boolean TotemExplodes=true;
public boolean OnlyWalkingMode=false;
public boolean BuildStuff=true;
@ -62,7 +63,7 @@ public class ConfigDB {
public boolean SecuredArea_Signs = true;
public boolean SecuredArea_Books = true;
public int HerobrineHP = 150;
public int BuildInterval = 45000;
public int BuildInterval = 72000;
public boolean UseHeads = true;
public boolean UseCustomItems = false;
public boolean UseAncientSword = true;
@ -74,6 +75,12 @@ public class ConfigDB {
public boolean Explosions=true;
public boolean Burn=true;
public boolean Curse=true;
public int maxBooks=1;
public int maxSigns=1;
public int maxHeads=1;
public boolean UseIgnorePermission=true;
private boolean isStartupDone=false;
public ConfigDB(Logger l){
this.log=l;
@ -125,18 +132,21 @@ public class ConfigDB {
if (!npc.contains("npc.Guardian")){
npc.set("npc.Guardian.SpawnCount", 1);
npc.set("npc.Guardian.HP", 40);
npc.set("npc.Guardian.Speed", 0.3);
npc.set("npc.Guardian.Drops.283.Chance", 40);
npc.set("npc.Guardian.Drops.283.Count", 1);
npc.set("npc.Guardian.Drops.286.Chance", 30);
npc.set("npc.Guardian.Drops.286.Count", 1);
npc.set("npc.Warrior.SpawnChance", 10);
npc.set("npc.Warrior.SpawnChance", 4);
npc.set("npc.Warrior.HP", 40);
npc.set("npc.Warrior.Speed", 0.3);
npc.set("npc.Warrior.Drops.307.Chance", 25);
npc.set("npc.Warrior.Drops.307.Count", 1);
npc.set("npc.Warrior.Drops.306.Chance", 20);
npc.set("npc.Warrior.Drops.306.Count", 1);
npc.set("npc.Demon.SpawnChance", 10);
npc.set("npc.Demon.SpawnChance", 4);
npc.set("npc.Demon.HP", 40);
npc.set("npc.Demon.Speed", 0.3);
npc.set("npc.Demon.Drops.322.Chance", 40);
npc.set("npc.Demon.Drops.322.Count", 1);
npc.set("npc.Demon.Drops.397.Chance", 20);
@ -167,7 +177,7 @@ public class ConfigDB {
UseCustomItemsList.add("ItemExample");
log.info("[HerobrineAI] Creating new Config ...");
config.set("config.ShowInterval", 30000);
config.set("config.ShowInterval", 144000);
config.set("config.ShowRate", 2);
config.set("config.HitPlayer", true);
config.set("config.SendMessages", true);
@ -202,12 +212,12 @@ public class ConfigDB {
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.BuildInterval", 72000);
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.HerobrineHP", 300);
config.set("config.AttackCreative", true);
config.set("config.AttackOP", true);
config.set("config.SecuredArea.Build", true);
@ -226,6 +236,10 @@ public class ConfigDB {
config.set("config.Explosions", true);
config.set("config.Burn", true);
config.set("config.Curse", true);
config.set("config.Limit.Books", 1);
config.set("config.Limit.Signs", 1);
config.set("config.Limit.Heads", 1);
config.set("config.UseIgnorePermission", true);
try {
config.save(configF);
@ -452,11 +466,42 @@ public class ConfigDB {
config.set("config.Burn", true);
config.set("config.Curse", true);
}
if (!npc.contains("npc.Warrior.Speed")){
if (hasUpdated==false){
log.info("[HerobrineAI] Updating old config...");
}
hasUpdated=true;
npc.set("npc.Warrior.Speed", 0.3);
npc.set("npc.Guardian.Speed", 0.3);
npc.set("npc.Demon.Speed", 0.3);
}
if (!config.contains("config.Limit.Books")){
if (hasUpdated==false){
log.info("[HerobrineAI] Updating old config...");
}
hasUpdated=true;
config.set("config.Limit.Books", 1);
config.set("config.Limit.Signs", 1);
config.set("config.Limit.Heads", 1);
}
if (!config.contains("config.UseIgnorePermission")){
if (hasUpdated==false){
log.info("[HerobrineAI] Updating old config...");
}
hasUpdated=true;
config.set("config.UseIgnorePermission", true);
}
if (hasUpdated==true){
try {
config.save(configF);
npc.save(npcF);
} catch (IOException e) {
e.printStackTrace();
@ -545,6 +590,10 @@ public class ConfigDB {
Explosions=config.getBoolean("config.Explosions");
Burn=config.getBoolean("config.Burn");
Curse=config.getBoolean("config.Curse");
maxBooks=config.getInt("config.Limit.Books");
maxSigns=config.getInt("config.Limit.Signs");
maxHeads=config.getInt("config.Limit.Heads");
UseIgnorePermission=config.getBoolean("config.UseIgnorePermission");
HerobrineAI.HerobrineMaxHP=HerobrineHP;
HerobrineAI.getPluginCore().getAICore().Stop_MAIN();
@ -554,17 +603,68 @@ public class ConfigDB {
HerobrineAI.getPluginCore().getAICore().Stop_RC();
HerobrineAI.getPluginCore().getAICore().Start_RC();
HerobrineAI.AvailableWorld=false;
HerobrineAI.getPluginCore().getAICore().getResetLimits().updateFromConfig();
if (HerobrineAI.HerobrineNPC!=null){
HerobrineAI.HerobrineNPC.setItemInHand(ItemInHand.getItemStack());
}
for (int i = 0;i<=useWorlds.size()-1;i++){
if (isStartupDone){
if (Bukkit.getServer().getWorlds().contains(Bukkit.getServer().getWorld(useWorlds.get(i)))){HerobrineAI.AvailableWorld=true;}
}
}
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(HerobrineAI.getPluginCore(), new Runnable() {
public void run() {
for (int i = 0;i<=useWorlds.size()-1;i++){
if (Bukkit.getServer().getWorlds().contains(Bukkit.getServer().getWorld(useWorlds.get(i)))){HerobrineAI.AvailableWorld=true;}
}
if (HerobrineAI.AvailableWorld==false){
log.warning("**********************************************************");
log.warning("[HerobrineAI] There are no available worlds for Herobrine!");
log.warning("**********************************************************");
}else{
log.info("**********************************************************");
log.info("[HerobrineAI] No problems detected.");
log.info("**********************************************************");
}
}
},1L);
}
isStartupDone=true;
}
public void addAllWorlds(){
ArrayList<String> allWorlds = new ArrayList<String>();
List<World> worlds_ = Bukkit.getWorlds();
for(int i=0;i<=worlds_.size()-1;i++){
if(!worlds_.get(i).getName().equalsIgnoreCase("world_herobrineai_graveyard")){
allWorlds.add(worlds_.get(i).getName());
}
}
try {
config.load(configF);
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} catch (InvalidConfigurationException e) {
e.printStackTrace();
}
config.set("config.Worlds", allWorlds);
try {
config.save(configF);
} catch (IOException e) {
e.printStackTrace();
}
Reload();
}
}

View File

@ -6,10 +6,12 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.logging.Logger;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Color;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.Material;
@ -18,8 +20,9 @@ import org.bukkit.WorldCreator;
import org.bukkit.command.CommandExecutor;
import org.bukkit.entity.Player;
import org.bukkit.event.Listener;
import org.bukkit.metadata.FixedMetadataValue;
import org.bukkit.plugin.java.JavaPlugin;
import org.jakub1221.herobrineai.NPC.AI.Path;
import org.jakub1221.herobrineai.NPC.AI.PathManager;
import org.jakub1221.herobrineai.NPC.Entity.HumanNPC;
import org.jakub1221.herobrineai.NPC.NPCCore;
@ -36,9 +39,7 @@ 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{
public class HerobrineAI extends JavaPlugin implements Listener {
private static HerobrineAI pluginCore;
private AICore aicore;
@ -46,94 +47,108 @@ public class HerobrineAI extends JavaPlugin implements Listener{
private Support support;
private EntityManager entMng;
private PathManager pathMng;
public static final int build=3127;
public static final String versionStr="3.1.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 final boolean isDebugging=false;
public static final int build = 3219;
public static final String versionStr = "3.2.2";
public static boolean isNPCDisabled = false;
private static int pathUpdateINT = 0;
public static String bukkit_ver_string = "1.6.4 R0.1";
public static int HerobrineHP = 200;
public static int HerobrineMaxHP = 200;
public static final boolean isDebugging = false;
public static boolean isInitDone = 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 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
public void onEnable() {
boolean errorCheck = true;
try {
Metrics metrics = new Metrics(this);
metrics.start();
} catch (IOException e) {
Class.forName("net.minecraft.server.v1_6_R3.Entity");
} catch (ClassNotFoundException e) {
errorCheck = false;
isInitDone = false;
}
// 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();
}
if (errorCheck) {
isInitDone = true;
HerobrineAI.pluginCore = this;
NPCman = new NPCCore(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) {
}
log.info("[HerobrineAI] Plugin loaded! Version: "+versionStr+" / Build: "+build);
// 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: " + build);
// Init Block Types
StandBlocks.add(Material.STONE);
StandBlocks.add(Material.getMaterial(2));
StandBlocks.add(Material.GRAVEL);
@ -150,11 +165,11 @@ public class HerobrineAI extends JavaPlugin implements Listener{
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));
@ -173,179 +188,267 @@ public class HerobrineAI extends JavaPlugin implements Listener{
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().scheduleSyncDelayedTask(this,
* new Runnable() { public void run() {
*
* 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.warning(
* "**********************************************************");
* log.
* warning("[HerobrineAI] There are no available worlds for Herobrine!"
* ); log.warning(
* "**********************************************************");
* }else{ log.info(
* "**********************************************************");
* log.info("[HerobrineAI] No problems detected."); log.info(
* "**********************************************************"); }
*
*
* } }, 1 * 1L);
*/
pathUpdateINT = Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(this, new Runnable() {
public void run() {
if (new Random().nextInt(4) == 2 && HerobrineAI.getPluginCore().getAICore().getCoreTypeNow()
.equals(CoreType.RANDOM_POSITION)) {
pathMng.setPath(new Path(new Random().nextInt(15) - 7f, new Random().nextInt(15) - 7f));
}
}
Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(AICore.plugin, new Runnable() {
public void run() {
}
}, 1 * 35L, 1 * 35L);
}, 1 * 200L, 1 * 200L);
Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(this, new Runnable() {
public void run() {
pathMng.update();
}
}, 1 * 5L, 1 * 5L);
//Command Executors
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
// 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);
Class[] argst = new Class[3];
argst[0] = Class.class;
argst[1] = String.class;
argst[2] = int.class;
try {
Method ab = net.minecraft.server.v1_11_R1.EntityTypes.class.getDeclaredMethod("a", argst);
} catch (NoSuchMethodException e1) {
isNPCDisabled = true;
} catch (SecurityException e1) {
isNPCDisabled = true;
}
a.invoke(a, CustomZombie.class, "Zombie", 54);
a.invoke(a, CustomSkeleton.class, "Skeleton", 51);
}catch (Exception e){
e.printStackTrace();
this.setEnabled(false);
}
if (!isNPCDisabled) {
try {
@SuppressWarnings("rawtypes")
Class[] args = new Class[3];
args[0] = Class.class;
args[1] = String.class;
args[2] = int.class;
}
public void onDisable(){
this.entMng.killAllMobs();
NPCman.DisableTask();
aicore.CancelTarget(CoreType.ANY);
log.info("[HerobrineAI] Plugin disabled!");
Method a = net.minecraft.server.v1_11_R1.EntityTypes.class.getDeclaredMethod("a", args);
a.setAccessible(true);
a.invoke(a, CustomZombie.class, "Zombie", 54);
a.invoke(a, CustomSkeleton.class, "Skeleton", 51);
} catch (Exception e) {
e.printStackTrace();
this.setEnabled(false);
}
} else {
log.warning("[HerobrineAI] Custom NPCs have been disabled. (Incompatibility error!)");
}
} else {
log.warning("[HerobrineAI] ******************ERROR******************");
log.warning("[HerobrineAI] This version is only compatible with bukkit version " + bukkit_ver_string);
log.warning("[HerobrineAI] *****************************************");
this.setEnabled(false);
}
}
public AICore getAICore(){
public void onDisable() {
if (isInitDone) {
this.entMng.killAllMobs();
Bukkit.getServer().getScheduler().cancelTask(pathUpdateINT);
NPCman.DisableTask();
aicore.CancelTarget(CoreType.ANY);
aicore.Stop_BD();
aicore.Stop_CG();
aicore.Stop_MAIN();
aicore.Stop_RC();
aicore.Stop_RM();
aicore.Stop_RP();
aicore.Stop_RS();
aicore.disableAll();
log.info("[HerobrineAI] Plugin disabled!");
}
}
public java.io.InputStream getInputStreamData(String src) {
return HerobrineAI.class.getResourceAsStream(src);
}
public AICore getAICore() {
return this.aicore;
}
public EntityManager getEntityManager(){
public EntityManager getEntityManager() {
return this.entMng;
}
public static HerobrineAI getPluginCore(){
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 HerobrineSpawn(Location loc) {
HerobrineNPC = (HumanNPC) NPCman.spawnHumanNPC(ChatColor.WHITE + "Herobrine", loc);
HerobrineNPC.getBukkitEntity().setMetadata("NPC", new FixedMetadataValue(this, true));
HerobrineEntityID = HerobrineNPC.getBukkitEntity().getEntityId();
}
public void HerobrineRemove(){
HerobrineEntityID=0;
HerobrineNPC=null;
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(){
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.hasPermission("hb-ai.ignore")){
sender.sendMessage(ChatColor.RED+"[HerobrineAI] Player has ignore permission.");
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.hasPermission("hb-ai.ignore")){
log.info("[HerobrineAI] Player has ignore permission.");
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.hasPermission("hb-ai.ignore")){
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";
}
}
public boolean canAttackPlayer(Player player, Player sender) {
boolean opCheck = true;
boolean creativeCheck = true;
boolean ignoreCheck = true;
if (!configdb.AttackOP) {
if (player.isOp()) {
opCheck = false;
}
}
if (!configdb.AttackCreative) {
if (player.getGameMode() == GameMode.CREATIVE) {
creativeCheck = false;
}
}
;
if (configdb.UseIgnorePermission && player.hasPermission("hb-ai.ignore")) {
ignoreCheck = false;
}
if (opCheck && creativeCheck && ignoreCheck) {
return true;
} else {
if (!opCheck) {
sender.sendMessage(ChatColor.RED + "[HerobrineAI] Player is OP.");
} else if (!creativeCheck) {
sender.sendMessage(ChatColor.RED + "[HerobrineAI] Player is in Creative mode.");
} else if (!ignoreCheck) {
sender.sendMessage(ChatColor.RED + "[HerobrineAI] Player has ignore permission.");
}
return false;
}
}
public boolean canAttackPlayerConsole(Player player) {
boolean opCheck = true;
boolean creativeCheck = true;
boolean ignoreCheck = true;
if (!configdb.AttackOP) {
if (player.isOp()) {
opCheck = false;
}
}
if (!configdb.AttackCreative) {
if (player.getGameMode() == GameMode.CREATIVE) {
creativeCheck = false;
}
}
;
if (configdb.UseIgnorePermission && player.hasPermission("hb-ai.ignore")) {
ignoreCheck = false;
}
if (opCheck && creativeCheck && ignoreCheck) {
return true;
} else {
if (!opCheck) {
log.info("[HerobrineAI] Player is OP.");
} else if (!creativeCheck) {
log.info("[HerobrineAI] Player is in Creative mode.");
} else if (!ignoreCheck) {
log.info("[HerobrineAI] Player has ignore permission.");
}
return false;
}
}
public boolean canAttackPlayerNoMSG(Player player) {
boolean opCheck = true;
boolean creativeCheck = true;
boolean ignoreCheck = true;
if (!configdb.AttackOP) {
if (player.isOp()) {
opCheck = false;
}
}
if (!configdb.AttackCreative) {
if (player.getGameMode() == GameMode.CREATIVE) {
creativeCheck = false;
}
}
;
if (configdb.UseIgnorePermission && player.hasPermission("hb-ai.ignore")) {
ignoreCheck = false;
}
if (opCheck && creativeCheck && ignoreCheck) {
return true;
} else {
return false;
}
}
public String getAvailableWorldString() {
if (AvailableWorld) {
return "Yes";
} else {
return "No";
}
}
}

View File

@ -360,7 +360,7 @@ public class Metrics {
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, "players", Integer.toString(Bukkit.getServer().getOnlinePlayers().size()));
encodeDataPair(data, "revision", String.valueOf(REVISION));
// If we're pinging, append it

View File

@ -97,9 +97,12 @@ public class Path {
}
}else{
if (new Random().nextInt(4)==0){
if (new Random().nextInt(7)==3){
HerobrineAI.HerobrineNPC.setYaw(new Random().nextInt(360));
int yaw=new Random().nextInt(360);
HerobrineAI.HerobrineNPC.setYaw(yaw);
HerobrineAI.HerobrineNPC.setYawA(yaw);
HerobrineAI.HerobrineNPC.setPitch(0);
}

View File

@ -1,21 +1,24 @@
package org.jakub1221.herobrineai.NPC.AI;
import org.jakub1221.herobrineai.HerobrineAI;
import org.jakub1221.herobrineai.AI.Core.CoreType;
public class PathManager {
Path pathNow = null;
public void setPath(Path path){
pathNow=path;
public void setPath(Path path) {
pathNow = path;
}
public void update(){
if (pathNow!=null){
pathNow.update();
public void update() {
if (pathNow != null && HerobrineAI.getPluginCore().getAICore().getCoreTypeNow().equals(CoreType.RANDOM_POSITION)) {
pathNow.update();
}
}
public Path getPath(){
public Path getPath() {
return pathNow;
}
}

View File

@ -1,12 +1,12 @@
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 net.minecraft.server.v1_11_R1.Entity;
import net.minecraft.server.v1_11_R1.EntityHuman;
import net.minecraft.server.v1_11_R1.EntityPlayer;
import net.minecraft.server.v1_11_R1.EnumGamemode;
import net.minecraft.server.v1_11_R1.PlayerInteractManager;
import org.bukkit.craftbukkit.v1_5_R2.entity.CraftEntity;
import org.bukkit.craftbukkit.v1_11_R1.entity.CraftEntity;
import org.jakub1221.herobrineai.NPC.NPCCore;
import org.jakub1221.herobrineai.NPC.NMS.BWorld;
import org.jakub1221.herobrineai.NPC.Network.NetworkHandler;

View File

@ -1,9 +1,9 @@
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 net.minecraft.server.v1_11_R1.EntityPlayer;
import net.minecraft.server.v1_11_R1.Packet18ArmAnimation;
import net.minecraft.server.v1_11_R1.WorldServer;
import net.minecraft.server.v1_11_R1.Entity;
import org.bukkit.Location;
import org.bukkit.entity.LivingEntity;
@ -43,7 +43,7 @@ public class HumanNPC {
}
public String getName() {
return ((HumanEntity) getEntity()).name;
return ((HumanEntity) getEntity()).getName();
}
public void setPitch(float pitch){
@ -96,10 +96,14 @@ public class HumanNPC {
((EntityPlayer) getEntity()).yaw = (float) (newYaw - 90);
((EntityPlayer) getEntity()).pitch = (float) newPitch;
((EntityPlayer) getEntity()).aA = (float) (newYaw - 90);
((EntityPlayer) getEntity()).aP = (float) (newYaw - 90);
}
public void setYawA(float yaw){
((EntityPlayer) getEntity()).aP=yaw;
}
public org.bukkit.entity.Entity getBukkitEntity() {
return entity.getBukkitEntity();

View File

@ -5,13 +5,13 @@ 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 net.minecraft.server.v1_6_R3.DedicatedServer;
import net.minecraft.server.v1_6_R3.MinecraftServer;
import net.minecraft.server.v1_6_R3.WorldServer;
import org.bukkit.Bukkit;
import org.bukkit.Server;
import org.bukkit.craftbukkit.v1_5_R2.CraftServer;
import org.bukkit.craftbukkit.v1_6_R3.CraftServer;
public class BServer {
private static BServer ins;

View File

@ -6,17 +6,17 @@ 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 net.minecraft.server.v1_11_R1.AxisAlignedBB;
import net.minecraft.server.v1_11_R1.Entity;
import net.minecraft.server.v1_11_R1.EntityPlayer;
import net.minecraft.server.v1_11_R1.PlayerChunkMap;
import net.minecraft.server.v1_11_R1.WorldProvider;
import net.minecraft.server.v1_11_R1.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.craftbukkit.v1_11_R1.CraftWorld;
import org.bukkit.craftbukkit.v1_11_R1.entity.CraftPlayer;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;

View File

@ -6,8 +6,8 @@ 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 net.minecraft.server.v1_11_R1.Entity;
import net.minecraft.server.v1_11_R1.PlayerInteractManager;
import org.bukkit.Bukkit;
import org.bukkit.Location;
@ -25,15 +25,15 @@ 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 boolean isInLoaded = false;
private int lastID = 0;
public NPCCore(JavaPlugin plugin) {
server = BServer.getInstance();
@ -43,15 +43,14 @@ public class NPCCore {
} 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);
}
@ -72,7 +71,7 @@ public class NPCCore {
}
npcs.clear();
}
public BWorld getBWorld(World world) {
BWorld bworld = bworlds.get(world);
if (bworld != null) {
@ -83,63 +82,64 @@ public class NPCCore {
return bworld;
}
public void DisableTask(){
Bukkit.getServer().getScheduler().cancelTask(taskid);
}
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;
}}
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){
public void onChunkUnload(ChunkUnloadEvent event) {
for (HumanNPC humannpc : npcs) {
if (humannpc != null && event.getChunk() == humannpc.getBukkitEntity().getLocation().getBlock().getChunk()) {
}
if (humannpc != null
&& event.getChunk() == humannpc.getBukkitEntity().getLocation().getBlock().getChunk()) {
}
}
}
}
public HumanNPC spawnHumanNPC(String name, Location l) {
lastID++;
int id = 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;
}
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){
for (HumanNPC n : npcs) {
if (n.getID() == id) {
return n;
}
}
return null;
}

View File

@ -2,9 +2,9 @@ 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;
import net.minecraft.server.v1_11_R1.Connection;
import net.minecraft.server.v1_11_R1.NetworkManager;
import net.minecraft.server.v1_11_R1.Packet;
public class NetworkCore extends NetworkManager{

View File

@ -1,26 +1,26 @@
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 net.minecraft.server.v1_11_R1.EntityPlayer;
import net.minecraft.server.v1_11_R1.Packet;
import net.minecraft.server.v1_11_R1.Packet101CloseWindow;
import net.minecraft.server.v1_11_R1.Packet102WindowClick;
import net.minecraft.server.v1_11_R1.Packet106Transaction;
import net.minecraft.server.v1_11_R1.Packet10Flying;
import net.minecraft.server.v1_11_R1.Packet130UpdateSign;
import net.minecraft.server.v1_11_R1.Packet14BlockDig;
import net.minecraft.server.v1_11_R1.Packet15Place;
import net.minecraft.server.v1_11_R1.Packet16BlockItemSwitch;
import net.minecraft.server.v1_11_R1.Packet18ArmAnimation;
import net.minecraft.server.v1_11_R1.Packet19EntityAction;
import net.minecraft.server.v1_11_R1.Packet255KickDisconnect;
import net.minecraft.server.v1_11_R1.Packet3Chat;
import net.minecraft.server.v1_11_R1.Packet7UseEntity;
import net.minecraft.server.v1_11_R1.Packet9Respawn;
import net.minecraft.server.v1_11_R1.PlayerConnection;
import org.bukkit.Bukkit;
import org.bukkit.craftbukkit.v1_5_R2.CraftServer;
import org.bukkit.craftbukkit.v1_5_R2.entity.CraftPlayer;
import org.bukkit.craftbukkit.v1_11_R1.CraftServer;
import org.bukkit.craftbukkit.v1_11_R1.entity.CraftPlayer;
import org.jakub1221.herobrineai.NPC.NPCCore;
public class NetworkHandler extends PlayerConnection {
@ -34,10 +34,6 @@ public class NetworkHandler extends PlayerConnection {
return new CraftPlayer((CraftServer) Bukkit.getServer(), player);
}
@Override
public void d() {
};
@Override
public void a(Packet10Flying packet10flying) {
};

View File

@ -1,11 +1,11 @@
package org.jakub1221.herobrineai.NPC.Network;
import net.minecraft.server.v1_5_R2.Packet;
import net.minecraft.server.v1_11_R1.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.craftbukkit.v1_11_R1.entity.CraftPlayer;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;

View File

@ -3,6 +3,7 @@ package org.jakub1221.herobrineai;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.jakub1221.herobrineai.support._CustomItems;
import org.jakub1221.herobrineai.support._Factions;
import org.jakub1221.herobrineai.support._GriefPrevention;
import org.jakub1221.herobrineai.support._PreciousStones;
import org.jakub1221.herobrineai.support._Residence;
@ -17,12 +18,14 @@ public class Support {
private boolean B_CustomItems=false;
private boolean B_WorldGuard=false;
private boolean B_PreciousStones=false;
private boolean B_Factions=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;
private _Factions Factions=null;
public Support(){
ResidenceCore=new _Residence();
@ -31,11 +34,12 @@ public class Support {
CustomItems=new _CustomItems();
WorldGuard=new _WorldGuard();
PreciousStones=new _PreciousStones();
Factions=new _Factions();
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(HerobrineAI.getPluginCore(), new Runnable() {
public void run() {
CheckForPlugins();
}
}, 1 * 10L);
}, 1 * 2L);
}
public boolean isPreciousStones(){
@ -53,6 +57,9 @@ public class Support {
public boolean isTowny(){
return B_Towny;
}
public boolean isFactions(){
return B_Factions;
}
public void CheckForPlugins(){
if (ResidenceCore.Check()){
B_Residence=true;
@ -79,6 +86,10 @@ public class Support {
B_PreciousStones=true;
HerobrineAI.log.info("[HerobrineAI] PreciousStones plugin detected!");
}
if (Factions.Check()){
B_Factions=true;
HerobrineAI.log.info("[HerobrineAI] Factions plugin detected!");
}
}
public boolean isSecuredArea(Location loc){
if (B_Residence){
@ -101,6 +112,10 @@ public class Support {
if (PreciousStones.isSecuredArea(loc)){
return true;
}else{return false;}
}else if (B_Factions){
if (Factions.isSecuredArea(loc)){
return true;
}else{return false;}
}
return false;
}

View File

@ -0,0 +1,40 @@
package org.jakub1221.herobrineai;
import java.util.Collection;
import java.util.Random;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
public class Utils {
private static Random randomGen = new Random();
public static Random getRandomGen(){
return randomGen;
}
public static Player getRandomPlayer() {
Collection<? extends Player> playersOnline = Bukkit.getServer().getOnlinePlayers();
if(playersOnline.size() == 1 && ((Player)playersOnline.toArray()[0]).getEntityId() == HerobrineAI.getPluginCore().HerobrineEntityID)
return null;
int player_rolled = new Random().nextInt(playersOnline.size());
Player p = (Player) playersOnline.toArray()[player_rolled];
if (p.getEntityId() == HerobrineAI.getPluginCore().HerobrineEntityID)
return getRandomPlayer();
return p;
}
public static int getRandomPlayerNum() {
Collection<? extends Player> playersOnline = Bukkit.getServer().getOnlinePlayers();
return new Random().nextInt(playersOnline.size());
}
}

File diff suppressed because it is too large Load Diff

View File

@ -1,59 +1,68 @@
package org.jakub1221.herobrineai.entity;
import java.util.Random;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.entity.Skeleton;
import org.bukkit.inventory.ItemStack;
import org.bukkit.Color;
import org.jakub1221.herobrineai.HerobrineAI;
import org.jakub1221.herobrineai.Utils;
import org.jakub1221.herobrineai.misc.ItemName;
import net.minecraft.server.v1_5_R2.World;
import net.minecraft.server.v1_11_R1.GenericAttributes;
import net.minecraft.server.v1_11_R1.World;
public class CustomSkeleton extends net.minecraft.server.v1_5_R2.EntitySkeleton implements CustomEntity{
public class CustomSkeleton extends net.minecraft.server.v1_11_R1.EntitySkeleton implements CustomEntity {
private MobType mobType=null;
public CustomSkeleton(World world,Location loc,MobType mbt) {
private MobType mobType = null;
public CustomSkeleton(World world, Location loc, MobType mbt) {
super(world);
this.mobType=mbt;
if (mbt==MobType.DEMON){
spawnDemon(loc);
}
this.mobType = mbt;
if (mbt == MobType.DEMON) {
spawnDemon(loc);
}
}
public void spawnDemon(Location loc) {
this.getAttributeInstance(GenericAttributes.c).setValue(HerobrineAI.getPluginCore().getConfigDB().npc.getDouble("npc.Demon.Speed"));
this.getAttributeInstance(GenericAttributes.maxHealth).setValue(HerobrineAI.getPluginCore().getConfigDB().npc.getInt("npc.Demon.HP"));
this.setHealth(HerobrineAI.getPluginCore().getConfigDB().npc.getInt("npc.Demon.HP"));
this.setCustomName("Demon");
Skeleton entityCast = (Skeleton) this.getBukkitEntity();
entityCast.getEquipment().setItemInHand(new ItemStack(Material.GOLDEN_APPLE, 1));
entityCast.getEquipment().setHelmet(ItemName.colorLeatherArmor(new ItemStack(Material.LEATHER_HELMET, 1), Color.RED));
entityCast.getEquipment().setChestplate(ItemName.colorLeatherArmor(new ItemStack(Material.LEATHER_CHESTPLATE, 1), Color.RED));
entityCast.getEquipment().setLeggings(ItemName.colorLeatherArmor(new ItemStack(Material.LEATHER_LEGGINGS, 1), Color.RED));
entityCast.getEquipment().setBoots(ItemName.colorLeatherArmor(new ItemStack(Material.LEATHER_BOOTS, 1), Color.RED));
this.getBukkitEntity().teleport(loc);
}
public void spawnDemon(Location loc){
this.health=HerobrineAI.getPluginCore().getConfigDB().npc.getInt("npc.Demon.HP");
this.setCustomName("Demon");
this.maxHealth=HerobrineAI.getPluginCore().getConfigDB().npc.getInt("npc.Demon.HP");
((Skeleton)this.getBukkitEntity()).getEquipment().setItemInHand(new ItemStack(Material.GOLDEN_APPLE,1));
((Skeleton)this.getBukkitEntity()).getEquipment().setHelmet(ItemName.colorLeatherArmor(new ItemStack(Material.LEATHER_HELMET,1), Color.RED));
((Skeleton)this.getBukkitEntity()).getEquipment().setChestplate(ItemName.colorLeatherArmor(new ItemStack(Material.LEATHER_CHESTPLATE,1), Color.RED));
((Skeleton)this.getBukkitEntity()).getEquipment().setLeggings(ItemName.colorLeatherArmor(new ItemStack(Material.LEATHER_LEGGINGS,1), Color.RED));
((Skeleton)this.getBukkitEntity()).getEquipment().setBoots(ItemName.colorLeatherArmor(new ItemStack(Material.LEATHER_BOOTS,1), Color.RED));
this.getBukkitEntity().teleport(loc);
}
public CustomSkeleton(World world) {
super(world);
}
@Override
public void Kill(){
for(int i=1;i<=2500;i++){
if (HerobrineAI.getPluginCore().getConfigDB().npc.contains("npc.Demon.Drops."+Integer.toString(i))==true){
int chance=new Random().nextInt(100);
if (chance<=HerobrineAI.getPluginCore().getConfigDB().npc.getInt("npc.Demon.Drops."+Integer.toString(i)+".Chance")){
this.getBukkitEntity().getLocation().getWorld().dropItemNaturally(this.getBukkitEntity().getLocation(), new ItemStack(Material.getMaterial(i),HerobrineAI.getPluginCore().getConfigDB().npc.getInt("npc.Demon.Drops."+Integer.toString(i)+".Count")));
}
public void Kill() {
for (int i = 1; i <= 2500; i++) {
if (HerobrineAI.getPluginCore().getConfigDB().npc.contains("npc.Demon.Drops." + Integer.toString(i)) == true) {
int chance = Utils.getRandomGen().nextInt(100);
int requiredRoll = HerobrineAI.getPluginCore().getConfigDB().npc.getInt("npc.Demon.Drops." + Integer.toString(i) + ".Chance");
if (chance <= requiredRoll) {
ItemStack its = new ItemStack(Material.getMaterial(i), HerobrineAI.getPluginCore().getConfigDB().npc.getInt("npc.Demon.Drops." + Integer.toString(i) + ".Count"));
this.getBukkitEntity().getLocation().getWorld().dropItemNaturally(this.getBukkitEntity().getLocation(),its);
}
}
}
this.health=0;
this.setHealth(0);
}
@Override

View File

@ -4,80 +4,104 @@ import java.util.Random;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.entity.Skeleton;
import org.bukkit.entity.Zombie;
import org.bukkit.inventory.ItemStack;
import org.jakub1221.herobrineai.HerobrineAI;
import org.jakub1221.herobrineai.Utils;
import net.minecraft.server.v1_5_R2.ItemStack;
import net.minecraft.server.v1_5_R2.World;
import net.minecraft.server.v1_11_R1.GenericAttributes;
import net.minecraft.server.v1_11_R1.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) {
public class CustomZombie extends net.minecraft.server.v1_11_R1.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);
}
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=HerobrineAI.getPluginCore().getConfigDB().npc.getInt("npc.Guardian.HP");
this.setCustomName("Artifact Guardian");
this.maxHealth=HerobrineAI.getPluginCore().getConfigDB().npc.getInt("npc.Guardian.HP");
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=HerobrineAI.getPluginCore().getConfigDB().npc.getInt("npc.Warrior.HP");
this.setCustomName("Herobrine´s Warrior");
this.maxHealth=HerobrineAI.getPluginCore().getConfigDB().npc.getInt("npc.Warrior.HP");
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);
}
private void spawnArtifactGuardian(Location loc) {
this.getAttributeInstance(GenericAttributes.c).setValue(HerobrineAI.getPluginCore().getConfigDB().npc.getDouble("npc.Guardian.Speed"));
this.getAttributeInstance(GenericAttributes.maxHealth).setValue(HerobrineAI.getPluginCore().getConfigDB().npc.getInt("npc.Guardian.HP"));
this.setHealth(HerobrineAI.getPluginCore().getConfigDB().npc.getInt("npc.Guardian.HP"));
this.setCustomName("Artifact Guardian");
Zombie entityCast = (Zombie) this.getBukkitEntity();
entityCast.getEquipment().setItemInMainHand(new ItemStack(Material.GOLD_SWORD, 1));
entityCast.getEquipment().setHelmet(new ItemStack(Material.GOLD_HELMET, 1));
entityCast.getEquipment().setChestplate(new ItemStack(Material.GOLD_CHESTPLATE, 1));
entityCast.getEquipment().setLeggings(new ItemStack(Material.GOLD_LEGGINGS, 1));
entityCast.getEquipment().setBoots(new ItemStack(Material.GOLD_BOOTS, 1));
this.getBukkitEntity().teleport(loc);
}
private void spawnHerobrineWarrior(Location loc) {
this.getAttributeInstance(GenericAttributes.c).setValue(HerobrineAI.getPluginCore().getConfigDB().npc.getDouble("npc.Warrior.Speed"));
this.getAttributeInstance(GenericAttributes.maxHealth).setValue(HerobrineAI.getPluginCore().getConfigDB().npc.getInt("npc.Warrior.HP"));
this.setHealth(HerobrineAI.getPluginCore().getConfigDB().npc.getInt("npc.Warrior.HP"));
this.setCustomName("Herobrine Warrior");
Zombie entityCast = (Zombie) this.getBukkitEntity();
entityCast.getEquipment().setItemInMainHand(new ItemStack(Material.IRON_SWORD, 1));
entityCast.getEquipment().setHelmet(new ItemStack(Material.IRON_HELMET, 1));
entityCast.getEquipment().setChestplate(new ItemStack(Material.IRON_CHESTPLATE, 1));
entityCast.getEquipment().setLeggings(new ItemStack(Material.IRON_LEGGINGS, 1));
entityCast.getEquipment().setBoots(new ItemStack(Material.IRON_BOOTS, 1));
this.getBukkitEntity().teleport(loc);
}
public CustomZombie(World world) {
super(world);
}
@Override
public void Kill() {
String mobS = "";
if (this.mobType==MobType.ARTIFACT_GUARDIAN){mobS="Guardian";}else{mobS="Warrior";}
for(int i=1;i<=2500;i++){
if (HerobrineAI.getPluginCore().getConfigDB().npc.contains("npc."+mobS+".Drops."+Integer.toString(i))==true){
int chance=new Random().nextInt(100);
if (chance<=HerobrineAI.getPluginCore().getConfigDB().npc.getInt("npc."+mobS+".Drops."+Integer.toString(i)+".Chance")){
this.getBukkitEntity().getLocation().getWorld().dropItemNaturally(this.getBukkitEntity().getLocation(), new org.bukkit.inventory.ItemStack(Material.getMaterial(i),HerobrineAI.getPluginCore().getConfigDB().npc.getInt("npc."+mobS+".Drops."+Integer.toString(i)+".Count")));
}
}
if (this.mobType == MobType.ARTIFACT_GUARDIAN) {
mobS = "Guardian";
} else {
mobS = "Warrior";
}
this.health=0;
for (int i = 1; i <= 2500; i++) {
if (HerobrineAI.getPluginCore().getConfigDB().npc.contains("npc." + mobS + ".Drops." + Integer.toString(i)) == true) {
int chance = Utils.getRandomGen().nextInt(100);
int requiredRoll = HerobrineAI.getPluginCore().getConfigDB().npc.getInt("npc." + mobS + ".Drops." + Integer.toString(i) + ".Chance");
if (chance <= requiredRoll) {
ItemStack its = new ItemStack(Material.getMaterial(i), HerobrineAI.getPluginCore().getConfigDB().npc.getInt("npc." + mobS + ".Drops." + Integer.toString(i) + ".Count"));
this.getBukkitEntity().getLocation().getWorld().dropItemNaturally(this.getBukkitEntity().getLocation(),its);
}
}
}
this.setHealth(0);
}
@Override
public MobType getMobType() {
return this.mobType;
}
}

View File

@ -5,7 +5,6 @@ import java.util.Map;
import org.bukkit.Location;
import org.bukkit.World;
import org.jakub1221.herobrineai.HerobrineAI;
public class EntityManager {
@ -14,7 +13,7 @@ public class EntityManager {
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();
net.minecraft.server.v1_11_R1.World mcWorld = ((org.bukkit.craftbukkit.v1_11_R1.CraftWorld) world).getHandle();
CustomZombie zmb = new CustomZombie(mcWorld,loc,mbt);
mcWorld.addEntity(zmb);
mobList.put(new Integer(zmb.getBukkitEntity().getEntityId()),zmb);
@ -24,7 +23,7 @@ public class EntityManager {
public void spawnCustomSkeleton(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();
net.minecraft.server.v1_11_R1.World mcWorld = ((org.bukkit.craftbukkit.v1_11_R1.CraftWorld) world).getHandle();
CustomSkeleton zmb = new CustomSkeleton(mcWorld,loc,mbt);
mcWorld.addEntity(zmb);
mobList.put(new Integer(zmb.getBukkitEntity().getEntityId()),zmb);

View File

@ -12,92 +12,95 @@ 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.bukkit.util.Vector;
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{
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;
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) {
Object[][] checkList = {
{ new Vector(0, -1, 0), Material.NETHERRACK },
{ new Vector(-1, -1, 0), Material.GOLD_BLOCK },
{ new Vector(-1, -1, -1), Material.GOLD_BLOCK },
{ new Vector(-1, -1, 1), Material.GOLD_BLOCK },
{ new Vector(1, -1, 0), Material.GOLD_BLOCK },
{ new Vector(1, -1, -1), Material.GOLD_BLOCK },
{ new Vector(1, -1, 1), Material.GOLD_BLOCK },
{ new Vector(0, -1, -1), Material.GOLD_BLOCK },
{ new Vector(0, -1, +1), Material.GOLD_BLOCK },
{ new Vector(0, 0, 1), Material.REDSTONE_TORCH_ON },
{ new Vector(0, 0, -1), Material.REDSTONE_TORCH_ON },
{ new Vector(1, 0, 0), Material.REDSTONE_TORCH_ON },
{ new Vector(-1, 0, 0), Material.REDSTONE_TORCH_ON }
};
boolean checkListCorrect = true;
for (int i = 0; i < checkList.length; i++) {
Vector v = (Vector) checkList[i][0];
Block checkBlock = block.getWorld().getBlockAt(blockloc.getBlockX() + v.getBlockX(),
blockloc.getBlockY() + v.getBlockY(), blockloc.getBlockZ() + v.getBlockZ());
if (checkBlock.getType() != (Material) checkList[i][1]) {
checkListCorrect = false;
break;
}
}
if (checkListCorrect && HerobrineAI.getPluginCore().getConfigDB().UseTotem && !AICore.isTotemCalled) {
HerobrineAI.getPluginCore().getAICore().PlayerCallTotem(event.getPlayer());
}
}
}
}
}
@EventHandler
public void onBlockPlace(BlockPlaceEvent event){
if (event.getBlock().getWorld()==Bukkit.getServer().getWorld("world_herobrineai_graveyard")){
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

@ -7,8 +7,8 @@ import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.entity.Arrow;
import org.bukkit.entity.CreatureType;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.entity.Projectile;
@ -25,266 +25,290 @@ 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.Utils;
import org.jakub1221.herobrineai.AI.*;
import org.jakub1221.herobrineai.AI.Core.CoreType;
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;
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");
public EntityListener() {
equalsLore.add("Herobrine artifact");
equalsLore.add("Bow of Teleporting");
equalsLoreS.add("Herobrine´s artifact");
equalsLoreS.add("Herobrine artifact");
equalsLoreS.add("Sword of Lighting");
}
@SuppressWarnings("deprecation")
@EventHandler
public void onCreatureSpawn(CreatureSpawnEvent event){
Entity entity = event.getEntity();
CreatureType creatureType = event.getCreatureType();
if (event.isCancelled()) return;
if (creatureType == CreatureType.ZOMBIE){
if (HerobrineAI.getPluginCore().getConfigDB().UseNPC_Warrior){
if (new Random().nextInt(100)<HerobrineAI.getPluginCore().getConfigDB().npc.getInt("npc.Warrior.SpawnChance")){
if (HerobrineAI.getPluginCore().getEntityManager().isCustomMob(entity.getEntityId())==false){
LivingEntity ent = (LivingEntity) entity;
ent.setHealth(0);
HerobrineAI.getPluginCore().getEntityManager().spawnCustomZombie(event.getLocation(),MobType.HEROBRINE_WARRIOR);
return;
}
}
}
}else if (creatureType == CreatureType.SKELETON){
if (HerobrineAI.getPluginCore().getConfigDB().UseNPC_Demon){
if (new Random().nextInt(100)<HerobrineAI.getPluginCore().getConfigDB().npc.getInt("npc.Demon.SpawnChance")){
if (HerobrineAI.getPluginCore().getEntityManager().isCustomMob(entity.getEntityId())==false){
LivingEntity ent = (LivingEntity) entity;
ent.setHealth(0);
HerobrineAI.getPluginCore().getEntityManager().spawnCustomSkeleton(event.getLocation(),MobType.DEMON);
return;
}
}
}
}
}
@EventHandler
public void onEntityDeathEvent(EntityDeathEvent event){
if (HerobrineAI.getPluginCore().getEntityManager().isCustomMob(event.getEntity().getEntityId())){
public void onCreatureSpawn(CreatureSpawnEvent event) {
if (!HerobrineAI.isNPCDisabled) {
if (HerobrineAI.getPluginCore().getConfigDB().useWorlds.contains(event.getEntity().getLocation().getWorld().getName())) {
Entity entity = event.getEntity();
EntityType creatureType = event.getEntityType();
if (event.isCancelled())
return;
if (creatureType == EntityType.ZOMBIE) {
if (HerobrineAI.getPluginCore().getConfigDB().UseNPC_Warrior) {
if (Utils.getRandomGen().nextInt(100) < HerobrineAI.getPluginCore().getConfigDB().npc.getInt("npc.Warrior.SpawnChance")) {
if (HerobrineAI.getPluginCore().getEntityManager().isCustomMob(entity.getEntityId()) == false) {
LivingEntity ent = (LivingEntity) entity;
ent.setHealth(0);
HerobrineAI.getPluginCore().getEntityManager().spawnCustomZombie(event.getLocation(), MobType.HEROBRINE_WARRIOR);
return;
}
}
}
} else if (creatureType == EntityType.SKELETON) {
if (HerobrineAI.getPluginCore().getConfigDB().UseNPC_Demon) {
if (Utils.getRandomGen().nextInt(100) < HerobrineAI.getPluginCore().getConfigDB().npc.getInt("npc.Demon.SpawnChance")) {
if (HerobrineAI.getPluginCore().getEntityManager().isCustomMob(entity.getEntityId()) == false) {
LivingEntity ent = (LivingEntity) entity;
ent.setHealth(0);
HerobrineAI.getPluginCore().getEntityManager().spawnCustomSkeleton(event.getLocation(), MobType.DEMON);
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){
public void EntityTargetEvent(EntityTargetLivingEntityEvent e) {
LivingEntity lv = e.getTarget();
if (lv.getEntityId()==HerobrineAI.HerobrineEntityID){
if (lv.getEntityId() == HerobrineAI.HerobrineEntityID) {
e.setCancelled(true);
return;
}
}
@EventHandler
public void onProjectileHit(ProjectileHitEvent event){
if (event.getEntity() instanceof Arrow){
public void onProjectileHit(ProjectileHitEvent event) {
if (event.getEntity() instanceof Arrow) {
Arrow arrow = (Arrow) event.getEntity();
if (arrow.getShooter() instanceof Player){
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){
if (player.getItemInHand() != null) {
itemInHand = player.getItemInHand();
if (itemInHand.getType() != null) {
player.teleport(arrow.getLocation());
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){
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){
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")));
}
if (HerobrineAI.getPluginCore().getConfigDB().Killable == true
&& HerobrineAI.getPluginCore().getAICore().getCoreTypeNow() != CoreType.GRAVEYARD) {
if (dEvent.getDamager() instanceof Player) {
if (event.getDamage() >= HerobrineAI.HerobrineHP) {
HerobrineDropItems();
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) {
HerobrineDropItems();
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);
}
}
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);
} 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);
}
}else if (dEvent.getDamager() instanceof Skeleton){
Skeleton zmb = (Skeleton) dEvent.getDamager();
if (zmb.getCustomName()=="Demon"){
dEvent.setDamage(dEvent.getDamage()*3);
}
}
}
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;
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 (Utils.getRandomGen().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<EFBFBD>s Warrior") {
dEvent.setDamage(dEvent.getDamage() * 3);
}
} else if (dEvent.getDamager() instanceof Skeleton) {
Skeleton zmb = (Skeleton) dEvent.getDamager();
if (zmb.getCustomName() == "Demon") {
dEvent.setDamage(dEvent.getDamage() * 3);
}
}
}
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;
}
}
}
}
}
}
}
}
}
}
}
protected void HerobrineDropItems(){
for (int i = 1; i <= 2500; i++) {
if (HerobrineAI.getPluginCore().getConfigDB().config.contains("config.Drops." + Integer.toString(i)) == true) {
Random randgen = Utils.getRandomGen();
int chance = randgen.nextInt(100);
int requiredRoll = HerobrineAI.getPluginCore().getConfigDB().config.getInt("config.Drops." + Integer.toString(i) + ".chance");
if (chance <= requiredRoll) {
int itsAmount = HerobrineAI.getPluginCore().getConfigDB().config.getInt("config.Drops." + Integer.toString(i)+ ".count");
ItemStack its = new ItemStack(Material.getMaterial(i), itsAmount);
HerobrineAI.HerobrineNPC.getBukkitEntity().getLocation().getWorld().dropItemNaturally(
HerobrineAI.HerobrineNPC.getBukkitEntity().getLocation(),
its);
}
}
}
}
}

View File

@ -12,43 +12,52 @@ import org.jakub1221.herobrineai.AI.Core.CoreType;
import org.jakub1221.herobrineai.HerobrineAI;
import org.jakub1221.herobrineai.misc.ItemName;
public class InventoryListener implements Listener{
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()));
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) {
if (HerobrineAI.getPluginCore().getAICore().getResetLimits().isHead()) {
event.getInventory().setItem(event.getInventory().firstEmpty(),
ItemName.CreateSkull(event.getPlayer().getName()));
}
}
}
}
}
}
}
}
@EventHandler
public void onInventoryOpen(InventoryOpenEvent event){
@EventHandler
public void onInventoryOpen(InventoryOpenEvent event) {
if (event.getInventory().getType() == InventoryType.CHEST
|| event.getInventory().getType() == InventoryType.FURNACE
|| event.getInventory().getType() == InventoryType.WORKBENCH) {
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);
}
if (HerobrineAI.getPluginCore().getConfigDB().useWorlds.contains(event.getPlayer().getLocation().getWorld().getName())) {
if (HerobrineAI.getPluginCore().getConfigDB().PlaceSigns == true
&& HerobrineAI.getPluginCore().getSupport().checkSigns(event.getPlayer().getLocation())) {
if (HerobrineAI.getPluginCore().getAICore().getResetLimits().isSign()) {
Object[] data = { event.getPlayer().getLocation(), event.getPlayer().getLocation() };
HerobrineAI.getPluginCore().getAICore().getCore(CoreType.SIGNS).RunCore(data);
}
}
}
}
}
}

View File

@ -1,7 +1,6 @@
package org.jakub1221.herobrineai.listeners;
import java.util.ArrayList;
import java.util.Random;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
@ -9,7 +8,7 @@ import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.Jukebox;
import org.bukkit.craftbukkit.v1_5_R2.entity.CraftPlayer;
import org.bukkit.craftbukkit.v1_11_R1.entity.CraftPlayer;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventPriority;
@ -25,191 +24,230 @@ 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.Utils;
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;
public class PlayerListener implements Listener {
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");
public PlayerListener() {
equalsLoreS.add("Herobrine artifact");
equalsLoreS.add("Sword of Lighting");
equalsLoreA.add("Herobrine´s artifact");
equalsLoreA.add("Herobrine 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)){
HerobrineAI.getPluginCore().getAICore();
if (!AICore.isDiscCalled){
final Player player = event.getPlayer();
HerobrineAI.getPluginCore().getAICore();
AICore.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
public void onPlayerEnterBed(PlayerBedEnterEvent event){
if (new Random().nextInt(100)>75){
Player player = event.getPlayer();
((CraftPlayer) player).getHandle().a(true, false, false);
HerobrineAI.getPluginCore().getAICore().playerBedEnter(player);
}
}
@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));
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 (Utils.getRandomGen().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)) {
HerobrineAI.getPluginCore().getAICore();
if (!AICore.isDiscCalled) {
final Player player = event.getPlayer();
HerobrineAI.getPluginCore().getAICore();
AICore.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
public void onPlayerEnterBed(PlayerBedEnterEvent event) {
if (Utils.getRandomGen().nextInt(100) > 75) {
Player player = event.getPlayer();
((CraftPlayer) player).getHandle().a(true, false, false);
HerobrineAI.getPluginCore().getAICore().playerBedEnter(player);
}
}
@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 (Utils.getRandomGen().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) {
Location herobrineLocation = HerobrineAI.HerobrineNPC.getEntity().getBukkitEntity().getLocation();
if (herobrineLocation.getBlockX() > HerobrineAI.getPluginCore().getConfigDB().WalkingModeXRadius
&& herobrineLocation.getBlockX() < -HerobrineAI.getPluginCore().getConfigDB().WalkingModeXRadius
&& herobrineLocation.getBlockZ() > HerobrineAI.getPluginCore().getConfigDB().WalkingModeZRadius
&& herobrineLocation.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), 0, -20.f, 0);
nowloc.setYaw(1.f);
nowloc.setPitch(1.f);
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.49f, 4.f,
10.69f, -179.85f, 0.44999f));
}
}
}
}

View File

@ -31,7 +31,7 @@ public class WorldListener implements Listener{
if (HerobrineAI.getPluginCore().getConfigDB().BuildPyramids==true){
if (new Random().nextInt(15)==1){
if (new Random().nextInt(30)==4){
Object[] data = {event.getChunk()};
HerobrineAI.getPluginCore().getAICore().getCore(CoreType.PYRAMID).RunCore(data);
}

View File

@ -11,57 +11,96 @@ 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);
public static BlockFace getPlayerBlockFace(Location loc) {
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);
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

@ -6,58 +6,58 @@ 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 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(){
public int getID() {
return ID;
}
public int getDATA(){
public int getDATA() {
return DATA;
}
public boolean isData(){
if (DATA>0){
public boolean isData() {
if (DATA > 0) {
return true;
}
return false;
}
public ItemStack getItemStack(){
public ItemStack getItemStack() {
ItemStack item = null;
if (ID!=0){
if (DATA>0){
item = new ItemStack(ID,1,(byte) DATA);
}else{
item = new ItemStack(ID);
if (ID != 0) {
if (DATA > 0) {
item = new ItemStack(ID, 1, (byte) DATA);
} else {
item = new ItemStack(ID);
}
}
}
return item;
return item;
}
}

View File

@ -1,6 +1,5 @@
package org.jakub1221.herobrineai.misc;
import java.util.ArrayList;
import org.bukkit.ChatColor;
@ -14,50 +13,56 @@ import org.bukkit.inventory.meta.SkullMeta;
public class ItemName {
public static ItemMeta meta=null;
public static SkullMeta skullmeta=null;
public static ItemStack colorLeatherArmor(ItemStack i,Color color){
public static ItemMeta meta = null;
public static SkullMeta skullmeta = null;
public static ItemStack colorLeatherArmor(ItemStack i, Color color) {
LeatherArmorMeta la_meta = (LeatherArmorMeta) i.getItemMeta();
la_meta.setColor(color);
i.setItemMeta(la_meta);
return i;
}
public static ItemStack setName(ItemStack item, String name){
meta=item.getItemMeta();
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();
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();
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){
public static ArrayList<String> getLore(ItemStack item) {
return (ArrayList<String>) item.getItemMeta().getLore();
}
public static String getName(ItemStack item){
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();
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);
skullmeta.setDisplayName(ChatColor.RESET + data);
skull.setItemMeta(skullmeta);
return skull;
}
}

View File

@ -10,38 +10,45 @@ import org.bukkit.configuration.file.YamlConfiguration;
public class StructureLoader {
private int current=0;
private int length=0;
private int current = 0;
private int length = 0;
private InputStream inp;
private YamlConfiguration file;
public StructureLoader(InputStream in){
inp=in;
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();
}
try {
inp.close();
} catch (IOException 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);
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,17 @@
package org.jakub1221.herobrineai.support;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import com.massivecraft.factions.entity.BoardColls;
import com.massivecraft.mcore.ps.PS;
public class _Factions {
public boolean Check(){
return (Bukkit.getServer().getPluginManager().getPlugin("Factions")!=null);
}
public boolean isSecuredArea(Location loc){
return !BoardColls.get().getFactionAt(PS.valueOf(loc)).getComparisonName().equalsIgnoreCase("Wilderness");
}
}