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 name: HerobrineAI
main: org.jakub1221.herobrineai.HerobrineAI main: org.jakub1221.herobrineai.HerobrineAI
version: 3.1.0 version: 3.2.2
commands: commands:
hb-ai: hb-ai:
description: Main command. 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>

View File

@ -12,6 +12,7 @@ import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory; import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.jakub1221.herobrineai.HerobrineAI; import org.jakub1221.herobrineai.HerobrineAI;
import org.jakub1221.herobrineai.Utils;
import org.jakub1221.herobrineai.AI.Core.CoreType; import org.jakub1221.herobrineai.AI.Core.CoreType;
import org.jakub1221.herobrineai.AI.cores.Attack; import org.jakub1221.herobrineai.AI.cores.Attack;
import org.jakub1221.herobrineai.AI.cores.Book; import org.jakub1221.herobrineai.AI.cores.Book;
@ -42,38 +43,37 @@ public class AICore {
private CoreType CoreNow = CoreType.ANY; private CoreType CoreNow = CoreType.ANY;
public static HerobrineAI plugin; public static HerobrineAI plugin;
public static Player PlayerTarget; public static Player PlayerTarget;
public static boolean isTarget=false; public static boolean isTarget = false;
public static int ticksToEnd=0; public static int ticksToEnd = 0;
public static boolean isDiscCalled=false; public static boolean isDiscCalled = false;
public static boolean isTotemCalled=false; public static boolean isTotemCalled = false;
public static int _ticks=0; public static int _ticks = 0;
private boolean BuildINT=false; private ResetLimits resetLimits = null;
private boolean MainINT=false; private boolean BuildINT = false;
private boolean RandomPositionINT=false; private boolean MainINT = false;
private boolean RandomMoveINT=false; private boolean RandomPositionINT = false;
private boolean RandomSeeINT=false; private boolean RandomMoveINT = false;
private boolean CheckGravityINT=false; private boolean RandomSeeINT = false;
private boolean RandomCoreINT=false; private boolean CheckGravityINT = false;
private int RP_INT=0; private boolean RandomCoreINT = false;
private int RM_INT=0; private int RP_INT = 0;
private int RS_INT=0; private int RM_INT = 0;
private int CG_INT=0; private int RS_INT = 0;
private int MAIN_INT=0; private int CG_INT = 0;
private int BD_INT=0; private int MAIN_INT = 0;
private int RC_INT=0; private int BD_INT = 0;
private int RC_INT = 0;
public Core getCore(CoreType type){ public Core getCore(CoreType type) {
for (Core c : AllCores){ for (Core c : AllCores) {
if (c.getCoreType()==type){ if (c.getCoreType() == type) {
return c; return c;
} }
} }
return null; return null;
} }
public AICore() {
public AICore (){
/* Cores init */ /* Cores init */
AllCores.add(new Attack()); AllCores.add(new Attack());
@ -95,75 +95,102 @@ public class AICore {
AllCores.add(new Burn()); AllCores.add(new Burn());
AllCores.add(new Curse()); AllCores.add(new Curse());
resetLimits = new ResetLimits();
plugin = HerobrineAI.getPluginCore(); plugin = HerobrineAI.getPluginCore();
log.info("[HerobrineAI] Debug mode enabled!"); log.info("[HerobrineAI] Debug mode enabled!");
FindPlayer(); FindPlayer();
StartIntervals(); StartIntervals();
}
public Graveyard getGraveyard() {
return ((Graveyard) getCore(CoreType.GRAVEYARD));
}
public RandomPosition getRandomPosition() {
return ((RandomPosition) getCore(CoreType.RANDOM_POSITION));
}
public void setCoreTypeNow(CoreType c) {
CoreNow = c;
}
public CoreType getCoreTypeNow() {
return CoreNow;
}
public ResetLimits getResetLimits() {
return resetLimits;
}
public void disableAll() {
resetLimits.disable();
} }
public Graveyard getGraveyard(){return ((Graveyard)getCore(CoreType.GRAVEYARD));} public static String getStringWalkingMode() {
public RandomPosition getRandomPosition(){return ((RandomPosition)getCore(CoreType.RANDOM_POSITION));}
public void setCoreTypeNow(CoreType c){CoreNow=c;}
public CoreType getCoreTypeNow(){return CoreNow;}
public static String getStringWalkingMode(){ String result = "";
String result=""; if (HerobrineAI.getPluginCore().getAICore().getCoreTypeNow() == CoreType.RANDOM_POSITION) {
result = "Yes";
if (HerobrineAI.getPluginCore().getAICore().getCoreTypeNow() == CoreType.RANDOM_POSITION){result="Yes";}else{result="No";} } else {
result = "No";
}
return result; return result;
} }
public void playerBedEnter(Player player){ public void playerBedEnter(Player player) {
int chance = new Random().nextInt(100); int chance = new Random().nextInt(100);
if (chance<25){ if (chance < 25) {
GraveyardTeleport(player); GraveyardTeleport(player);
}else if (chance<50){ } else if (chance < 50) {
setHauntTarget(player); setHauntTarget(player);
}else{ } else {
if (HerobrineAI.getPluginCore().getConfigDB().UseNPC_Demon){ if (HerobrineAI.getPluginCore().getConfigDB().UseNPC_Demon && !HerobrineAI.isNPCDisabled) {
HerobrineAI.getPluginCore().getEntityManager().spawnCustomSkeleton(player.getLocation(), MobType.DEMON); HerobrineAI.getPluginCore().getEntityManager().spawnCustomSkeleton(player.getLocation(), MobType.DEMON);
} }
} }
} }
public void FindPlayer(){ public void FindPlayer() {
if (HerobrineAI.getPluginCore().getConfigDB().OnlyWalkingMode==false){ if (HerobrineAI.getPluginCore().getConfigDB().OnlyWalkingMode == false) {
if (isTarget==false){ if (isTarget == false) {
int att_chance= new Random().nextInt(100); int att_chance = new Random().nextInt(100);
log.info("[HerobrineAI] Generating find chance..."); log.info("[HerobrineAI] Generating find chance...");
if (att_chance-(HerobrineAI.getPluginCore().getConfigDB().ShowRate*4)<55){ if (att_chance - (HerobrineAI.getPluginCore().getConfigDB().ShowRate * 4) < 55) {
if (Bukkit.getServer().getOnlinePlayers().length>0){ if (Bukkit.getServer().getOnlinePlayers().size() > 0) {
log.info("[HerobrineAI] Finding target..."); log.info("[HerobrineAI] Finding target...");
Player [] AllOnPlayers = Bukkit.getServer().getOnlinePlayers(); Player targetPlayer = Utils.getRandomPlayer();
int player_rolled= new Random().nextInt(Bukkit.getServer().getOnlinePlayers().length-1);
if (AllOnPlayers[player_rolled].getEntityId()!=HerobrineAI.HerobrineEntityID){ if (targetPlayer.getEntityId() != HerobrineAI.HerobrineEntityID) {
if (HerobrineAI.getPluginCore().getConfigDB().useWorlds.contains(AllOnPlayers[player_rolled].getLocation().getWorld().getName()) && HerobrineAI.getPluginCore().canAttackPlayerNoMSG(AllOnPlayers[player_rolled])){ if (HerobrineAI.getPluginCore().getConfigDB().useWorlds
.contains(targetPlayer.getLocation().getWorld().getName())
&& HerobrineAI.getPluginCore().canAttackPlayerNoMSG(targetPlayer)) {
CancelTarget(CoreType.ANY); CancelTarget(CoreType.ANY);
PlayerTarget=AllOnPlayers[player_rolled]; isTarget = true;
isTarget=true; log.info("[HerobrineAI] Target founded, starting AI now! (" + targetPlayer.getName()+ ")");
log.info("[HerobrineAI] Target founded, starting AI now! ("+PlayerTarget.getName()+")");
setCoreTypeNow(CoreType.START); setCoreTypeNow(CoreType.START);
StartAI(); StartAI();
}else{ log.info("[HerobrineAI] Target is in the safe world! ("+AllOnPlayers[player_rolled].getLocation().getWorld().getName()+")");FindPlayer();} } else {
log.info("[HerobrineAI] Target is in the safe world! ("+ targetPlayer.getLocation().getWorld().getName() + ")");
FindPlayer();
}
} }
} }
} }
@ -172,174 +199,174 @@ public CoreType getCoreTypeNow(){return CoreNow;}
} }
} }
public void CancelTarget(CoreType coreType){ public void CancelTarget(CoreType coreType) {
if (coreType == CoreNow || coreType == CoreType.ANY){ if (coreType == CoreNow || coreType == CoreType.ANY) {
if (CoreNow == CoreType.RANDOM_POSITION){ if (CoreNow == CoreType.RANDOM_POSITION) {
Stop_RM(); Stop_RM();
Stop_RS(); Stop_RS();
Stop_CG(); Stop_CG();
Location nowloc = new Location((World) Bukkit.getServer().getWorlds().get(0),(float) 0,(float) -20,(float) 0); Location nowloc = new Location((World) Bukkit.getServer().getWorlds().get(0), 0, -20.f, 0);
nowloc.setYaw((float) 1);
nowloc.setPitch((float) 1); nowloc.setYaw(1.f);
nowloc.setPitch(1.f);
HerobrineAI.HerobrineNPC.moveTo(nowloc); HerobrineAI.HerobrineNPC.moveTo(nowloc);
CoreNow=CoreType.ANY; CoreNow = CoreType.ANY;
HerobrineAI.getPluginCore().getPathManager().setPath(null); HerobrineAI.getPluginCore().getPathManager().setPath(null);
} }
if (isTarget==true){ if (isTarget == true) {
if (CoreNow == CoreType.ATTACK){ if (CoreNow == CoreType.ATTACK) {
((Attack) getCore(CoreType.ATTACK)).StopHandler(); ((Attack) getCore(CoreType.ATTACK)).StopHandler();
} }
if (CoreNow == CoreType.HAUNT){ if (CoreNow == CoreType.HAUNT) {
((Haunt) getCore(CoreType.HAUNT)).StopHandler(); ((Haunt) getCore(CoreType.HAUNT)).StopHandler();
} }
_ticks = 0;
isTarget = false;
HerobrineAI.HerobrineHP = HerobrineAI.HerobrineMaxHP;
_ticks=0;
isTarget=false;
HerobrineAI.HerobrineHP=HerobrineAI.HerobrineMaxHP;
log.info("[HerobrineAI] Target cancelled."); log.info("[HerobrineAI] Target cancelled.");
Location nowloc = new Location((World) Bukkit.getServer().getWorlds().get(0),(float) 0,(float) -20,(float) 0); Location nowloc = new Location((World) Bukkit.getServer().getWorlds().get(0), 0, -20.f, 0);
nowloc.setYaw((float) 1);
nowloc.setPitch((float) 1); nowloc.setYaw(1.f);
nowloc.setPitch(1.f);
HerobrineAI.HerobrineNPC.moveTo(nowloc); HerobrineAI.HerobrineNPC.moveTo(nowloc);
CoreNow=CoreType.ANY; CoreNow = CoreType.ANY;
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(AICore.plugin, new Runnable() { Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(AICore.plugin, new Runnable() {
public void run() { public void run() {
FindPlayer(); FindPlayer();
} }
}, (6/HerobrineAI.getPluginCore().getConfigDB().ShowRate) * (HerobrineAI.getPluginCore().getConfigDB().ShowInterval * 1L)); }, (6 / HerobrineAI.getPluginCore().getConfigDB().ShowRate) * (HerobrineAI.getPluginCore().getConfigDB().ShowInterval * 1L));
} }
} }
} }
public void StartAI(){ public void StartAI() {
if (PlayerTarget.isOnline() && isTarget){ if (PlayerTarget.isOnline() && isTarget) {
if (PlayerTarget.isDead()==false){ if (PlayerTarget.isDead() == false) {
Object[] data = {PlayerTarget}; Object[] data = { PlayerTarget };
int chance= new Random().nextInt(100); int chance = new Random().nextInt(100);
if (chance<=10){ if (chance <= 10) {
if(HerobrineAI.getPluginCore().getConfigDB().UseGraveyardWorld==true){ if (HerobrineAI.getPluginCore().getConfigDB().UseGraveyardWorld == true) {
log.info("[HerobrineAI] Teleporting target to Graveyard world."); log.info("[HerobrineAI] Teleporting target to Graveyard world.");
getCore(CoreType.GRAVEYARD).RunCore(data); getCore(CoreType.GRAVEYARD).RunCore(data);
} }
}else if (chance<=25){ } else if (chance <= 25) {
getCore(CoreType.ATTACK).RunCore(data); getCore(CoreType.ATTACK).RunCore(data);
}else{ } else {
getCore(CoreType.HAUNT).RunCore(data); getCore(CoreType.HAUNT).RunCore(data);
} }
}else{CancelTarget(CoreType.START);} } else {
}else{CancelTarget(CoreType.START);} CancelTarget(CoreType.START);
}
} else {
CancelTarget(CoreType.START);
}
} }
public CoreResult setAttackTarget(Player player){ public CoreResult setAttackTarget(Player player) {
Object[] data = {player}; Object[] data = { player };
return getCore(CoreType.ATTACK).RunCore(data); return getCore(CoreType.ATTACK).RunCore(data);
} }
public CoreResult setHauntTarget(Player player){ public CoreResult setHauntTarget(Player player) {
Object[] data = {player}; Object[] data = { player };
return getCore(CoreType.HAUNT).RunCore(data); return getCore(CoreType.HAUNT).RunCore(data);
} }
public void GraveyardTeleport(final Player player) {
if (player.isOnline()) {
public void GraveyardTeleport(final Player player){
if (player.isOnline()){
CancelTarget(CoreType.ANY); CancelTarget(CoreType.ANY);
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(AICore.plugin, new Runnable() { Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(AICore.plugin, new Runnable() {
public void run() { public void run() {
Object[] data = {player}; Object[] data = { player };
getCore(CoreType.GRAVEYARD).RunCore(data); getCore(CoreType.GRAVEYARD).RunCore(data);
} }
}, 1 * 10L); }, 1 * 10L);
}
} }
public void PlayerCallTotem(Player player) {
} final String playername = player.getName();
public void PlayerCallTotem(Player player){
final String playername=player.getName();
final Location loc = (Location) player.getLocation(); final Location loc = (Location) player.getLocation();
isTotemCalled=true; isTotemCalled = true;
CancelTarget(CoreType.ANY); CancelTarget(CoreType.ANY);
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(AICore.plugin, new Runnable() { Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(AICore.plugin, new Runnable() {
public void run() { public void run() {
CancelTarget(CoreType.ANY); CancelTarget(CoreType.ANY);
Object[] data = {loc, playername}; Object[] data = { loc, playername };
getCore(CoreType.TOTEM).RunCore(data); getCore(CoreType.TOTEM).RunCore(data);
} }
}, 1 * 40L); }, 1 * 40L);
} }
private void RandomPositionInterval(){ private void RandomPositionInterval() {
if (CoreNow==CoreType.ANY){ if (CoreNow == CoreType.ANY) {
((RandomPosition)getCore(CoreType.RANDOM_POSITION)).setRandomTicks(0); ((RandomPosition) getCore(CoreType.RANDOM_POSITION)).setRandomTicks(0);
int count = HerobrineAI.getPluginCore().getConfigDB().useWorlds.size(); int count = HerobrineAI.getPluginCore().getConfigDB().useWorlds.size();
int chance=new Random().nextInt(count); int chance = new Random().nextInt(count);
Object[] data = {Bukkit.getServer().getWorld(HerobrineAI.getPluginCore().getConfigDB().useWorlds.get(chance))}; Object[] data = {
Bukkit.getServer().getWorld(HerobrineAI.getPluginCore().getConfigDB().useWorlds.get(chance)) };
getCore(CoreType.RANDOM_POSITION).RunCore(data); getCore(CoreType.RANDOM_POSITION).RunCore(data);
} }
} }
private void CheckGravityInterval(){ private void CheckGravityInterval() {
if (this.CoreNow==CoreType.RANDOM_POSITION){ if (this.CoreNow == CoreType.RANDOM_POSITION) {
((RandomPosition)getCore(CoreType.RANDOM_POSITION)).CheckGravity(); ((RandomPosition) getCore(CoreType.RANDOM_POSITION)).CheckGravity();
} }
} }
private void RandomMoveInterval(){
((RandomPosition)getCore(CoreType.RANDOM_POSITION)).RandomMove(); private void RandomMoveInterval() {
((RandomPosition) getCore(CoreType.RANDOM_POSITION)).RandomMove();
} }
private void RandomSeeInterval(){ private void RandomSeeInterval() {
if (CoreNow == CoreType.RANDOM_POSITION){ if (CoreNow == CoreType.RANDOM_POSITION) {
((RandomPosition)getCore(CoreType.RANDOM_POSITION)).CheckPlayerPosition(); ((RandomPosition) getCore(CoreType.RANDOM_POSITION)).CheckPlayerPosition();
} }
} }
private void PyramidInterval(){
if (new Random().nextBoolean()){ private void PyramidInterval() {
if (Bukkit.getServer().getOnlinePlayers().length>0){
if (new Random().nextBoolean()) {
if (Bukkit.getServer().getOnlinePlayers().size() > 0) {
log.info("[HerobrineAI] Finding pyramid target..."); log.info("[HerobrineAI] Finding pyramid target...");
Player [] AllOnPlayers = Bukkit.getServer().getOnlinePlayers();
int player_rolled= new Random().nextInt(Bukkit.getServer().getOnlinePlayers().length-1); Player player = Utils.getRandomPlayer();
if (HerobrineAI.getPluginCore().getConfigDB().useWorlds.contains(AllOnPlayers[player_rolled].getLocation().getWorld().getName())){ if (HerobrineAI.getPluginCore().getConfigDB().useWorlds.contains(player.getLocation().getWorld().getName())) {
int chance2=new Random().nextInt(100); int chance2 = new Random().nextInt(100);
if (chance2<30){ if (chance2 < 30) {
if (HerobrineAI.getPluginCore().getConfigDB().BuildPyramids==true){ if (HerobrineAI.getPluginCore().getConfigDB().BuildPyramids == true) {
Object[] data = {AllOnPlayers[player_rolled]}; Object[] data = { player };
getCore(CoreType.PYRAMID).RunCore(data); getCore(CoreType.PYRAMID).RunCore(data);
} }
}else if(chance2<70){ } else if (chance2 < 70) {
if (HerobrineAI.getPluginCore().getConfigDB().BuryPlayers){ if (HerobrineAI.getPluginCore().getConfigDB().BuryPlayers) {
Object[] data = {AllOnPlayers[player_rolled]}; Object[] data = { player };
getCore(CoreType.BURY_PLAYER).RunCore(data); getCore(CoreType.BURY_PLAYER).RunCore(data);
} }
}else{ } else {
if (HerobrineAI.getPluginCore().getConfigDB().UseHeads){ if (HerobrineAI.getPluginCore().getConfigDB().UseHeads) {
Object[] data = {AllOnPlayers[player_rolled].getName()}; Object[] data = { player.getName() };
getCore(CoreType.HEADS).RunCore(data); getCore(CoreType.HEADS).RunCore(data);
} }
} }
@ -350,17 +377,17 @@ if (CoreNow==CoreType.ANY){
} }
private void TempleInterval() {
private void TempleInterval(){ if (HerobrineAI.getPluginCore().getConfigDB().BuildTemples == true) {
if (HerobrineAI.getPluginCore().getConfigDB().BuildTemples==true){ if (new Random().nextBoolean()) {
if (new Random().nextBoolean()){ if (Bukkit.getServer().getOnlinePlayers().size() > 0) {
if (Bukkit.getServer().getOnlinePlayers().length>0){
log.info("[HerobrineAI] Finding temple target..."); log.info("[HerobrineAI] Finding temple target...");
Player [] AllOnPlayers = Bukkit.getServer().getOnlinePlayers();
int player_rolled= new Random().nextInt(Bukkit.getServer().getOnlinePlayers().length-1); Player player = Utils.getRandomPlayer();
if (HerobrineAI.getPluginCore().getConfigDB().useWorlds.contains(AllOnPlayers[player_rolled].getLocation().getWorld().getName())){
if (new Random().nextBoolean()){ if (HerobrineAI.getPluginCore().getConfigDB().useWorlds.contains(player.getLocation().getWorld().getName())) {
Object[] data = {AllOnPlayers[player_rolled]}; if (new Random().nextBoolean()) {
Object[] data = { player };
getCore(CoreType.TEMPLE).RunCore(data); getCore(CoreType.TEMPLE).RunCore(data);
} }
@ -369,61 +396,61 @@ private void TempleInterval(){
} }
} }
}
private void BuildCave() {
if (HerobrineAI.getPluginCore().getConfigDB().BuildStuff == true) {
if (new Random().nextBoolean()) {
if (Bukkit.getServer().getOnlinePlayers().size() > 0) {
} Player player = Utils.getRandomPlayer();
private void BuildCave(){ if (HerobrineAI.getPluginCore().getConfigDB().useWorlds
if (HerobrineAI.getPluginCore().getConfigDB().BuildStuff==true){ .contains(player.getLocation().getWorld().getName())) {
if (new Random().nextBoolean()){
if (Bukkit.getServer().getOnlinePlayers().length>0){
Player [] AllOnPlayers = Bukkit.getServer().getOnlinePlayers();
int player_rolled= new Random().nextInt(Bukkit.getServer().getOnlinePlayers().length-1);
if (HerobrineAI.getPluginCore().getConfigDB().useWorlds.contains(AllOnPlayers[player_rolled].getLocation().getWorld().getName())){
if (new Random().nextBoolean()){ if (new Random().nextBoolean()) {
Object[] data = {AllOnPlayers[player_rolled].getLocation()}; Object[] data = { player.getLocation() };
getCore(CoreType.BUILD_STUFF).RunCore(data); getCore(CoreType.BUILD_STUFF).RunCore(data);
} }
} }
} }
} }
} }
} }
public void callByDisc(Player player) {
public void callByDisc(Player player){ isDiscCalled = false;
isDiscCalled=false; if (player.isOnline()) {
if (player.isOnline()){
CancelTarget(CoreType.ANY); CancelTarget(CoreType.ANY);
setHauntTarget(player); setHauntTarget(player);
} }
} }
public void RandomCoreINT(){ public void RandomCoreINT() {
if (new Random().nextBoolean()){ if (new Random().nextBoolean()) {
if (Bukkit.getServer().getOnlinePlayers().length>0){ if (Bukkit.getServer().getOnlinePlayers().size() > 0) {
Player [] AllOnPlayers = Bukkit.getServer().getOnlinePlayers();
int player_rolled= new Random().nextInt(Bukkit.getServer().getOnlinePlayers().length-1);
if (AllOnPlayers[player_rolled].getEntityId()!=HerobrineAI.HerobrineEntityID){ Player player = Utils.getRandomPlayer();
if (HerobrineAI.getPluginCore().getConfigDB().useWorlds.contains(AllOnPlayers[player_rolled].getLocation().getWorld().getName())){
Object[] data = {AllOnPlayers[player_rolled]};
if (new Random().nextInt(100)<30){ if (player.getEntityId() != HerobrineAI.HerobrineEntityID) {
if (HerobrineAI.getPluginCore().getConfigDB().useWorlds
.contains(player.getLocation().getWorld().getName())) {
Object[] data = { player };
if (HerobrineAI.getPluginCore().canAttackPlayerNoMSG(player)) {
if (new Random().nextInt(100) < 30) {
getCore(CoreType.RANDOM_SOUND).RunCore(data); getCore(CoreType.RANDOM_SOUND).RunCore(data);
}else if (new Random().nextInt(100)<60){ } else if (new Random().nextInt(100) < 60) {
if (HerobrineAI.getPluginCore().getConfigDB().Burn){ if (HerobrineAI.getPluginCore().getConfigDB().Burn) {
getCore(CoreType.BURN).RunCore(data); getCore(CoreType.BURN).RunCore(data);
} }
}else if (new Random().nextInt(100)<80){ } else if (new Random().nextInt(100) < 80) {
if (HerobrineAI.getPluginCore().getConfigDB().Curse){ if (HerobrineAI.getPluginCore().getConfigDB().Curse) {
getCore(CoreType.CURSE).RunCore(data); getCore(CoreType.CURSE).RunCore(data);
} }
}else{ } else {
getCore(CoreType.RANDOM_EXPLOSION).RunCore(data); getCore(CoreType.RANDOM_EXPLOSION).RunCore(data);
} }
@ -432,69 +459,38 @@ private void BuildCave(){
} }
} }
} }
}
public void DisappearEffect() {
public void DisappearEffect(){
Location ploc = (Location) PlayerTarget.getLocation(); Location ploc = (Location) PlayerTarget.getLocation();
Location hbloc1 = (Location) HerobrineAI.HerobrineNPC.getBukkitEntity().getLocation(); for(int i=0; i < 5; i++){
hbloc1.setY(hbloc1.getY()+1); for(float j=0; j < 2; j+= 0.5f){
Location hbloc2 = (Location) HerobrineAI.HerobrineNPC.getBukkitEntity().getLocation(); Location hbloc = (Location) HerobrineAI.HerobrineNPC.getBukkitEntity().getLocation();
hbloc2.setY(hbloc2.getY()+0); hbloc.setY(hbloc.getY() + j);
Location hbloc3 = (Location) HerobrineAI.HerobrineNPC.getBukkitEntity().getLocation(); hbloc.getWorld().playEffect(hbloc, Effect.SMOKE, 80);
hbloc3.setY(hbloc3.getY()+0.5); }
Location hbloc4 = (Location) HerobrineAI.HerobrineNPC.getBukkitEntity().getLocation(); }
hbloc4.setY(hbloc4.getY()+1.5);
ploc.getWorld().playEffect(hbloc1, Effect.SMOKE, 80);
ploc.getWorld().playEffect(hbloc2, Effect.SMOKE, 80);
ploc.getWorld().playEffect(hbloc3, Effect.SMOKE, 80);
ploc.getWorld().playEffect(hbloc4, Effect.SMOKE, 80);
ploc.getWorld().playEffect(hbloc1, Effect.SMOKE, 80);
ploc.getWorld().playEffect(hbloc2, Effect.SMOKE, 80);
ploc.getWorld().playEffect(hbloc3, Effect.SMOKE, 80);
ploc.getWorld().playEffect(hbloc4, Effect.SMOKE, 80);
ploc.getWorld().playEffect(hbloc1, Effect.SMOKE, 80);
ploc.getWorld().playEffect(hbloc2, Effect.SMOKE, 80);
ploc.getWorld().playEffect(hbloc3, Effect.SMOKE, 80);
ploc.getWorld().playEffect(hbloc4, Effect.SMOKE, 80);
ploc.getWorld().playEffect(hbloc1, Effect.SMOKE, 80);
ploc.getWorld().playEffect(hbloc2, Effect.SMOKE, 80);
ploc.getWorld().playEffect(hbloc3, Effect.SMOKE, 80);
ploc.getWorld().playEffect(hbloc4, Effect.SMOKE, 80);
ploc.getWorld().playEffect(hbloc1, Effect.SMOKE, 80);
ploc.getWorld().playEffect(hbloc2, Effect.SMOKE, 80);
ploc.getWorld().playEffect(hbloc3, Effect.SMOKE, 80);
ploc.getWorld().playEffect(hbloc4, Effect.SMOKE, 80);
ploc.getWorld().playEffect(hbloc1, Effect.SMOKE, 80);
ploc.getWorld().playEffect(hbloc2, Effect.SMOKE, 80);
ploc.getWorld().playEffect(hbloc3, Effect.SMOKE, 80);
ploc.getWorld().playEffect(hbloc4, Effect.SMOKE, 80);
ploc.getWorld().playEffect(hbloc1, Effect.SMOKE, 80);
ploc.getWorld().playEffect(hbloc2, Effect.SMOKE, 80);
ploc.getWorld().playEffect(hbloc3, Effect.SMOKE, 80);
ploc.getWorld().playEffect(hbloc4, Effect.SMOKE, 80);
ploc.setY(-20); ploc.setY(-20);
HerobrineAI.HerobrineNPC.moveTo(ploc); HerobrineAI.HerobrineNPC.moveTo(ploc);
} }
private void BuildInterval(){ private void BuildInterval() {
if(new Random().nextInt(100)<75){ if (new Random().nextInt(100) < 75) {
PyramidInterval(); PyramidInterval();
}else{ } else {
TempleInterval(); TempleInterval();
} }
if (new Random().nextBoolean()){ if (new Random().nextBoolean()) {
BuildCave(); BuildCave();
} }
} }
private void StartIntervals(){ private void StartIntervals() {
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(AICore.plugin, new Runnable() { Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(AICore.plugin, new Runnable() {
public void run() { public void run() {
Start_RP(); Start_RP();
@ -505,132 +501,148 @@ private void BuildCave(){
}, 1 * 5L); }, 1 * 5L);
} }
public void Start_RP(){
RandomPositionINT=true; public void Start_RP() {
RP_INT=Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(AICore.plugin, new Runnable() { RandomPositionINT = true;
RP_INT = Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(AICore.plugin, new Runnable() {
public void run() { public void run() {
RandomPositionInterval(); RandomPositionInterval();
} }
},1 * 300L, 1 * 300L); }, 1 * 300L, 1 * 300L);
} }
public void Start_BD(){
BuildINT=true; public void Start_BD() {
BD_INT=Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(AICore.plugin, new Runnable() { BuildINT = true;
BD_INT = Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(AICore.plugin, new Runnable() {
public void run() { public void run() {
BuildInterval(); BuildInterval();
} }
}, 1 * 1L * HerobrineAI.getPluginCore().getConfigDB().BuildInterval, 1 * 1L * HerobrineAI.getPluginCore().getConfigDB().BuildInterval); }, 1 * 1L * HerobrineAI.getPluginCore().getConfigDB().BuildInterval,
1 * 1L * HerobrineAI.getPluginCore().getConfigDB().BuildInterval);
} }
public void Start_MAIN(){
MainINT=true; public void Start_MAIN() {
MAIN_INT=Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(AICore.plugin, new Runnable() { MainINT = true;
MAIN_INT = Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(AICore.plugin, new Runnable() {
public void run() { public void run() {
FindPlayer(); FindPlayer();
} }
},(6/HerobrineAI.getPluginCore().getConfigDB().ShowRate) * (HerobrineAI.getPluginCore().getConfigDB().ShowInterval * 1L),(6/HerobrineAI.getPluginCore().getConfigDB().ShowRate) * (HerobrineAI.getPluginCore().getConfigDB().ShowInterval * 1L)); }, (6 / HerobrineAI.getPluginCore().getConfigDB().ShowRate)
* (HerobrineAI.getPluginCore().getConfigDB().ShowInterval * 1L),
(6 / HerobrineAI.getPluginCore().getConfigDB().ShowRate)
* (HerobrineAI.getPluginCore().getConfigDB().ShowInterval * 1L));
} }
public void Start_RM(){
RandomMoveINT=true;
RM_INT=Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(AICore.plugin, new Runnable() { public void Start_RM() {
RandomMoveINT = true;
RM_INT = Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(AICore.plugin, new Runnable() {
public void run() { public void run() {
RandomMoveInterval(); RandomMoveInterval();
} }
},1 * 50L ,1 * 50L); }, 1 * 50L, 1 * 50L);
} }
public void Start_RS(){
RandomSeeINT=true; public void Start_RS() {
RS_INT=Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(AICore.plugin, new Runnable() { RandomSeeINT = true;
RS_INT = Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(AICore.plugin, new Runnable() {
public void run() { public void run() {
RandomSeeInterval(); RandomSeeInterval();
} }
}, 1 * 15L,1 * 15L); }, 1 * 15L, 1 * 15L);
} }
public void Start_RC(){ public void Start_RC() {
RandomCoreINT=true; RandomCoreINT = true;
RC_INT=Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(AICore.plugin, new Runnable() { RC_INT = Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(AICore.plugin, new Runnable() {
public void run() { public void run() {
RandomCoreINT(); RandomCoreINT();
} }
}, (long)(HerobrineAI.getPluginCore().getConfigDB().ShowInterval/1.5),(long)(HerobrineAI.getPluginCore().getConfigDB().ShowInterval/1.5)); }, (long) (HerobrineAI.getPluginCore().getConfigDB().ShowInterval / 1.5),
(long) (HerobrineAI.getPluginCore().getConfigDB().ShowInterval / 1.5));
} }
public void Start_CG(){ public void Start_CG() {
CheckGravityINT=true; CheckGravityINT = true;
CG_INT=Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(AICore.plugin, new Runnable() { CG_INT = Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(AICore.plugin, new Runnable() {
public void run() { public void run() {
CheckGravityInterval(); CheckGravityInterval();
} }
}, 1 * 10L,1 * 10L); }, 1 * 10L, 1 * 10L);
} }
public void Stop_RP(){ public void Stop_RP() {
if (RandomPositionINT){ if (RandomPositionINT) {
RandomPositionINT=false; RandomPositionINT = false;
Bukkit.getServer().getScheduler().cancelTask(RP_INT); Bukkit.getServer().getScheduler().cancelTask(RP_INT);
} }
} }
public void Stop_BD(){
if (BuildINT){ public void Stop_BD() {
BuildINT=false; if (BuildINT) {
BuildINT = false;
Bukkit.getServer().getScheduler().cancelTask(BD_INT); Bukkit.getServer().getScheduler().cancelTask(BD_INT);
} }
} }
public void Stop_RS(){
if (RandomSeeINT){ public void Stop_RS() {
RandomSeeINT=false; if (RandomSeeINT) {
RandomSeeINT = false;
Bukkit.getServer().getScheduler().cancelTask(RS_INT); Bukkit.getServer().getScheduler().cancelTask(RS_INT);
} }
} }
public void Stop_RM(){
if (RandomMoveINT){ public void Stop_RM() {
RandomMoveINT=false; if (RandomMoveINT) {
RandomMoveINT = false;
Bukkit.getServer().getScheduler().cancelTask(RM_INT); Bukkit.getServer().getScheduler().cancelTask(RM_INT);
} }
} }
public void Stop_RC(){
if (RandomCoreINT){ public void Stop_RC() {
RandomCoreINT=false; if (RandomCoreINT) {
RandomCoreINT = false;
Bukkit.getServer().getScheduler().cancelTask(RC_INT); Bukkit.getServer().getScheduler().cancelTask(RC_INT);
} }
} }
public void Stop_CG(){
if (CheckGravityINT){ public void Stop_CG() {
CheckGravityINT=false; if (CheckGravityINT) {
CheckGravityINT = false;
Bukkit.getServer().getScheduler().cancelTask(CG_INT); Bukkit.getServer().getScheduler().cancelTask(CG_INT);
} }
} }
public void Stop_MAIN(){
if (MainINT){ public void Stop_MAIN() {
MainINT=false; if (MainINT) {
MainINT = false;
Bukkit.getServer().getScheduler().cancelTask(MAIN_INT); Bukkit.getServer().getScheduler().cancelTask(MAIN_INT);
} }
} }
public ItemStack createAncientSword(){ public ItemStack createAncientSword() {
ItemStack item = new ItemStack(Material.GOLD_SWORD); ItemStack item = new ItemStack(Material.GOLD_SWORD);
String name = "Ancient Sword"; String name = "Ancient Sword";
ArrayList<String> lore = new ArrayList<String>(); ArrayList<String> lore = new ArrayList<String>();
lore.add("AncientSword"); lore.add("AncientSword");
lore.add("Very old and mysterious sword."); lore.add("Very old and mysterious sword.");
lore.add("This will protect you aganist Herobrine."); lore.add("It protects you aganist Herobrine.");
item = ItemName.setNameAndLore(item, name, lore); item = ItemName.setNameAndLore(item, name, lore);
return item; return item;
} }
public boolean isAncientSword(ItemStack item){ public boolean isAncientSword(ItemStack item) {
ArrayList<String> lore = new ArrayList<String>(); ArrayList<String> lore = new ArrayList<String>();
lore.add("AncientSword"); lore.add("AncientSword");
lore.add("Very old and mysterious sword."); lore.add("Very old and mysterious sword.");
lore.add("This will protect you aganist Herobrine."); lore.add("It protects you aganist Herobrine.");
if (item!=null){ if (item != null) {
if (item.getItemMeta()!=null){ if (item.getItemMeta() != null) {
if (item.getItemMeta().getLore()!=null){ if (item.getItemMeta().getLore() != null) {
ArrayList<String> ilore = (ArrayList<String>) item.getItemMeta().getLore(); ArrayList<String> ilore = (ArrayList<String>) item.getItemMeta().getLore();
if (ilore.containsAll(lore)){ if (ilore.containsAll(lore)) {
return true; return true;
} }
@ -641,13 +653,13 @@ private void BuildCave(){
return false; return false;
} }
public boolean checkAncientSword(Inventory inv){ public boolean checkAncientSword(Inventory inv) {
ItemStack[] itemlist = inv.getContents(); ItemStack[] itemlist = inv.getContents();
ItemStack item = null; ItemStack item = null;
int i=0; int i = 0;
for (i=0;i<=itemlist.length-1;i++){ for (i = 0; i <= itemlist.length - 1; i++) {
item=itemlist[i]; item = itemlist[i];
if (isAncientSword(item)){ if (isAncientSword(item)) {
return true; return true;
} }
} }

View File

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

View File

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

View File

@ -7,16 +7,15 @@ import org.jakub1221.herobrineai.HerobrineAI;
public class Message { public class Message {
public static void SendMessage(Player player){ public static void SendMessage(Player player) {
if (HerobrineAI.getPluginCore().getConfigDB().SendMessages==true){ if (HerobrineAI.getPluginCore().getConfigDB().SendMessages == true) {
int count = HerobrineAI.getPluginCore().getConfigDB().useMessages.size(); int count = HerobrineAI.getPluginCore().getConfigDB().useMessages.size();
Random randgen = new Random(); Random randgen = new Random();
int randmsg=randgen.nextInt(count); int randmsg = randgen.nextInt(count);
player.sendMessage("<Herobrine> "+HerobrineAI.getPluginCore().getConfigDB().useMessages.get(randmsg));
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,39 +11,43 @@ import org.bukkit.entity.Player;
import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType; import org.bukkit.potion.PotionEffectType;
import org.jakub1221.herobrineai.HerobrineAI; import org.jakub1221.herobrineai.HerobrineAI;
import org.jakub1221.herobrineai.Utils;
import org.jakub1221.herobrineai.AI.AICore; import org.jakub1221.herobrineai.AI.AICore;
import org.jakub1221.herobrineai.AI.Core; import org.jakub1221.herobrineai.AI.Core;
import org.jakub1221.herobrineai.AI.CoreResult; import org.jakub1221.herobrineai.AI.CoreResult;
import org.jakub1221.herobrineai.AI.Message; import org.jakub1221.herobrineai.AI.Message;
import org.jakub1221.herobrineai.AI.extensions.Position; import org.jakub1221.herobrineai.AI.extensions.Position;
public class Attack extends Core{ public class Attack extends Core {
private int ticksToEnd = 0; private int ticksToEnd = 0;
private int HandlerINT=0; private int HandlerINT = 0;
private boolean isHandler=false; private boolean isHandler = false;
public Attack(){ public Attack() {
super(CoreType.ATTACK,AppearType.APPEAR); super(CoreType.ATTACK, AppearType.APPEAR, HerobrineAI.getPluginCore());
} }
public CoreResult CallCore(Object[] data){ public CoreResult CallCore(Object[] data) {
return setAttackTarget((Player)data[0]); return setAttackTarget((Player) data[0]);
} }
public CoreResult setAttackTarget(Player player){ public CoreResult setAttackTarget(Player player) {
if (!HerobrineAI.getPluginCore().getAICore().checkAncientSword(player.getInventory())){ if (!PluginCore.getAICore().checkAncientSword(player.getInventory())) {
if (HerobrineAI.getPluginCore().getSupport().checkAttack(player.getLocation())){ if (PluginCore.getSupport().checkAttack(player.getLocation())) {
if (!PluginCore.canAttackPlayerNoMSG(player)) {
return new CoreResult(false, "This player is protected.");
}
HerobrineAI.HerobrineHP=HerobrineAI.HerobrineMaxHP; HerobrineAI.HerobrineHP = HerobrineAI.HerobrineMaxHP;
ticksToEnd=0; ticksToEnd = 0;
AICore.PlayerTarget=player; AICore.PlayerTarget = player;
AICore.isTarget=true; AICore.isTarget = true;
AICore.log.info("[HerobrineAI] Teleporting to target. ("+ AICore.PlayerTarget.getName()+")"); AICore.log.info("[HerobrineAI] Teleporting to target. (" + AICore.PlayerTarget.getName() + ")");
Location ploc = (Location) AICore.PlayerTarget.getLocation(); Location ploc = (Location) AICore.PlayerTarget.getLocation();
Object[] data = {ploc}; Object[] data = { ploc };
HerobrineAI.getPluginCore().getAICore().getCore(CoreType.DESTROY_TORCHES).RunCore(data); PluginCore.getAICore().getCore(CoreType.DESTROY_TORCHES).RunCore(data);
if (HerobrineAI.getPluginCore().getConfigDB().UsePotionEffects){ if (PluginCore.getConfigDB().UsePotionEffects) {
AICore.PlayerTarget.addPotionEffect(new PotionEffect(PotionEffectType.CONFUSION, 1000, 1)); AICore.PlayerTarget.addPotionEffect(new PotionEffect(PotionEffectType.CONFUSION, 1000, 1));
AICore.PlayerTarget.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, 1000, 1)); AICore.PlayerTarget.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, 1000, 1));
AICore.PlayerTarget.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 1000, 1)); AICore.PlayerTarget.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 1000, 1));
@ -56,174 +60,159 @@ public class Attack extends Core{
StartHandler(); StartHandler();
return new CoreResult(true,"Herobrine attacks "+player.getName()+"!"); return new CoreResult(true, "Herobrine attacks " + player.getName() + "!");
}else{ } else {
return new CoreResult(false,"Player is in secure area."); return new CoreResult(false, "Player is in secure area.");
} }
}else{ } else {
return new CoreResult(false,"Player has Ancient Sword."); return new CoreResult(false, "Player has Ancient Sword.");
} }
} }
public void StopHandler(){ public void StopHandler() {
if (isHandler){ if (isHandler) {
Bukkit.getScheduler().cancelTask(HandlerINT); Bukkit.getScheduler().cancelTask(HandlerINT);
isHandler=false; isHandler = false;
} }
} }
public void StartHandler(){ public void StartHandler() {
KeepLooking(); KeepLooking();
FollowHideRepeat(); FollowHideRepeat();
isHandler=true; isHandler = true;
HandlerINT=Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(AICore.plugin, new Runnable() { HandlerINT = Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(AICore.plugin, new Runnable() {
public void run() { public void run() {
Handler(); Handler();
} }
}, 1 * 5L,1 * 5L); }, 1 * 5L, 1 * 5L);
} }
private void Handler(){ private void Handler() {
KeepLooking(); 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(); FollowHideRepeat();
}
} }
public void KeepLooking(){ public void KeepLooking() {
if (AICore.PlayerTarget.isOnline() && AICore.isTarget && HerobrineAI.getPluginCore().getAICore().getCoreTypeNow()==CoreType.ATTACK){ if (AICore.PlayerTarget.isOnline() && AICore.isTarget
if (AICore.PlayerTarget.isDead()==false){ && PluginCore.getAICore().getCoreTypeNow() == CoreType.ATTACK) {
if (ticksToEnd==160){HerobrineAI.getPluginCore().getAICore().CancelTarget(CoreType.ATTACK);}else{ if (AICore.PlayerTarget.isDead() == false) {
if (ticksToEnd == 160) {
PluginCore.getAICore().CancelTarget(CoreType.ATTACK);
} else {
ticksToEnd++; ticksToEnd++;
Location ploc = (Location) AICore.PlayerTarget.getLocation(); Location ploc = (Location) AICore.PlayerTarget.getLocation();
ploc.setY(ploc.getY()+1.5); ploc.setY(ploc.getY() + 1.5);
HerobrineAI.HerobrineNPC.lookAtPoint(ploc); HerobrineAI.HerobrineNPC.lookAtPoint(ploc);
if (HerobrineAI.getPluginCore().getConfigDB().Lighting==true){ if (PluginCore.getConfigDB().Lighting == true) {
int lchance= new Random().nextInt(100); int lchance = Utils.getRandomGen().nextInt(100);
if (lchance>75){ if (lchance > 75) {
Location newloc = (Location) ploc; Location newloc = (Location) ploc;
int randx= new Random().nextInt(50); int randx = Utils.getRandomGen().nextInt(50);
int randz= new Random().nextInt(50); int randz = Utils.getRandomGen().nextInt(50);
if (new Random().nextBoolean()){ if (Utils.getRandomGen().nextBoolean()) {
newloc.setX(newloc.getX()+randx); newloc.setX(newloc.getX() + randx);
}else{ } else {
newloc.setX(newloc.getX()-randx); newloc.setX(newloc.getX() - randx);
} }
if (new Random().nextBoolean()){ if (Utils.getRandomGen().nextBoolean()) {
newloc.setZ(newloc.getZ()+randz); newloc.setZ(newloc.getZ() + randz);
}else{ } else {
newloc.setZ(newloc.getZ()-randz); newloc.setZ(newloc.getZ() - randz);
} }
newloc.setY(250); newloc.setY(250);
newloc.getWorld().strikeLightning(newloc); newloc.getWorld().strikeLightning(newloc);
} }
} }
} }
}else{HerobrineAI.getPluginCore().getAICore().CancelTarget(CoreType.ATTACK);} } else {
}else{HerobrineAI.getPluginCore().getAICore().CancelTarget(CoreType.ATTACK);} PluginCore.getAICore().CancelTarget(CoreType.ATTACK);
}
} else {
PluginCore.getAICore().CancelTarget(CoreType.ATTACK);
}
} }
public void Follow(){ public void Follow() {
if (AICore.PlayerTarget.isOnline() && AICore.isTarget && HerobrineAI.getPluginCore().getAICore().getCoreTypeNow()==CoreType.ATTACK){ if (AICore.PlayerTarget.isOnline()
if (AICore.PlayerTarget.isDead()==false){ && AICore.isTarget
if (HerobrineAI.getPluginCore().getConfigDB().useWorlds.contains(AICore.PlayerTarget.getWorld().getName()) && HerobrineAI.getPluginCore().getSupport().checkAttack(AICore.PlayerTarget.getLocation())){ && 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())); HerobrineAI.HerobrineNPC.moveTo(Position.getTeleportPosition(AICore.PlayerTarget.getLocation()));
Location ploc = (Location) AICore.PlayerTarget.getLocation(); Location ploc = (Location) AICore.PlayerTarget.getLocation();
ploc.setY(ploc.getY()+1.5); ploc.setY(ploc.getY() + 1.5);
HerobrineAI.HerobrineNPC.lookAtPoint(ploc); HerobrineAI.HerobrineNPC.lookAtPoint(ploc);
AICore.PlayerTarget.playSound(AICore.PlayerTarget.getLocation(),Sound.BREATH,(float) 0.75,(float) 0.75); AICore.PlayerTarget.playSound(AICore.PlayerTarget.getLocation(), Sound.ENTITY_PLAYER_BREATH, 0.75f, 0.75f);
if (HerobrineAI.getPluginCore().getConfigDB().HitPlayer==true){ if (PluginCore.getConfigDB().HitPlayer == true) {
int hitchance= new Random().nextInt(100); int hitchance = Utils.getRandomGen().nextInt(100);
if (hitchance<55){ if (hitchance < 55) {
AICore.PlayerTarget.playSound(AICore.PlayerTarget.getLocation(), Sound.HURT,(float) 0.75,(float) 0.75); AICore.PlayerTarget.playSound(AICore.PlayerTarget.getLocation(), Sound.ENTITY_PLAYER_HURT, 0.75f, 0.75f);
if (AICore.PlayerTarget.getHealth()>=4){
AICore.PlayerTarget.setHealth(AICore.PlayerTarget.getHealth()-4);
}else{AICore.PlayerTarget.setHealth(0);}
AICore.PlayerTarget.damage(4);
} }
} }
}else{HerobrineAI.getPluginCore().getAICore().CancelTarget(CoreType.ATTACK);} } else {
}else{HerobrineAI.getPluginCore().getAICore().CancelTarget(CoreType.ATTACK);} PluginCore.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 Hide(){ public void Hide() {
if (AICore.PlayerTarget.isOnline() && AICore.isTarget && HerobrineAI.getPluginCore().getAICore().getCoreTypeNow()==CoreType.ATTACK){ if (AICore.PlayerTarget.isOnline() && AICore.isTarget
if (AICore.PlayerTarget.isDead()==false){ && PluginCore.getAICore().getCoreTypeNow() == CoreType.ATTACK) {
if (AICore.PlayerTarget.isDead() == false) {
Location ploc = (Location) AICore.PlayerTarget.getLocation(); Location ploc = (Location) AICore.PlayerTarget.getLocation();
ploc.setY(-20); ploc.setY(-20);
Location hbloc1 = (Location) HerobrineAI.HerobrineNPC.getBukkitEntity().getLocation(); for(int i=0; i < 5; i++){
hbloc1.setY(hbloc1.getY()+1); for(float j=0; j < 2; j+= 0.5f){
Location hbloc2 = (Location) HerobrineAI.HerobrineNPC.getBukkitEntity().getLocation(); Location hbloc = (Location) HerobrineAI.HerobrineNPC.getBukkitEntity().getLocation();
hbloc2.setY(hbloc2.getY()+0); hbloc.setY(hbloc.getY() + j);
Location hbloc3 = (Location) HerobrineAI.HerobrineNPC.getBukkitEntity().getLocation(); hbloc.getWorld().playEffect(hbloc, Effect.SMOKE, 80);
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);
} }
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); HerobrineAI.HerobrineNPC.moveTo(ploc);
}else{HerobrineAI.getPluginCore().getAICore().CancelTarget(CoreType.ATTACK);} } else {
}else{HerobrineAI.getPluginCore().getAICore().CancelTarget(CoreType.ATTACK);} PluginCore.getAICore().CancelTarget(CoreType.ATTACK);
}
} else {
PluginCore.getAICore().CancelTarget(CoreType.ATTACK);
}
} }
public void FollowHideRepeat(){ public void FollowHideRepeat() {
if (AICore.PlayerTarget.isOnline() && AICore.isTarget && HerobrineAI.getPluginCore().getAICore().getCoreTypeNow()==CoreType.ATTACK){ if (AICore.PlayerTarget.isOnline() && AICore.isTarget
if (AICore.PlayerTarget.isDead()==false){ && PluginCore.getAICore().getCoreTypeNow() == CoreType.ATTACK) {
if (AICore.PlayerTarget.isDead() == false) {
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(AICore.plugin, new Runnable() { Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(AICore.plugin, new Runnable() {
public void run() { public void run() {
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(AICore.plugin, new Runnable() { Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(AICore.plugin, new Runnable() {
@ -234,7 +223,11 @@ public class Attack extends Core{
Follow(); Follow();
} }
}, 1 * 45L); }, 1 * 45L);
}else{HerobrineAI.getPluginCore().getAICore().CancelTarget(CoreType.ATTACK);} } else {
}else{HerobrineAI.getPluginCore().getAICore().CancelTarget(CoreType.ATTACK);} PluginCore.getAICore().CancelTarget(CoreType.ATTACK);
}
} else {
PluginCore.getAICore().CancelTarget(CoreType.ATTACK);
}
} }
} }

View File

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

View File

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

View File

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

View File

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

View File

@ -12,7 +12,7 @@ import org.jakub1221.herobrineai.AI.CoreResult;
public class Curse extends Core { public class Curse extends Core {
public Curse() { public Curse() {
super(CoreType.CURSE, AppearType.NORMAL); super(CoreType.CURSE, AppearType.NORMAL, HerobrineAI.getPluginCore());
} }
@Override @Override
@ -26,22 +26,20 @@ public class Curse extends Core {
player.addPotionEffect(new PotionEffect(PotionEffectType.POISON, 50, 1)); player.addPotionEffect(new PotionEffect(PotionEffectType.POISON, 50, 1));
player.addPotionEffect(new PotionEffect(PotionEffectType.WEAKNESS, 1000, 1)); player.addPotionEffect(new PotionEffect(PotionEffectType.WEAKNESS, 1000, 1));
int i = 0; for (int i=0; i< 3 ; i++) {
while(i!=3){ Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(HerobrineAI.getPluginCore(), new Runnable() {
i++;
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(HerobrineAI.getPluginCore(), new Runnable(){
@Override @Override
public void run() { public void run() {
player.getLocation().getWorld().strikeLightning(new Location(player.getLocation().getWorld(),player.getLocation().getX(),player.getLocation().getY()+1,player.getLocation().getZ())); 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)); player.addPotionEffect(new PotionEffect(PotionEffectType.POISON, 50, 1));
} }
}, i*150L); }, i * 150L);
} }
return new CoreResult(true, "Player cursed!");
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.Core;
import org.jakub1221.herobrineai.AI.CoreResult; import org.jakub1221.herobrineai.AI.CoreResult;
public class DestroyTorches extends Core{ public class DestroyTorches extends Core {
public DestroyTorches(){ public DestroyTorches() {
super(CoreType.DESTROY_TORCHES,AppearType.NORMAL); super(CoreType.DESTROY_TORCHES, AppearType.NORMAL, HerobrineAI.getPluginCore());
} }
public CoreResult CallCore(Object[] data){ public CoreResult CallCore(Object[] data) {
return destroyTorches((Location) data[0]); return destroyTorches((Location) data[0]);
} }
public CoreResult destroyTorches(Location loc){ public CoreResult destroyTorches(Location loc) {
if (HerobrineAI.getPluginCore().getConfigDB().DestroyTorches==true){ if (HerobrineAI.getPluginCore().getConfigDB().DestroyTorches == true) {
int x = loc.getBlockX();
int y = loc.getBlockY();
int z = loc.getBlockZ();
World world = loc.getWorld();
int x=loc.getBlockX(); int i = -(HerobrineAI.getPluginCore().getConfigDB().DestroyTorchesRadius); // Y
int y=loc.getBlockY(); int ii = -(HerobrineAI.getPluginCore().getConfigDB().DestroyTorchesRadius); // X
int z=loc.getBlockZ(); int iii = -(HerobrineAI.getPluginCore().getConfigDB().DestroyTorchesRadius); // Z
World world=loc.getWorld();
int i=-(HerobrineAI.getPluginCore().getConfigDB().DestroyTorchesRadius); // Y for (i = -(HerobrineAI.getPluginCore().getConfigDB().DestroyTorchesRadius); i <= HerobrineAI.getPluginCore()
int ii=-(HerobrineAI.getPluginCore().getConfigDB().DestroyTorchesRadius); // X .getConfigDB().DestroyTorchesRadius; i++) {
int iii=-(HerobrineAI.getPluginCore().getConfigDB().DestroyTorchesRadius); // Z for (ii = -(HerobrineAI.getPluginCore().getConfigDB().DestroyTorchesRadius); ii <= HerobrineAI
.getPluginCore().getConfigDB().DestroyTorchesRadius; ii++) {
for(i=-(HerobrineAI.getPluginCore().getConfigDB().DestroyTorchesRadius);i<=HerobrineAI.getPluginCore().getConfigDB().DestroyTorchesRadius;i++){ for (iii = -(HerobrineAI.getPluginCore().getConfigDB().DestroyTorchesRadius); iii <= HerobrineAI
for(ii=-(HerobrineAI.getPluginCore().getConfigDB().DestroyTorchesRadius);ii<=HerobrineAI.getPluginCore().getConfigDB().DestroyTorchesRadius;ii++){ .getPluginCore().getConfigDB().DestroyTorchesRadius; iii++) {
for(iii=-(HerobrineAI.getPluginCore().getConfigDB().DestroyTorchesRadius);iii<=HerobrineAI.getPluginCore().getConfigDB().DestroyTorchesRadius;iii++){ if (world.getBlockAt(x + ii, y + i, z + iii).getType() == Material.TORCH) {
if(world.getBlockAt(x+ii, y+i, z+iii).getType() == Material.TORCH){ world.getBlockAt(x + ii, y + i, z + iii).breakNaturally();
world.getBlockAt(x+ii, y+i, z+iii).breakNaturally(); return new CoreResult(true, "Torches destroyed!");
return new CoreResult(true,"Torches destroyed!");
} }
} }
} }
} }
} }
return new CoreResult(false,"Cannot destroy torches."); return new CoreResult(false, "Cannot destroy torches.");
} }
} }

View File

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

View File

@ -1,126 +1,139 @@
package org.jakub1221.herobrineai.AI.cores; 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.Random;
import java.util.Set;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.entity.CreatureType; import org.bukkit.block.Block;
import org.bukkit.entity.EntityType; import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.entity.Wolf; import org.bukkit.entity.Wolf;
import org.jakub1221.herobrineai.HerobrineAI; import org.jakub1221.herobrineai.HerobrineAI;
import org.jakub1221.herobrineai.Utils;
import org.jakub1221.herobrineai.AI.AICore; import org.jakub1221.herobrineai.AI.AICore;
import org.jakub1221.herobrineai.AI.Core; import org.jakub1221.herobrineai.AI.Core;
import org.jakub1221.herobrineai.AI.CoreResult; 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 _ticks = 0;
private int ticksToEnd = 0;
private int spawnedWolves = 0; private int spawnedWolves = 0;
private int spawnedBats = 0; private int spawnedBats = 0;
private int KL_INT=0; private int KL_INT = 0;
private int PS_INT=0; private int PS_INT = 0;
private boolean isHandler=false; private boolean isHandler = false;
private boolean isFirst = true;
public Haunt(){ public Haunt() {
super(CoreType.HAUNT,AppearType.APPEAR); super(CoreType.HAUNT, AppearType.APPEAR, HerobrineAI.getPluginCore());
} }
public CoreResult CallCore(Object[] data){ public CoreResult CallCore(Object[] data) {
return setHauntTarget((Player) data[0]); return setHauntTarget((Player) data[0]);
} }
public CoreResult setHauntTarget(Player player){ public CoreResult setHauntTarget(Player player) {
if (HerobrineAI.getPluginCore().getSupport().checkHaunt(player.getLocation())){ if (PluginCore.getSupport().checkHaunt(player.getLocation())) {
if (!PluginCore.canAttackPlayerNoMSG(player)) {
spawnedWolves=0; return new CoreResult(false, "This player is protected.");
spawnedBats=0; }
_ticks=0; spawnedWolves = 0;
ticksToEnd=0; spawnedBats = 0;
AICore.isTarget=true; _ticks = 0;
AICore.PlayerTarget=player; isFirst = true;
AICore.isTarget = true;
AICore.PlayerTarget = player;
AICore.log.info("[HerobrineAI] Hauntig player!"); AICore.log.info("[HerobrineAI] Hauntig player!");
Location loc = (Location) HerobrineAI.HerobrineNPC.getBukkitEntity().getLocation(); Location loc = (Location) HerobrineAI.HerobrineNPC.getBukkitEntity().getLocation();
loc.setY(-20); loc.setY(-20);
HerobrineAI.HerobrineNPC.moveTo(loc); HerobrineAI.HerobrineNPC.moveTo(loc);
StartHandler(); StartHandler();
return new CoreResult(true,"Herobrine haunts "+player.getName()+"!"); 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(){ public void StartHandler() {
isHandler=true; isHandler = true;
KL_INT=Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(AICore.plugin, new Runnable() { KL_INT = Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(AICore.plugin, new Runnable() {
public void run() { public void run() {
KeepLookingHaunt(); KeepLookingHaunt();
} }
}, 1 * 5L, 1 * 5L); }, 1 * 5L, 1 * 5L);
PS_INT=Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(AICore.plugin, new Runnable() { PS_INT = Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(AICore.plugin, new Runnable() {
public void run() { public void run() {
PlaySounds(); PlaySounds();
} }
}, 1 * 35L, 1 * 35L); }, 1 * 35L, 1 * 35L);
} }
public void StopHandler(){ public void StopHandler() {
if(isHandler){ if (isHandler) {
isHandler=false; isHandler = false;
Bukkit.getScheduler().cancelTask(KL_INT); Bukkit.getScheduler().cancelTask(KL_INT);
Bukkit.getScheduler().cancelTask(PS_INT); Bukkit.getScheduler().cancelTask(PS_INT);
} }
} }
public void PlaySounds(){ public void PlaySounds() {
if (AICore.PlayerTarget.isOnline() && AICore.isTarget && HerobrineAI.getPluginCore().getAICore().getCoreTypeNow()==CoreType.HAUNT){ if (AICore.PlayerTarget.isOnline() && AICore.isTarget
if (AICore.PlayerTarget.isDead()==false){ && PluginCore.getAICore().getCoreTypeNow() == CoreType.HAUNT) {
if (ticksToEnd==35){HerobrineAI.getPluginCore().getAICore().CancelTarget(CoreType.HAUNT);}else{ if (AICore.PlayerTarget.isDead() == false) {
ticksToEnd++; if (_ticks > 290) {
Object[] data = {AICore.PlayerTarget}; PluginCore.getAICore().CancelTarget(CoreType.HAUNT);
HerobrineAI.getPluginCore().getAICore().getCore(CoreType.SOUNDF).RunCore(data); } else {
Object[] data = { AICore.PlayerTarget };
PluginCore.getAICore().getCore(CoreType.SOUNDF).RunCore(data);
Location ploc = (Location) AICore.PlayerTarget.getLocation(); Location ploc = (Location) AICore.PlayerTarget.getLocation();
Random randxgen = new Random(); Random randxgen = Utils.getRandomGen();
int randx= randxgen.nextInt(100); int randx = randxgen.nextInt(100);
if (randx<70){} if (randx < 70) {
else if (randx<80 && spawnedBats<=3){ } else if (randx < 80 && spawnedBats < 2) {
if (HerobrineAI.getPluginCore().getConfigDB().SpawnBats){ if (PluginCore.getConfigDB().SpawnBats) {
ploc.getWorld().spawnEntity(ploc, EntityType.BAT); ploc.getWorld().spawnEntity(ploc, EntityType.BAT);
spawnedBats++; spawnedBats++;
} }
}else if (randx<90 && spawnedWolves<=2){ } else if (randx < 90 && spawnedWolves < 1) {
if (HerobrineAI.getPluginCore().getConfigDB().SpawnWolves){ if (PluginCore.getConfigDB().SpawnWolves) {
Wolf wolf = (Wolf) ploc.getWorld().spawnCreature(ploc, CreatureType.WOLF); Wolf wolf = (Wolf) ploc.getWorld().spawnEntity(ploc, EntityType.WOLF);
wolf.setAdult(); wolf.setAdult();
wolf.setAngry(true); wolf.setAngry(true);
spawnedWolves++; spawnedWolves++;
} }
} }
if (HerobrineAI.getPluginCore().getConfigDB().Lighting==true){ if (PluginCore.getConfigDB().Lighting == true) {
int lchance= new Random().nextInt(100); int lchance = randxgen.nextInt(100);
if (lchance>75){ if (lchance > 75) {
Location newloc = (Location) ploc; Location newloc = (Location) ploc;
int randz= new Random().nextInt(50); int randz = randxgen.nextInt(50);
int randxp= new Random().nextInt(1); int randxp = randxgen.nextInt(1);
int randzp= new Random().nextInt(1); int randzp = randxgen.nextInt(1);
if (randxp==1){ if (randxp == 1) {
newloc.setX(newloc.getX()+randx); newloc.setX(newloc.getX() + randx);
}else{ } else {
newloc.setX(newloc.getX()-randx); newloc.setX(newloc.getX() - randx);
} }
if (randzp==1){ if (randzp == 1) {
newloc.setZ(newloc.getZ()+randz); newloc.setZ(newloc.getZ() + randz);
}else{ } else {
newloc.setZ(newloc.getZ()-randz); newloc.setZ(newloc.getZ() - randz);
} }
newloc.setY(250); newloc.setY(250);
@ -128,97 +141,144 @@ public class Haunt extends Core{
} }
} }
if (isFirst) {
if (ticksToEnd==1){ Object[] data2 = { AICore.PlayerTarget.getLocation() };
Object[] data2 = {AICore.PlayerTarget.getLocation()}; PluginCore.getAICore().getCore(CoreType.BUILD_STUFF).RunCore(data2);
HerobrineAI.getPluginCore().getAICore().getCore(CoreType.BUILD_STUFF).RunCore(data2);} }
isFirst = false;
}
} else {
PluginCore.getAICore().CancelTarget(CoreType.HAUNT);
}
} else {
PluginCore.getAICore().CancelTarget(CoreType.HAUNT);
} }
}else{HerobrineAI.getPluginCore().getAICore().CancelTarget(CoreType.HAUNT);}
}else{HerobrineAI.getPluginCore().getAICore().CancelTarget(CoreType.HAUNT);}
} }
public void KeepLookingHaunt(){ public void KeepLookingHaunt() {
if (AICore.PlayerTarget.isOnline() && AICore.isTarget && HerobrineAI.getPluginCore().getAICore().getCoreTypeNow()==CoreType.HAUNT){ if (AICore.PlayerTarget.isOnline() && AICore.isTarget
if (AICore.PlayerTarget.isDead()==false){ && PluginCore.getAICore().getCoreTypeNow() == CoreType.HAUNT) {
if (AICore.PlayerTarget.isDead() == false) {
Location loc = (Location) HerobrineAI.HerobrineNPC.getBukkitEntity().getLocation(); Location loc = (Location) HerobrineAI.HerobrineNPC.getBukkitEntity().getLocation();
Player [] AllOnPlayers = Bukkit.getServer().getOnlinePlayers(); if (Bukkit.getServer().getOnlinePlayers().size() > 0) {
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();
} 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();
} }
HerobrineAI.HerobrineHP=HerobrineAI.HerobrineMaxHP; }
HerobrineAI.HerobrineHP = HerobrineAI.HerobrineMaxHP;
loc = AICore.PlayerTarget.getLocation(); loc = AICore.PlayerTarget.getLocation();
loc.setY(loc.getY()+1.5); loc.setY(loc.getY() + 1.5);
HerobrineAI.HerobrineNPC.lookAtPoint(loc); HerobrineAI.HerobrineNPC.lookAtPoint(loc);
_ticks++; _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();} AICore _aicore = PluginCore.getAICore();
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();} if(_ticks % 30 == 0)
HauntTP();
else if(_ticks % 20 == 0)
_aicore.DisappearEffect();
}else{HerobrineAI.getPluginCore().getAICore().CancelTarget(CoreType.HAUNT);} } else {
}else{HerobrineAI.getPluginCore().getAICore().CancelTarget(CoreType.HAUNT);} PluginCore.getAICore().CancelTarget(CoreType.HAUNT);
}
} else {
PluginCore.getAICore().CancelTarget(CoreType.HAUNT);
}
} }
public void HauntTP(){ public void HauntTP() {
if (AICore.PlayerTarget.isOnline() && AICore.isTarget && HerobrineAI.getPluginCore().getAICore().getCoreTypeNow()==CoreType.HAUNT){ if (AICore.PlayerTarget.isOnline() && AICore.isTarget
if (AICore.PlayerTarget.isDead()==false){ && PluginCore.getAICore().getCoreTypeNow() == CoreType.HAUNT) {
if (HerobrineAI.getPluginCore().getConfigDB().useWorlds.contains(AICore.PlayerTarget.getWorld().getName())){ if (AICore.PlayerTarget.isDead() == false) {
if (PluginCore.getConfigDB().useWorlds
.contains(AICore.PlayerTarget.getWorld().getName())) {
FindPlace(AICore.PlayerTarget); FindAndTeleport(AICore.PlayerTarget);
Location ploc = (Location) AICore.PlayerTarget.getLocation(); Location ploc = (Location) AICore.PlayerTarget.getLocation();
ploc.setY(ploc.getY()+1.5); ploc.setY(ploc.getY() + 1.5);
HerobrineAI.HerobrineNPC.lookAtPoint(ploc); HerobrineAI.HerobrineNPC.lookAtPoint(ploc);
} else {
PluginCore.getAICore().CancelTarget(CoreType.HAUNT);
}else{HerobrineAI.getPluginCore().getAICore().CancelTarget(CoreType.HAUNT);} }
}else{HerobrineAI.getPluginCore().getAICore().CancelTarget(CoreType.HAUNT);} } else {
}else{HerobrineAI.getPluginCore().getAICore().CancelTarget(CoreType.HAUNT);} PluginCore.getAICore().CancelTarget(CoreType.HAUNT);
}
} else {
PluginCore.getAICore().CancelTarget(CoreType.HAUNT);
}
} }
public boolean FindPlace(Player player){ public boolean FindAndTeleport(Player player) {
Location loc = (Location) player.getLocation(); Location loc = (Location) player.getLocation();
int x=0; int x = 0;
int z=0; int z = 0;
int y=0; int y = 0;
int xMax=new Random().nextInt(10)-7; Random randGen = Utils.getRandomGen();
int zMax=new Random().nextInt(10)-7;
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(y=-5;y<=5;y++){ for (x = -xMax; xMax > 0 ? x <= xMax : x >= xMax; x += xMax > 0 ? 1 : -1) {
for(x=xMax;x<=10;x++){ for (z = -zMax; zMax > 0 ? z <= zMax : z >= zMax; z += zMax > 0 ? 1 : -1) {
for(z=zMax;z<=10;z++){ if (!(x >= -4 && x <= 4 && z >= -4 && z <= 4)) {
if (HerobrineAI.StandBlocks.contains(loc.getWorld().getBlockAt(x+loc.getBlockX(), y+loc.getBlockY()-1, z+loc.getBlockZ()).getType())){ Material blockBottom = loc.getWorld().getBlockAt(
if (HerobrineAI.AllowedBlocks.contains(loc.getWorld().getBlockAt(x+loc.getBlockX(), y+loc.getBlockY(), z+loc.getBlockZ()).getType())){ x + loc.getBlockX(),
if (HerobrineAI.AllowedBlocks.contains(loc.getWorld().getBlockAt(x+loc.getBlockX(), y+loc.getBlockY()+1, z+loc.getBlockZ()).getType())){ y + loc.getBlockY() - 1,
Teleport(loc.getWorld(),x+loc.getBlockX(),y+loc.getBlockY(),z+loc.getBlockZ()); 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;
} }
} }
} }
@ -227,17 +287,11 @@ public boolean FindPlace(Player player){
} }
}
return false; return false;
} }
public void Teleport(World world,int X,int Y,int Z){ public void Teleport(World world, int X, int Y, int Z) {
Location loc = (Location) HerobrineAI.HerobrineNPC.getBukkitEntity().getLocation(); Location loc = (Location) HerobrineAI.HerobrineNPC.getBukkitEntity().getLocation();
loc.setWorld(world); loc.setWorld(world);
@ -249,6 +303,3 @@ public boolean FindPlace(Player player){
} }
} }

View File

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

View File

@ -8,55 +8,75 @@ import org.bukkit.Material;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.jakub1221.herobrineai.HerobrineAI; import org.jakub1221.herobrineai.HerobrineAI;
import org.jakub1221.herobrineai.Utils;
import org.jakub1221.herobrineai.AI.AICore; import org.jakub1221.herobrineai.AI.AICore;
import org.jakub1221.herobrineai.AI.Core; import org.jakub1221.herobrineai.AI.Core;
import org.jakub1221.herobrineai.AI.CoreResult; import org.jakub1221.herobrineai.AI.CoreResult;
public class Pyramid extends Core{ public class Pyramid extends Core {
public Pyramid(){ public Pyramid() {
super(CoreType.PYRAMID,AppearType.NORMAL); super(CoreType.PYRAMID, AppearType.NORMAL, HerobrineAI.getPluginCore());
} }
public CoreResult CallCore(Object[] data){ public CoreResult CallCore(Object[] data) {
if (data[0] instanceof Player){ if (data[0] instanceof Player) {
return FindPlace((Player) data[0]); return FindPlace((Player) data[0]);
}else{ } else {
return FindPlace((Chunk) data[0]); return FindPlace((Chunk) data[0]);
} }
} }
public CoreResult FindPlace(Chunk chunk){ public CoreResult FindPlace(Chunk chunk) {
if (HerobrineAI.getPluginCore().getConfigDB().BuildPyramids){ if (PluginCore.getConfigDB().BuildPyramids) {
Location loc = chunk.getBlock(2, 0, 2).getLocation(); Location loc = chunk.getBlock(2, 0, 2).getLocation();
loc=loc.getWorld().getHighestBlockAt(loc).getLocation(); loc = loc.getWorld().getHighestBlockAt(loc).getLocation();
boolean canBuild=true; boolean canBuild = true;
int i1=0; int i1 = 0;
int i2=5; int i2 = 5;
int i3=5; int i3 = 5;
int i4=0; int i4 = 0;
int i5=0; int i5 = 0;
int i6=0; int i6 = 0;
for (i1=-5;i1<=5;i1++){//Y for (i1 = -5; i1 <= 5; i1++) {// Y
canBuild=true; canBuild = true;
for (i4 = -1; i4 <= 3; i4++) {// Y
for (i5 = -2; i5 <= 2; i5++) {// X
for (i6 = -2; i6 <= 2; i6++) {// Z
for (i4=-1;i4<=3;i4++){//Y if (loc.getBlockX() == i2 + i5 + loc.getBlockX()
for(i5=-2;i5<=2;i5++){//X && loc.getBlockY() == i1 + i4 + loc.getBlockY()
for(i6=-2;i6<=2;i6++){//Z && loc.getBlockZ() == i3 + i6 + loc.getBlockZ()) {
canBuild = false;
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 (i4 == -1) {
if (canBuild==true){ 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;} 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;}
} }
} }
@ -65,59 +85,69 @@ public class Pyramid extends Core{
} }
} }
if (canBuild==true){ if (canBuild == true) {
BuildPyramid(loc.getWorld(),i2+loc.getBlockX(),i1+loc.getBlockY(),i3+loc.getBlockZ()); BuildPyramid(loc.getWorld(), i2 + loc.getBlockX(), i1 + loc.getBlockY(), i3 + loc.getBlockZ());
return new CoreResult(true,"Creating a pyramid!"); return new CoreResult(true, "Creating a pyramid!");
} }
} }
} }
return new CoreResult(false,"Cannot create a pyramid!"); return new CoreResult(false, "Cannot create a pyramid!");
} }
public CoreResult FindPlace(Player player){ public CoreResult FindPlace(Player player) {
if (HerobrineAI.getPluginCore().getConfigDB().BuildPyramids){ if (PluginCore.getConfigDB().BuildPyramids) {
Location loc = (Location) player.getLocation(); Location loc = (Location) player.getLocation();
boolean canBuild=true; boolean canBuild = true;
int i1=0; int i1 = 0;
int i2=0; int i2 = 0;
int i3=0; int i3 = 0;
int i4=0; int i4 = 0;
int i5=0; int i5 = 0;
int i6=0; int i6 = 0;
int xMax=new Random().nextInt(15)-10; int xMax = Utils.getRandomGen().nextInt(15) - 10;
int zMax=new Random().nextInt(15)-10; int zMax = Utils.getRandomGen().nextInt(15) - 10;
for (i1=-5;i1<=5;i1++){//Y for (i1 = -5; i1 <= 5; i1++) {// Y
for(i2=xMax;i2<=15;i2++){//X for (i2 = xMax; i2 <= 15; i2++) {// X
for(i3=zMax;i3<=15;i3++){//Z for (i3 = zMax; i3 <= 15; i3++) {// Z
canBuild=true; canBuild = true;
for (i4 = -1; i4 <= 3; i4++) {// Y
for (i5 = -2; i5 <= 2; i5++) {// X
for (i6 = -2; i6 <= 2; i6++) {// Z
for (i4=-1;i4<=3;i4++){//Y if (player.getLocation().getBlockX() == i2 + i5 + loc.getBlockX()
for(i5=-2;i5<=2;i5++){//X && player.getLocation().getBlockY() == i1 + i4 + loc.getBlockY()
for(i6=-2;i6<=2;i6++){//Z && player.getLocation().getBlockZ() == i3 + i6 + loc.getBlockZ()) {
canBuild = false;
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 (i4 == -1) {
if (canBuild==true){ 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;} 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;}
} }
} }
@ -126,9 +156,15 @@ if (HerobrineAI.getPluginCore().getConfigDB().BuildPyramids){
} }
} }
if (canBuild==true){ if (canBuild == true) {
BuildPyramid(loc.getWorld(),i2+loc.getBlockX(),i1+loc.getBlockY(),i3+loc.getBlockZ()); BuildPyramid(
return new CoreResult(true,"Creating a pyramid!"); loc.getWorld(),
i2 + loc.getBlockX(),
i1 + loc.getBlockY(),
i3 + loc.getBlockZ()
);
return new CoreResult(true, "Creating a pyramid!");
} }
} }
@ -136,60 +172,61 @@ if (HerobrineAI.getPluginCore().getConfigDB().BuildPyramids){
} }
}
} 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){ public void BuildPyramid(World world, int X, int Y, int Z) {
if (HerobrineAI.getPluginCore().getSupport().checkBuild(new Location(world,X,Y,Z))){ if (HerobrineAI.getPluginCore().getSupport().checkBuild(new Location(world, X, Y, Z))) {
AICore.log.info("Creating pyramid at "+X+","+Y+","+Z); AICore.log.info("Creating pyramid at " + X + "," + Y + "," + Z);
Material mainMat = (Material) Material.SANDSTONE; Material mainMat = (Material) Material.SANDSTONE;
// TODO CHANGE THIS
// Level 1 // Level 1
world.getBlockAt(X,Y,Z).setType(mainMat); world.getBlockAt(X, Y, Z).setType(mainMat);
world.getBlockAt(X-2,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+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).setType(mainMat);
world.getBlockAt(X-2,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 - 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-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+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,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-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+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+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);
world.getBlockAt(X+1,Y,Z+2).setType(mainMat); world.getBlockAt(X + 1, Y, Z + 2).setType(mainMat);
// Level 2 // Level 2
world.getBlockAt(X,Y+1,Z).setType(mainMat); 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).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-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);
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 // Level 3
world.getBlockAt(X,Y+2,Z).setType(mainMat); world.getBlockAt(X, Y + 2, Z).setType(mainMat);
// Level 4 // Level 4
world.getBlockAt(X,Y+3,Z).setType(Material.REDSTONE_TORCH_ON); 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.Location;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.jakub1221.herobrineai.HerobrineAI; import org.jakub1221.herobrineai.HerobrineAI;
import org.jakub1221.herobrineai.Utils;
import org.jakub1221.herobrineai.AI.Core; import org.jakub1221.herobrineai.AI.Core;
import org.jakub1221.herobrineai.AI.CoreResult; import org.jakub1221.herobrineai.AI.CoreResult;
public class RandomExplosion extends Core { public class RandomExplosion extends Core {
public RandomExplosion() { public RandomExplosion() {
super(CoreType.RANDOM_EXPLOSION,AppearType.NORMAL); super(CoreType.RANDOM_EXPLOSION, AppearType.NORMAL, HerobrineAI.getPluginCore());
} }
@Override @Override
public CoreResult CallCore(Object[] data) { public CoreResult CallCore(Object[] data) {
Player player = (Player) data[0]; Player player = (Player) data[0];
if (HerobrineAI.getPluginCore().getConfigDB().Explosions){ if (PluginCore.getConfigDB().Explosions) {
if (HerobrineAI.getPluginCore().getSupport().checkBuild(player.getLocation())){ if (PluginCore.getSupport().checkBuild(player.getLocation())) {
Location loc = player.getLocation(); Location loc = player.getLocation();
int x=loc.getBlockX()+(new Random().nextInt(16)-8); int x = loc.getBlockX() + (Utils.getRandomGen().nextInt(16) - 8);
int y=loc.getBlockY(); int y = loc.getBlockY();
int z=loc.getBlockZ()+(new Random().nextInt(16)-8); int z = loc.getBlockZ() + (Utils.getRandomGen().nextInt(16) - 8);
loc.getWorld().createExplosion(new Location(loc.getWorld(),x,y,z), 1.0f); loc.getWorld().createExplosion(new Location(loc.getWorld(), x, y, z), 1.0f);
}else{ } else {
return new CoreResult(true,"Player is in secure area!"); return new CoreResult(true, "Player is in secure area!");
} }
}else{ } else {
return new CoreResult(true,"Explosions are not allowed!"); 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; package org.jakub1221.herobrineai.AI.cores;
import java.util.Collection;
import java.util.Random; import java.util.Random;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
@ -9,115 +10,136 @@ import org.bukkit.World;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.jakub1221.herobrineai.ConfigDB; import org.jakub1221.herobrineai.ConfigDB;
import org.jakub1221.herobrineai.HerobrineAI; import org.jakub1221.herobrineai.HerobrineAI;
import org.jakub1221.herobrineai.Utils;
import org.jakub1221.herobrineai.AI.AICore; import org.jakub1221.herobrineai.AI.AICore;
import org.jakub1221.herobrineai.AI.Core; import org.jakub1221.herobrineai.AI.Core;
import org.jakub1221.herobrineai.AI.CoreResult; import org.jakub1221.herobrineai.AI.CoreResult;
import org.jakub1221.herobrineai.NPC.AI.Path; import org.jakub1221.herobrineai.NPC.AI.Path;
public class RandomPosition extends Core{ public class RandomPosition extends Core {
private int randomTicks=0; private int randomTicks = 0;
private int randomMoveTicks=0; private int randomMoveTicks = 0;
private boolean RandomMoveIsPlayer=false; private boolean RandomMoveIsPlayer = false;
public RandomPosition(){ public RandomPosition() {
super(CoreType.RANDOM_POSITION,AppearType.APPEAR); super(CoreType.RANDOM_POSITION, AppearType.APPEAR, HerobrineAI.getPluginCore());
} }
public int getRandomTicks(){return this.randomTicks;} public int getRandomTicks() {
public int getRandomMoveTicks(){return this.randomMoveTicks;} return this.randomTicks;
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){ public int getRandomMoveTicks() {
if (HerobrineAI.getPluginCore().getConfigDB().UseWalkingMode){ return this.randomMoveTicks;
if (randomTicks!=3){ }
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++; randomTicks++;
if (HerobrineAI.getPluginCore().getAICore().getCoreTypeNow() != CoreType.RANDOM_POSITION && AICore.isTarget==false){ if (PluginCore.getAICore().getCoreTypeNow() != CoreType.RANDOM_POSITION && AICore.isTarget == false) {
Location newloc = (Location) getRandomLocation(world); Location newloc = (Location) getRandomLocation(world);
if (newloc!=null){ if (newloc != null) {
HerobrineAI.HerobrineNPC.moveTo(newloc); HerobrineAI.HerobrineNPC.moveTo(newloc);
newloc.setX(newloc.getX()+2); newloc.setX(newloc.getX() + 2);
newloc.setY(newloc.getY()+1.5); newloc.setY(newloc.getY() + 1.5);
HerobrineAI.HerobrineNPC.lookAtPoint(newloc); HerobrineAI.HerobrineNPC.lookAtPoint(newloc);
randomTicks=0; randomTicks = 0;
AICore.log.info("[HerobrineAI] Herobrine is now in RandomLocation mode."); AICore.log.info("[HerobrineAI] Herobrine is now in RandomLocation mode.");
HerobrineAI.getPluginCore().getAICore().Start_RM(); PluginCore.getAICore().Start_RM();
HerobrineAI.getPluginCore().getAICore().Start_RS(); PluginCore.getAICore().Start_RS();
HerobrineAI.getPluginCore().getAICore().Start_CG(); PluginCore.getAICore().Start_CG();
RandomMoveIsPlayer=false; RandomMoveIsPlayer = false;
return new CoreResult(true,"Herobrine is now in WalkingMode."); return new CoreResult(true, "Herobrine is now in WalkingMode.");
}else{AICore.log.info("[HerobrineAI] RandomPosition Failed!");return setRandomPosition(world);} } else {
AICore.log.info("[HerobrineAI] RandomPosition Failed!");
return setRandomPosition(world);
} }
}else{
return new CoreResult(false,"WalkingMode - Find location failed!");
} }
}else{ } else {
return new CoreResult(false,"WalkingMode is disabled!"); return new CoreResult(false, "WalkingMode - Find location failed!");
} }
return new CoreResult(false,"WalkingMode failed!"); } else {
return new CoreResult(false, "WalkingMode is disabled!");
}
return new CoreResult(false, "WalkingMode failed!");
} }
public Location getRandomLocation(World world){ public Location getRandomLocation(World world) {
int i = 0; int i = 0;
for (i=0;i<=300;i++){ for (i = 0; i <= 100; i++) {
int r_nxtX=HerobrineAI.getPluginCore().getConfigDB().WalkingModeXRadius; int r_nxtX = PluginCore.getConfigDB().WalkingModeXRadius;
int nxtX=r_nxtX; int nxtX = r_nxtX;
if (nxtX<0){ if (nxtX < 0) {
nxtX=-nxtX; nxtX = -nxtX;
} }
int r_nxtZ=HerobrineAI.getPluginCore().getConfigDB().WalkingModeZRadius; int r_nxtZ = PluginCore.getConfigDB().WalkingModeZRadius;
int nxtZ=r_nxtZ; int nxtZ = r_nxtZ;
if (nxtZ<0){ if (nxtZ < 0) {
nxtZ=-nxtZ; nxtZ = -nxtZ;
} }
int randx= new Random().nextInt(nxtX); int randx = Utils.getRandomGen().nextInt(nxtX);
int randy=0; int randy = 0;
int randz= new Random().nextInt(nxtZ); int randz = Utils.getRandomGen().nextInt(nxtZ);
int randxp= new Random().nextInt(1); int randxp = Utils.getRandomGen().nextInt(1);
int randzp= new Random().nextInt(1); int randzp = Utils.getRandomGen().nextInt(1);
if (randxp==0 && randx!=0){randx=-(randx);} if (randxp == 0 && randx != 0) {
if (randzp==0 && randz!=0){randz=-(randz);} randx = -(randx);
}
if (randzp == 0 && randz != 0) {
randz = -(randz);
}
randx=randx+HerobrineAI.getPluginCore().getConfigDB().WalkingModeFromXRadius; randx = randx + PluginCore.getConfigDB().WalkingModeFromXRadius;
randz=randz+HerobrineAI.getPluginCore().getConfigDB().WalkingModeFromZRadius; randz = randz + PluginCore.getConfigDB().WalkingModeFromZRadius;
if (world != null){ if (world != null) {
randy=world.getHighestBlockYAt(randx,randz); randy = world.getHighestBlockYAt(randx, randz);
}else{ } else {
return null; 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, randz).getType() == Material.AIR
if (world.getBlockAt(randx, randy-1, randz).getType() != Material.AIR && && world.getBlockAt(randx, randy + 1, randz).getType() == Material.AIR) {
world.getBlockAt(randx, randy-1, randz).getType() != Material.WATER && if (world.getBlockAt(randx, randy - 1, randz).getType() != Material.AIR
world.getBlockAt(randx, randy-1, randz).getType() != Material.LAVA && && world.getBlockAt(randx, randy - 1, randz).getType() != Material.WATER
world.getBlockAt(randx, randy-1, randz).getType() != Material.GRASS && && world.getBlockAt(randx, randy - 1, randz).getType() != Material.LAVA
world.getBlockAt(randx, randy-1, randz).getType() != Material.SNOW && && world.getBlockAt(randx, randy - 1, randz).getType() != Material.GRASS
world.getBlockAt(randx, randy-1, randz).getType() != Material.LEAVES && && world.getBlockAt(randx, randy - 1, randz).getType() != Material.SNOW
world.getBlockAt(randx, randy-1, randz).getType() != Material.WHEAT && && world.getBlockAt(randx, randy - 1, randz).getType() != Material.LEAVES
world.getBlockAt(randx, randy-1, randz).getType() != Material.TORCH && && world.getBlockAt(randx, randy - 1, randz).getType() != Material.WHEAT
world.getBlockAt(randx, randy-1, randz).getType() != Material.REDSTONE_TORCH_OFF && && world.getBlockAt(randx, randy - 1, randz).getType() != Material.TORCH
world.getBlockAt(randx, randy-1, randz).getType() != Material.REDSTONE_TORCH_ON && && world.getBlockAt(randx, randy - 1, randz).getType() != Material.REDSTONE_TORCH_OFF
world.getBlockAt(randx, randy-1, randz).getType() != Material.REDSTONE && && world.getBlockAt(randx, randy - 1, randz).getType() != Material.REDSTONE_TORCH_ON
world.getBlockAt(randx, randy-1, randz).getType() != Material.STATIONARY_WATER && && world.getBlockAt(randx, randy - 1, randz).getType() != Material.REDSTONE
world.getBlockAt(randx, randy-1, randz).getType() != Material.STATIONARY_LAVA){ && 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);
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);
} }
} }
@ -127,72 +149,92 @@ public class RandomPosition extends Core{
} }
public void RandomMove(){ public void RandomMove() {
if (HerobrineAI.getPluginCore().getAICore().getCoreTypeNow()==CoreType.RANDOM_POSITION && AICore.isTarget==false && RandomMoveIsPlayer==false){ if (PluginCore.getAICore().getCoreTypeNow() == CoreType.RANDOM_POSITION && AICore.isTarget == false
HerobrineAI.HerobrineHP=HerobrineAI.HerobrineMaxHP; && RandomMoveIsPlayer == false) {
HerobrineAI.HerobrineHP = HerobrineAI.HerobrineMaxHP;
if (new Random().nextInt(4)==1){ if (Utils.getRandomGen().nextInt(5) == 3) {
Location loc = HerobrineAI.HerobrineNPC.getBukkitEntity().getLocation(); 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); Path path = new Path((float) loc.getX() + Utils.getRandomGen().nextInt(30) - 15,
HerobrineAI.getPluginCore().getPathManager().setPath(path); (float) loc.getZ() + Utils.getRandomGen().nextInt(30) - 15);
PluginCore.getPathManager().setPath(path);
} }
} }
} }
public void CheckGravity(){ public void CheckGravity() {
if (HerobrineAI.getPluginCore().getAICore().getCoreTypeNow()==CoreType.RANDOM_POSITION && AICore.isTarget==false){ if (PluginCore.getAICore().getCoreTypeNow() == CoreType.RANDOM_POSITION && AICore.isTarget == false) {
Location hbloc = (Location) HerobrineAI.HerobrineNPC.getBukkitEntity().getLocation(); Location hbloc = (Location) HerobrineAI.HerobrineNPC.getBukkitEntity().getLocation();
World w = (World) hbloc.getWorld(); World w = (World) hbloc.getWorld();
ConfigDB config = HerobrineAI.getPluginCore().getConfigDB(); 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 (hbloc.getBlockX() < config.WalkingModeXRadius + config.WalkingModeFromXRadius
if (HerobrineAI.NonStandBlocks.contains(w.getBlockAt(hbloc.getBlockX(), hbloc.getBlockY()-1, hbloc.getBlockZ()).getType())){ && 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); hbloc.setY(hbloc.getY() - 1);
HerobrineAI.HerobrineNPC.moveTo(hbloc); HerobrineAI.HerobrineNPC.moveTo(hbloc);
} }
}else{ } else {
HerobrineAI.getPluginCore().getAICore().CancelTarget(CoreType.RANDOM_POSITION); PluginCore.getAICore().CancelTarget(CoreType.RANDOM_POSITION);
} }
} }
} }
public void CheckPlayerPosition(){ public void CheckPlayerPosition() {
boolean isThere=false; boolean isThere = false;
Location loc = (Location) HerobrineAI.HerobrineNPC.getBukkitEntity().getLocation(); Location loc = (Location) HerobrineAI.HerobrineNPC.getBukkitEntity().getLocation();
Player [] AllOnPlayers = Bukkit.getServer().getOnlinePlayers(); Collection<? extends Player> onlinePlayers = Bukkit.getServer().getOnlinePlayers();
if (Bukkit.getServer().getOnlinePlayers().length>0){
int i = 0; if (Bukkit.getServer().getOnlinePlayers().size() > 0) {
for (i=0;i<=Bukkit.getServer().getOnlinePlayers().length-1;i++){
if (HerobrineAI.HerobrineEntityID!=AllOnPlayers[i].getEntityId()){ for (Player player : onlinePlayers) {
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()){ 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); loc.setY(-20);
HerobrineAI.HerobrineNPC.moveTo(loc); HerobrineAI.HerobrineNPC.moveTo(loc);
HerobrineAI.getPluginCore().getAICore().CancelTarget(CoreType.RANDOM_POSITION); PluginCore.getAICore().CancelTarget(CoreType.RANDOM_POSITION);
RandomMoveIsPlayer=false; RandomMoveIsPlayer = false;
HerobrineAI.getPluginCore().getAICore().setAttackTarget(AllOnPlayers[i]); PluginCore.getAICore().setAttackTarget(player);
}else{ break;
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()){ } else {
ploc.setY(ploc.getY()+1.5);
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.HerobrineNPC.lookAtPoint(ploc);
HerobrineAI.getPluginCore().getPathManager().setPath(null); PluginCore.getPathManager().setPath(null);
isThere=true; isThere = true;
break;
} }
} }
} }
} }
} }
if (isThere){ if (isThere) {
RandomMoveIsPlayer=true; RandomMoveIsPlayer = true;
}else{ } else {
RandomMoveIsPlayer=false; RandomMoveIsPlayer = false;
} }
} }

View File

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

View File

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

View File

@ -4,13 +4,15 @@ import java.util.Random;
import org.bukkit.Sound; import org.bukkit.Sound;
import org.bukkit.entity.Player; 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.Core;
import org.jakub1221.herobrineai.AI.CoreResult; import org.jakub1221.herobrineai.AI.CoreResult;
public class SoundF extends Core{ public class SoundF extends Core{
public SoundF(){ public SoundF(){
super(CoreType.SOUNDF,AppearType.NORMAL); super(CoreType.SOUNDF,AppearType.NORMAL, HerobrineAI.getPluginCore());
} }
public CoreResult CallCore(Object[] data){ public CoreResult CallCore(Object[] data){
@ -19,32 +21,19 @@ public class SoundF extends Core{
public CoreResult playRandom(Player player){ public CoreResult playRandom(Player player){
Sound[] sounds = new Sound[15]; Sound[] sounds = {
sounds[0]=Sound.STEP_STONE; Sound.ENTITY_GHAST_SCREAM,
sounds[1]=Sound.STEP_WOOD; Sound.ENTITY_WITHER_DEATH,
sounds[2]=Sound.STEP_GRASS; Sound.ENTITY_WITHER_HURT,
sounds[3]=Sound.STEP_SAND; Sound.ENTITY_BAT_HURT,
sounds[4]=Sound.STEP_GRAVEL; Sound.ENTITY_PLAYER_BREATH,
sounds[5]=Sound.BREATH; Sound.ENTITY_PLAYER_HURT,
sounds[6]=Sound.BREATH; Sound.BLOCK_IRON_DOOR_OPEN,
sounds[7]=Sound.BREATH; Sound.BLOCK_IRON_DOOR_CLOSE
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;
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!"); return new CoreResult(true,"SoundF is starting!");
} }

View File

@ -12,56 +12,74 @@ import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.jakub1221.herobrineai.HerobrineAI; import org.jakub1221.herobrineai.HerobrineAI;
import org.jakub1221.herobrineai.Utils;
import org.jakub1221.herobrineai.AI.Core; import org.jakub1221.herobrineai.AI.Core;
import org.jakub1221.herobrineai.AI.CoreResult; import org.jakub1221.herobrineai.AI.CoreResult;
import org.jakub1221.herobrineai.entity.MobType; import org.jakub1221.herobrineai.entity.MobType;
import org.jakub1221.herobrineai.misc.ItemName; import org.jakub1221.herobrineai.misc.ItemName;
import org.jakub1221.herobrineai.misc.StructureLoader; import org.jakub1221.herobrineai.misc.StructureLoader;
public class Temple extends Core{ public class Temple extends Core {
public Temple(){ public Temple() {
super(CoreType.TEMPLE,AppearType.NORMAL); super(CoreType.TEMPLE, AppearType.NORMAL, HerobrineAI.getPluginCore());
} }
public CoreResult CallCore(Object[] data){ public CoreResult CallCore(Object[] data) {
if (data[0] instanceof Player){ if (data[0] instanceof Player) {
return FindPlacePlayer((Player)data[0]); return FindPlacePlayer((Player) data[0]);
}else{ } else {
return FindPlacePlayer((Chunk)data[0]); return FindPlacePlayer((Chunk) data[0]);
} }
} }
public CoreResult FindPlacePlayer(Player player){ public CoreResult FindPlacePlayer(Player player) {
Location loc = player.getLocation(); Location loc = player.getLocation();
boolean canBuild=true; boolean canBuild = true;
int i1=0; int i1 = 0;
int i2=0; int i2 = 0;
int i3=0; int i3 = 0;
int i4=0; int i4 = 0;
int i5=0; int i5 = 0;
int i6=0; int i6 = 0;
for (i1=-5;i1<=5;i1++){//Y for (i1 = -5; i1 <= 5; i1++) {// Y
for(i2=-20;i2<=20;i2++){//X for (i2 = -20; i2 <= 20; i2++) {// X
for(i3=-20;i3<=20;i3++){//Z for (i3 = -20; i3 <= 20; i3++) {// Z
canBuild=true; canBuild = true;
for (i4 = -1; i4 <= 12; i4++) {// Y
for (i5 = 0; i5 <= 11; i5++) {// X
for (i6 = 0; i6 <= 10; i6++) {// Z
for (i4=-1;i4<=12;i4++){//Y if (player.getLocation().getBlockX() == i2 + i5 + loc.getBlockX()
for(i5=0;i5<=11;i5++){//X && player.getLocation().getBlockY() == i1 + i4 + loc.getBlockY()
for(i6=0;i6<=10;i6++){//Z && player.getLocation().getBlockZ() == i3 + i6 + loc.getBlockZ()) {
canBuild = false;
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 (i4 == -1) {
if (canBuild==true){ 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;} 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;}
} }
} }
@ -70,9 +88,9 @@ public class Temple extends Core{
} }
} }
if (canBuild==true){ if (canBuild == true) {
Create(loc.getWorld(),i2+loc.getBlockX(),i1+loc.getBlockY(),i3+loc.getBlockZ()); Create(loc.getWorld(), i2 + loc.getBlockX(), i1 + loc.getBlockY(), i3 + loc.getBlockZ());
return new CoreResult(true,"Creating temple near "+player.getName()+"!"); return new CoreResult(true, "Creating temple near " + player.getName() + "!");
} }
} }
@ -80,49 +98,65 @@ public class Temple extends Core{
} }
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(); Location loc = chunk.getBlock(2, 0, 2).getLocation();
loc=loc.getWorld().getHighestBlockAt(loc).getLocation(); loc = loc.getWorld().getHighestBlockAt(loc).getLocation();
boolean canBuild=true; boolean canBuild = true;
int i1=0; int i1 = 0;
int i2=0; int i2 = 0;
int i3=0; int i3 = 0;
int i4=0; int i4 = 0;
int i5=0; int i5 = 0;
int i6=0; int i6 = 0;
i1=0; i1 = 0;
i2=0; i2 = 0;
i3=0; i3 = 0;
i4=0; i4 = 0;
i5=0; i5 = 0;
i6=0; i6 = 0;
for (i1 = -5; i1 <= 5; i1++) {// Y
for (i1=-5;i1<=5;i1++){//Y canBuild = true;
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()
for (i4=-1;i4<=12;i4++){//Y && loc.getBlockZ() == i3 + i6 + loc.getBlockZ()) {
for(i5=0;i5<=11;i5++){//X canBuild = false;
for(i6=0;i6<=10;i6++){//Z }
if (i4 == -1) {
if (loc.getBlockX()==i2+i5+loc.getBlockX() && loc.getBlockY()==i1+i4+loc.getBlockY() && loc.getBlockZ()==i3+i6+loc.getBlockZ()){canBuild=false;} if (canBuild == true) {
if (i4==-1){ if (HerobrineAI.StandBlocks
if (canBuild==true){ .contains(loc
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;} .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;}
} }
} }
@ -131,94 +165,104 @@ public class Temple extends Core{
} }
} }
if (canBuild==true){ if (canBuild == true) {
Create(loc.getWorld(),i2+loc.getBlockX(),i1+loc.getBlockY(),i3+loc.getBlockZ()); Create(loc.getWorld(), i2 + loc.getBlockX(), i1 + loc.getBlockY(), i3 + loc.getBlockZ());
return new CoreResult(true,"Creating temple!"); return new CoreResult(true, "Creating temple!");
} }
} }
return new CoreResult(false, "Cannot find a good place for Temple.");
return new CoreResult(false,"Cannot find a good place for Temple.");
} }
public void Create(World world,int X,int Y,int Z){ public void Create(World world, int X, int Y, int Z) {
Location loc = new Location(world,X,Y,Z); Location loc = new Location(world, X, Y, Z);
if (HerobrineAI.getPluginCore().getSupport().checkBuild(new Location(world,X,Y,Z))){ if (HerobrineAI.getPluginCore().getSupport().checkBuild(new Location(world, X, Y, Z))) {
int MainX=loc.getBlockX(); int MainX = loc.getBlockX();
int MainY=loc.getBlockY(); int MainY = loc.getBlockY();
int MainZ=loc.getBlockZ(); int MainZ = loc.getBlockZ();
//Main blocks // Main blocks
new StructureLoader(HerobrineAI.getPluginCore().data_temple).Build(loc.getWorld(), MainX, MainY, MainZ); new StructureLoader(HerobrineAI.getPluginCore().getInputStreamData("/res/temple.yml")).Build(loc.getWorld(),
loc.getWorld().getBlockAt(MainX+6, MainY+0, MainZ+2).setType(Material.CHEST); MainX, MainY, MainZ);
//Mob spawn loc.getWorld().getBlockAt(MainX + 6, MainY + 0, MainZ + 2).setType(Material.CHEST);
if (HerobrineAI.getPluginCore().getConfigDB().UseNPC_Guardian){ // Mob spawn
Location mobloc = new Location(loc.getWorld(),MainX+6, MainY+0, MainZ+4); if (!HerobrineAI.isNPCDisabled) {
for (int i=1;i<=HerobrineAI.getPluginCore().getConfigDB().npc.getInt("npc.Guardian.SpawnCount");i++){ if (HerobrineAI.getPluginCore().getConfigDB().UseNPC_Guardian) {
HerobrineAI.getPluginCore().getEntityManager().spawnCustomZombie(mobloc, MobType.ARTIFACT_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; // Chest
if (HerobrineAI.getPluginCore().getConfigDB().UseCustomItems){ ItemStack ciItem = null;
if (HerobrineAI.getPluginCore().getConfigDB().UseCustomItemsList.size()>0){ if (HerobrineAI.getPluginCore().getConfigDB().UseCustomItems) {
if (HerobrineAI.getPluginCore().getConfigDB().UseCustomItemsList.size() > 0) {
Random generator = new Random(); Random generator = new Random();
int chance = generator.nextInt(HerobrineAI.getPluginCore().getConfigDB().UseCustomItemsList.size()); int chance = generator.nextInt(HerobrineAI.getPluginCore().getConfigDB().UseCustomItemsList.size());
if (HerobrineAI.getPluginCore().getSupport().isCustomItems()){ if (HerobrineAI.getPluginCore().getSupport().isCustomItems()) {
if (HerobrineAI.getPluginCore().getSupport().getCustomItems().checkItem(HerobrineAI.getPluginCore().getConfigDB().UseCustomItemsList.get(chance))){ if (HerobrineAI.getPluginCore().getSupport().getCustomItems()
ciItem=HerobrineAI.getPluginCore().getSupport().getCustomItems().getItem(HerobrineAI.getPluginCore().getConfigDB().UseCustomItemsList.get(chance)); .checkItem(HerobrineAI.getPluginCore().getConfigDB().UseCustomItemsList.get(chance))) {
ciItem = HerobrineAI.getPluginCore().getSupport().getCustomItems()
.getItem(HerobrineAI.getPluginCore().getConfigDB().UseCustomItemsList.get(chance));
} }
} }
} }
if (ciItem!=null){ if (ciItem != null) {
Chest chest = (Chest) loc.getWorld().getBlockAt(MainX+6, MainY+0, MainZ+2).getState(); Chest chest = (Chest) loc.getWorld().getBlockAt(MainX + 6, MainY + 0, MainZ + 2).getState();
chest.getBlockInventory().setItem(chest.getInventory().firstEmpty(), ciItem); chest.getBlockInventory().setItem(chest.getInventory().firstEmpty(), ciItem);
} }
}else{ } else {
Random generator = new Random();
Random generator = Utils.getRandomGen();
int chance = generator.nextInt(15); int chance = generator.nextInt(15);
ItemStack item = null; ItemStack item = null;
ArrayList<String> newLore = new ArrayList<String>(); ArrayList<String> newLore = new ArrayList<String>();
if (chance<4 && HerobrineAI.getPluginCore().getConfigDB().UseArtifactBow){
if (chance < 4 && HerobrineAI.getPluginCore().getConfigDB().UseArtifactBow) {
item = new ItemStack(Material.BOW); item = new ItemStack(Material.BOW);
newLore.add("Herobrine´s artifact"); newLore.add("Herobrine<EFBFBD>s artifact");
newLore.add("Bow of Teleporting"); newLore.add("Bow of Teleporting");
item = ItemName.setNameAndLore(item, "Bow of Teleporting", newLore); item = ItemName.setNameAndLore(item, "Bow of Teleporting", newLore);
item.addEnchantment(Enchantment.ARROW_FIRE, 1); item.addEnchantment(Enchantment.ARROW_FIRE, 1);
item.addEnchantment(Enchantment.ARROW_KNOCKBACK, 1); item.addEnchantment(Enchantment.ARROW_KNOCKBACK, 1);
}else if (chance<8 && HerobrineAI.getPluginCore().getConfigDB().UseArtifactSword){
} else if (chance < 8 && HerobrineAI.getPluginCore().getConfigDB().UseArtifactSword) {
item = new ItemStack(Material.DIAMOND_SWORD); item = new ItemStack(Material.DIAMOND_SWORD);
newLore.add("Herobrine´s artifact"); newLore.add("Herobrine<EFBFBD>s artifact");
newLore.add("Sword of Lighting"); newLore.add("Sword of Lighting");
item = ItemName.setNameAndLore(item, "Sword of Lighting", newLore); item = ItemName.setNameAndLore(item, "Sword of Lighting", newLore);
item.addEnchantment(Enchantment.KNOCKBACK, 2); item.addEnchantment(Enchantment.KNOCKBACK, 2);
item.addEnchantment(Enchantment.DAMAGE_ALL, 2); item.addEnchantment(Enchantment.DAMAGE_ALL, 2);
item.addEnchantment(Enchantment.DURABILITY, 3); item.addEnchantment(Enchantment.DURABILITY, 3);
}else if (chance<12 && HerobrineAI.getPluginCore().getConfigDB().UseArtifactApple){
} else if (chance < 12 && HerobrineAI.getPluginCore().getConfigDB().UseArtifactApple) {
item = new ItemStack(Material.GOLDEN_APPLE); item = new ItemStack(Material.GOLDEN_APPLE);
newLore.add("Herobrine´s artifact"); newLore.add("Herobrine<EFBFBD>s artifact");
newLore.add("Apple of Death"); newLore.add("Apple of Death");
item = ItemName.setNameAndLore(item, "Apple of Death", newLore); item = ItemName.setNameAndLore(item, "Apple of Death", newLore);
}else{ } else {
if (HerobrineAI.getPluginCore().getConfigDB().UseAncientSword){ if (HerobrineAI.getPluginCore().getConfigDB().UseAncientSword) {
item=HerobrineAI.getPluginCore().getAICore().createAncientSword(); item = HerobrineAI.getPluginCore().getAICore().createAncientSword();
item.addEnchantment(Enchantment.KNOCKBACK, 2); item.addEnchantment(Enchantment.KNOCKBACK, 2);
item.addEnchantment(Enchantment.DAMAGE_ALL, 2); item.addEnchantment(Enchantment.DAMAGE_ALL, 2);
} }
} }
Chest chest = (Chest) loc.getWorld().getBlockAt(MainX+6, MainY+0, MainZ+2).getState(); Chest chest = (Chest) loc.getWorld().getBlockAt(MainX + 6, MainY + 0, MainZ + 2).getState();
chest.getBlockInventory().setItem(chest.getInventory().firstEmpty(), item); chest.getBlockInventory().setItem(chest.getInventory().firstEmpty(), item);
} }
} }

View File

@ -1,5 +1,7 @@
package org.jakub1221.herobrineai.AI.cores; package org.jakub1221.herobrineai.AI.cores;
import java.util.Collection;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.entity.Player; 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.CoreResult;
import org.jakub1221.herobrineai.AI.Message; import org.jakub1221.herobrineai.AI.Message;
public class Totem extends Core{ public class Totem extends Core {
public Totem(){ public Totem() {
super(CoreType.TOTEM,AppearType.APPEAR); super(CoreType.TOTEM, AppearType.APPEAR, HerobrineAI.getPluginCore());
} }
public CoreResult CallCore(Object[] data){ public CoreResult CallCore(Object[] data) {
return TotemCall((Location)data[0],(String)data[1]); return TotemCall((Location) data[0], (String) data[1]);
} }
public CoreResult TotemCall(Location loc,String caller){ public CoreResult TotemCall(Location loc, String caller) {
AICore.isTotemCalled=false; AICore.isTotemCalled = false;
loc.getWorld().strikeLightning(loc); loc.getWorld().strikeLightning(loc);
if (HerobrineAI.getPluginCore().getConfigDB().TotemExplodes==true){
if (PluginCore.getConfigDB().TotemExplodes == true) {
loc.getWorld().createExplosion(loc, 5); loc.getWorld().createExplosion(loc, 5);
} }
if (Bukkit.getServer().getPlayer(caller) != null){
if (Bukkit.getServer().getPlayer(caller).isOnline()){ if (Bukkit.getServer().getPlayer(caller) != null) {
HerobrineAI.getPluginCore().getAICore().setCoreTypeNow(CoreType.TOTEM);
HerobrineAI.getPluginCore().getAICore().setAttackTarget(Bukkit.getServer().getPlayer(caller)); 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); Player player = (Player) Bukkit.getServer().getPlayer(caller);
Player [] AllOnPlayers = Bukkit.getServer().getOnlinePlayers(); Collection<? extends Player> onlinePlayers = 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 (Bukkit.getServer().getOnlinePlayers().size() > 0) {
if (HerobrineAI.getPluginCore().getConfigDB().UsePotionEffects){ for(Player onlinePlayer : onlinePlayers) {
AllOnPlayers[i].addPotionEffect(new PotionEffect(PotionEffectType.CONFUSION, 1000, 1)); Location ploc = (Location) onlinePlayer.getLocation();
AllOnPlayers[i].addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, 1000, 1)); if (onlinePlayer.getName() != player.getName() && ploc.getX() + 10 > loc.getX()
AllOnPlayers[i].addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 1000, 1)); && 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{ } else {
boolean hasTarget=false;
Player target = null; Player target = null;
Player [] AllOnPlayers = Bukkit.getServer().getOnlinePlayers(); Collection<? extends Player> onlinePlayers = 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; if (Bukkit.getServer().getOnlinePlayers().size() > 0) {
target=AllOnPlayers[i]; 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);
if (target != null) {
PluginCore.getAICore().CancelTarget(CoreType.TOTEM);
PluginCore.getAICore().setAttackTarget(target);
Player player = (Player) target; Player player = (Player) target;
if (Bukkit.getServer().getOnlinePlayers().length>0){ if (Bukkit.getServer().getOnlinePlayers().size() > 0) {
int i = 0; for(Player onlinePlayer : onlinePlayers) {
for (i=0;i<=Bukkit.getServer().getOnlinePlayers().length-1;i++){
Location ploc = (Location) AllOnPlayers[i].getLocation();
if (AllOnPlayers[i].getName() != player.getName() && ploc.getX()+20>loc.getX() && ploc.getX()-20<loc.getX() && ploc.getZ()+20>loc.getZ() && ploc.getZ()-20<loc.getZ()){
Message.SendMessage(AllOnPlayers[i]); Location ploc = (Location) onlinePlayer.getLocation();
AllOnPlayers[i].addPotionEffect(new PotionEffect(PotionEffectType.CONFUSION, 1000, 1)); if (onlinePlayer.getName() != player.getName()
AllOnPlayers[i].addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, 1000, 1)); && ploc.getX() + 20 > loc.getX()
AllOnPlayers[i].addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 1000, 1)); && 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,29 +5,26 @@ import org.bukkit.Location;
import org.jakub1221.herobrineai.HerobrineAI; import org.jakub1221.herobrineai.HerobrineAI;
import org.jakub1221.herobrineai.misc.StructureLoader; import org.jakub1221.herobrineai.misc.StructureLoader;
public class GraveyardWorld {
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++) {
public static void Create(){ for (int z = -50; z <= 50; z++) {
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); loc.getWorld().getBlockAt(x, 3, z).setTypeId(110);
} }
} }
int MainX=-10; int MainX = -10;
int MainY=3; int MainY = 3;
int MainZ=-10; int MainZ = -10;
new StructureLoader(HerobrineAI.getPluginCore().data_graveyard_world).Build(loc.getWorld(), MainX, MainY, MainZ); StructureLoader structLoader = new StructureLoader(HerobrineAI.getPluginCore().getInputStreamData("/res/graveyard_world.yml"));
structLoader.Build(loc.getWorld(), MainX, MainY, MainZ);
} }

View File

@ -1,131 +1,29 @@
package org.jakub1221.herobrineai.AI.extensions; package org.jakub1221.herobrineai.AI.extensions;
import java.util.Random;
import org.bukkit.Location; 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){ for(int y = -2; y < 2; y++)
{
Location newloc = (Location) ploc; for(int x = -2; x < 2; x++)
{
int chance= new Random().nextInt(3); for(int z = -2; z < 2; z++)
{
if (chance==0){ 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();
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())){ Material topBlock = ploc.clone().add(new Location(ploc.getWorld(), x, y + 1 ,z)).getBlock().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{
if (bottomBlock.isSolid() && !middleBlock.isSolid() && !topBlock.isSolid())
return ploc.clone().add(new Location(ploc.getWorld(), x, y - 1 ,z));
} }
}
}else if(chance==1){
if (HerobrineAI.AllowedBlocks.contains(ploc.getWorld().getBlockAt(ploc.getBlockX()+2, ploc.getBlockY(), ploc.getBlockZ()).getType()) && HerobrineAI.AllowedBlocks.contains(ploc.getWorld().getBlockAt(ploc.getBlockX()+2, ploc.getBlockY()+1, ploc.getBlockZ()).getType())){
newloc.setX(newloc.getX()+2);
}else if (HerobrineAI.AllowedBlocks.contains(ploc.getWorld().getBlockAt(ploc.getBlockX()-2, ploc.getBlockY(), ploc.getBlockZ()).getType()) && HerobrineAI.AllowedBlocks.contains(ploc.getWorld().getBlockAt(ploc.getBlockX()-2, ploc.getBlockY()+1, ploc.getBlockZ()).getType())){
newloc.setX(newloc.getX()-2);
}else if (HerobrineAI.AllowedBlocks.contains(ploc.getWorld().getBlockAt(ploc.getBlockX(), ploc.getBlockY(), ploc.getBlockZ()-2).getType()) && HerobrineAI.AllowedBlocks.contains(ploc.getWorld().getBlockAt(ploc.getBlockX(), ploc.getBlockY()+1, ploc.getBlockZ()-2).getType())){
newloc.setZ(newloc.getZ()-2);
}else if (HerobrineAI.AllowedBlocks.contains(ploc.getWorld().getBlockAt(ploc.getBlockX(), ploc.getBlockY(), ploc.getBlockZ()+2).getType()) && HerobrineAI.AllowedBlocks.contains(ploc.getWorld().getBlockAt(ploc.getBlockX(), ploc.getBlockY()+1, ploc.getBlockZ()+2).getType())){
newloc.setZ(newloc.getZ()+2);
}else{
if (HerobrineAI.AllowedBlocks.contains(ploc.getWorld().getBlockAt(ploc.getBlockX()+2, ploc.getBlockY(), ploc.getBlockZ()).getType()) && HerobrineAI.AllowedBlocks.contains(ploc.getWorld().getBlockAt(ploc.getBlockX()+2, ploc.getBlockY()+1, ploc.getBlockZ()).getType())){
newloc.setX(newloc.getX()+2);
}else if (HerobrineAI.AllowedBlocks.contains(ploc.getWorld().getBlockAt(ploc.getBlockX()-2, ploc.getBlockY(), ploc.getBlockZ()).getType()) && HerobrineAI.AllowedBlocks.contains(ploc.getWorld().getBlockAt(ploc.getBlockX()-2, ploc.getBlockY()+1, ploc.getBlockZ()).getType())){
newloc.setX(newloc.getX()-2);
}else if (HerobrineAI.AllowedBlocks.contains(ploc.getWorld().getBlockAt(ploc.getBlockX(), ploc.getBlockY(), ploc.getBlockZ()-2).getType()) && HerobrineAI.AllowedBlocks.contains(ploc.getWorld().getBlockAt(ploc.getBlockX(), ploc.getBlockY()+1, ploc.getBlockZ()-2).getType())){
newloc.setZ(newloc.getZ()-2);
}else if (HerobrineAI.AllowedBlocks.contains(ploc.getWorld().getBlockAt(ploc.getBlockX(), ploc.getBlockY(), ploc.getBlockZ()+2).getType()) && HerobrineAI.AllowedBlocks.contains(ploc.getWorld().getBlockAt(ploc.getBlockX(), ploc.getBlockY()+1, ploc.getBlockZ()+2).getType())){
newloc.setZ(newloc.getZ()+2);
}else{
}
}
}else if(chance==2){
if (HerobrineAI.AllowedBlocks.contains(ploc.getWorld().getBlockAt(ploc.getBlockX(), ploc.getBlockY(), ploc.getBlockZ()-2).getType()) && HerobrineAI.AllowedBlocks.contains(ploc.getWorld().getBlockAt(ploc.getBlockX(), ploc.getBlockY()+1, ploc.getBlockZ()-2).getType())){
newloc.setZ(newloc.getZ()-2);
}
else if (HerobrineAI.AllowedBlocks.contains(ploc.getWorld().getBlockAt(ploc.getBlockX()+2, ploc.getBlockY(), ploc.getBlockZ()).getType()) && HerobrineAI.AllowedBlocks.contains(ploc.getWorld().getBlockAt(ploc.getBlockX()+2, ploc.getBlockY()+1, ploc.getBlockZ()).getType())){
newloc.setX(newloc.getX()+2);
}else if (HerobrineAI.AllowedBlocks.contains(ploc.getWorld().getBlockAt(ploc.getBlockX()-2, ploc.getBlockY(), ploc.getBlockZ()).getType()) && HerobrineAI.AllowedBlocks.contains(ploc.getWorld().getBlockAt(ploc.getBlockX()-2, ploc.getBlockY()+1, ploc.getBlockZ()).getType())){
newloc.setX(newloc.getX()-2);
}else if (HerobrineAI.AllowedBlocks.contains(ploc.getWorld().getBlockAt(ploc.getBlockX(), ploc.getBlockY(), ploc.getBlockZ()+2).getType()) && HerobrineAI.AllowedBlocks.contains(ploc.getWorld().getBlockAt(ploc.getBlockX(), ploc.getBlockY()+1, ploc.getBlockZ()+2).getType())){
newloc.setZ(newloc.getZ()+2);
}else{
if (HerobrineAI.AllowedBlocks.contains(ploc.getWorld().getBlockAt(ploc.getBlockX(), ploc.getBlockY(), ploc.getBlockZ()-2).getType()) && HerobrineAI.AllowedBlocks.contains(ploc.getWorld().getBlockAt(ploc.getBlockX(), ploc.getBlockY()+1, ploc.getBlockZ()-2).getType())){
newloc.setZ(newloc.getZ()-2);
}
else if (HerobrineAI.AllowedBlocks.contains(ploc.getWorld().getBlockAt(ploc.getBlockX()+2, ploc.getBlockY(), ploc.getBlockZ()).getType()) && HerobrineAI.AllowedBlocks.contains(ploc.getWorld().getBlockAt(ploc.getBlockX()+2, ploc.getBlockY()+1, ploc.getBlockZ()).getType())){
newloc.setX(newloc.getX()+2);
}else if (HerobrineAI.AllowedBlocks.contains(ploc.getWorld().getBlockAt(ploc.getBlockX()-2, ploc.getBlockY(), ploc.getBlockZ()).getType()) && HerobrineAI.AllowedBlocks.contains(ploc.getWorld().getBlockAt(ploc.getBlockX()-2, ploc.getBlockY()+1, ploc.getBlockZ()).getType())){
newloc.setX(newloc.getX()-2);
}else if (HerobrineAI.AllowedBlocks.contains(ploc.getWorld().getBlockAt(ploc.getBlockX(), ploc.getBlockY(), ploc.getBlockZ()+2).getType()) && HerobrineAI.AllowedBlocks.contains(ploc.getWorld().getBlockAt(ploc.getBlockX(), ploc.getBlockY()+1, ploc.getBlockZ()+2).getType())){
newloc.setZ(newloc.getZ()+2);
}else{
}
}
} if (chance==3){
if (HerobrineAI.AllowedBlocks.contains(ploc.getWorld().getBlockAt(ploc.getBlockX(), ploc.getBlockY(), ploc.getBlockZ()+2).getType()) && HerobrineAI.AllowedBlocks.contains(ploc.getWorld().getBlockAt(ploc.getBlockX(), ploc.getBlockY()+1, ploc.getBlockZ()+2).getType())){
newloc.setZ(newloc.getZ()+2);
}
else if (HerobrineAI.AllowedBlocks.contains(ploc.getWorld().getBlockAt(ploc.getBlockX()-2, ploc.getBlockY(), ploc.getBlockZ()).getType()) && HerobrineAI.AllowedBlocks.contains(ploc.getWorld().getBlockAt(ploc.getBlockX()-2, ploc.getBlockY()+1, ploc.getBlockZ()).getType())){
newloc.setX(newloc.getX()-2);
}else if (HerobrineAI.AllowedBlocks.contains(ploc.getWorld().getBlockAt(ploc.getBlockX()+2, ploc.getBlockY(), ploc.getBlockZ()).getType()) && HerobrineAI.AllowedBlocks.contains(ploc.getWorld().getBlockAt(ploc.getBlockX()+2, ploc.getBlockY()+1, ploc.getBlockZ()).getType())){
newloc.setX(newloc.getX()+2);
}else if (HerobrineAI.AllowedBlocks.contains(ploc.getWorld().getBlockAt(ploc.getBlockX(), ploc.getBlockY(), ploc.getBlockZ()-2).getType()) && HerobrineAI.AllowedBlocks.contains(ploc.getWorld().getBlockAt(ploc.getBlockX(), ploc.getBlockY()+1, ploc.getBlockZ()-2).getType())){
newloc.setZ(newloc.getZ()-2);
}else if (HerobrineAI.AllowedBlocks.contains(ploc.getWorld().getBlockAt(ploc.getBlockX(), ploc.getBlockY(), ploc.getBlockZ()+2).getType()) && HerobrineAI.AllowedBlocks.contains(ploc.getWorld().getBlockAt(ploc.getBlockX(), ploc.getBlockY()+1, ploc.getBlockZ()+2).getType())){
newloc.setZ(newloc.getZ()+2);
}else{
if (HerobrineAI.AllowedBlocks.contains(ploc.getWorld().getBlockAt(ploc.getBlockX(), ploc.getBlockY(), ploc.getBlockZ()+2).getType()) && HerobrineAI.AllowedBlocks.contains(ploc.getWorld().getBlockAt(ploc.getBlockX(), ploc.getBlockY()+1, ploc.getBlockZ()+2).getType())){
newloc.setZ(newloc.getZ()+2);
}
else if (HerobrineAI.AllowedBlocks.contains(ploc.getWorld().getBlockAt(ploc.getBlockX()-2, ploc.getBlockY(), ploc.getBlockZ()).getType()) && HerobrineAI.AllowedBlocks.contains(ploc.getWorld().getBlockAt(ploc.getBlockX()-2, ploc.getBlockY()+1, ploc.getBlockZ()).getType())){
newloc.setX(newloc.getX()-2);
}else if (HerobrineAI.AllowedBlocks.contains(ploc.getWorld().getBlockAt(ploc.getBlockX()+2, ploc.getBlockY(), ploc.getBlockZ()).getType()) && HerobrineAI.AllowedBlocks.contains(ploc.getWorld().getBlockAt(ploc.getBlockX()+2, ploc.getBlockY()+1, ploc.getBlockZ()).getType())){
newloc.setX(newloc.getX()+2);
}else if (HerobrineAI.AllowedBlocks.contains(ploc.getWorld().getBlockAt(ploc.getBlockX(), ploc.getBlockY(), ploc.getBlockZ()-2).getType()) && HerobrineAI.AllowedBlocks.contains(ploc.getWorld().getBlockAt(ploc.getBlockX(), ploc.getBlockY()+1, ploc.getBlockZ()-2).getType())){
newloc.setZ(newloc.getZ()-2);
}else{
}
} }
} }
return newloc; return ploc;
} }

View File

@ -8,6 +8,7 @@ import java.util.List;
import java.util.logging.Logger; import java.util.logging.Logger;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.World;
import org.bukkit.configuration.InvalidConfigurationException; import org.bukkit.configuration.InvalidConfigurationException;
import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.configuration.file.YamlConfiguration;
import org.jakub1221.herobrineai.misc.CustomID; import org.jakub1221.herobrineai.misc.CustomID;
@ -23,7 +24,7 @@ public class ConfigDB {
public boolean Lighting=true; public boolean Lighting=true;
public boolean DestroyTorches=true; public boolean DestroyTorches=true;
public int DestroyTorchesRadius=5; public int DestroyTorchesRadius=5;
public int ShowInterval=30000; public int ShowInterval=144000;
public boolean TotemExplodes=true; public boolean TotemExplodes=true;
public boolean OnlyWalkingMode=false; public boolean OnlyWalkingMode=false;
public boolean BuildStuff=true; public boolean BuildStuff=true;
@ -62,7 +63,7 @@ public class ConfigDB {
public boolean SecuredArea_Signs = true; public boolean SecuredArea_Signs = true;
public boolean SecuredArea_Books = true; public boolean SecuredArea_Books = true;
public int HerobrineHP = 150; public int HerobrineHP = 150;
public int BuildInterval = 45000; public int BuildInterval = 72000;
public boolean UseHeads = true; public boolean UseHeads = true;
public boolean UseCustomItems = false; public boolean UseCustomItems = false;
public boolean UseAncientSword = true; public boolean UseAncientSword = true;
@ -74,6 +75,12 @@ public class ConfigDB {
public boolean Explosions=true; public boolean Explosions=true;
public boolean Burn=true; public boolean Burn=true;
public boolean Curse=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){ public ConfigDB(Logger l){
this.log=l; this.log=l;
@ -125,18 +132,21 @@ public class ConfigDB {
if (!npc.contains("npc.Guardian")){ if (!npc.contains("npc.Guardian")){
npc.set("npc.Guardian.SpawnCount", 1); npc.set("npc.Guardian.SpawnCount", 1);
npc.set("npc.Guardian.HP", 40); 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.Chance", 40);
npc.set("npc.Guardian.Drops.283.Count", 1); npc.set("npc.Guardian.Drops.283.Count", 1);
npc.set("npc.Guardian.Drops.286.Chance", 30); npc.set("npc.Guardian.Drops.286.Chance", 30);
npc.set("npc.Guardian.Drops.286.Count", 1); 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.HP", 40);
npc.set("npc.Warrior.Speed", 0.3);
npc.set("npc.Warrior.Drops.307.Chance", 25); npc.set("npc.Warrior.Drops.307.Chance", 25);
npc.set("npc.Warrior.Drops.307.Count", 1); npc.set("npc.Warrior.Drops.307.Count", 1);
npc.set("npc.Warrior.Drops.306.Chance", 20); npc.set("npc.Warrior.Drops.306.Chance", 20);
npc.set("npc.Warrior.Drops.306.Count", 1); 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.HP", 40);
npc.set("npc.Demon.Speed", 0.3);
npc.set("npc.Demon.Drops.322.Chance", 40); npc.set("npc.Demon.Drops.322.Chance", 40);
npc.set("npc.Demon.Drops.322.Count", 1); npc.set("npc.Demon.Drops.322.Count", 1);
npc.set("npc.Demon.Drops.397.Chance", 20); npc.set("npc.Demon.Drops.397.Chance", 20);
@ -167,7 +177,7 @@ public class ConfigDB {
UseCustomItemsList.add("ItemExample"); UseCustomItemsList.add("ItemExample");
log.info("[HerobrineAI] Creating new Config ..."); log.info("[HerobrineAI] Creating new Config ...");
config.set("config.ShowInterval", 30000); config.set("config.ShowInterval", 144000);
config.set("config.ShowRate", 2); config.set("config.ShowRate", 2);
config.set("config.HitPlayer", true); config.set("config.HitPlayer", true);
config.set("config.SendMessages", true); config.set("config.SendMessages", true);
@ -202,12 +212,12 @@ public class ConfigDB {
config.set("config.WalkingModeRadius.Z", 1000); config.set("config.WalkingModeRadius.Z", 1000);
config.set("config.WalkingModeRadius.FromX", 0); config.set("config.WalkingModeRadius.FromX", 0);
config.set("config.WalkingModeRadius.FromZ", 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.BuildTemples", true);
config.set("config.UseArtifacts.Bow", true); config.set("config.UseArtifacts.Bow", true);
config.set("config.UseArtifacts.Sword", true); config.set("config.UseArtifacts.Sword", true);
config.set("config.UseArtifacts.Apple", 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.AttackCreative", true);
config.set("config.AttackOP", true); config.set("config.AttackOP", true);
config.set("config.SecuredArea.Build", true); config.set("config.SecuredArea.Build", true);
@ -226,6 +236,10 @@ public class ConfigDB {
config.set("config.Explosions", true); config.set("config.Explosions", true);
config.set("config.Burn", true); config.set("config.Burn", true);
config.set("config.Curse", 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 { try {
config.save(configF); config.save(configF);
@ -453,10 +467,41 @@ public class ConfigDB {
config.set("config.Curse", 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){ if (hasUpdated==true){
try { try {
config.save(configF); config.save(configF);
npc.save(npcF);
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
@ -545,6 +590,10 @@ public class ConfigDB {
Explosions=config.getBoolean("config.Explosions"); Explosions=config.getBoolean("config.Explosions");
Burn=config.getBoolean("config.Burn"); Burn=config.getBoolean("config.Burn");
Curse=config.getBoolean("config.Curse"); 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.HerobrineMaxHP=HerobrineHP;
HerobrineAI.getPluginCore().getAICore().Stop_MAIN(); HerobrineAI.getPluginCore().getAICore().Stop_MAIN();
@ -554,17 +603,68 @@ public class ConfigDB {
HerobrineAI.getPluginCore().getAICore().Stop_RC(); HerobrineAI.getPluginCore().getAICore().Stop_RC();
HerobrineAI.getPluginCore().getAICore().Start_RC(); HerobrineAI.getPluginCore().getAICore().Start_RC();
HerobrineAI.AvailableWorld=false; HerobrineAI.AvailableWorld=false;
HerobrineAI.getPluginCore().getAICore().getResetLimits().updateFromConfig();
if (HerobrineAI.HerobrineNPC!=null){ if (HerobrineAI.HerobrineNPC!=null){
HerobrineAI.HerobrineNPC.setItemInHand(ItemInHand.getItemStack()); HerobrineAI.HerobrineNPC.setItemInHand(ItemInHand.getItemStack());
} }
for (int i = 0;i<=useWorlds.size()-1;i++){
if (isStartupDone){
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 (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.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Random;
import java.util.logging.Logger; import java.util.logging.Logger;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Color;
import org.bukkit.GameMode; import org.bukkit.GameMode;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
@ -18,8 +20,9 @@ import org.bukkit.WorldCreator;
import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandExecutor;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.metadata.FixedMetadataValue;
import org.bukkit.plugin.java.JavaPlugin; 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.AI.PathManager;
import org.jakub1221.herobrineai.NPC.Entity.HumanNPC; import org.jakub1221.herobrineai.NPC.Entity.HumanNPC;
import org.jakub1221.herobrineai.NPC.NPCCore; 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.PlayerListener;
import org.jakub1221.herobrineai.listeners.WorldListener; 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 static HerobrineAI pluginCore;
private AICore aicore; private AICore aicore;
@ -46,14 +47,16 @@ public class HerobrineAI extends JavaPlugin implements Listener{
private Support support; private Support support;
private EntityManager entMng; private EntityManager entMng;
private PathManager pathMng; private PathManager pathMng;
public static final int build=3127; public static final int build = 3219;
public static final String versionStr="3.1.0"; public static final String versionStr = "3.2.2";
public java.io.InputStream data_temple=HerobrineAI.class.getResourceAsStream("/res/temple.yml"); public static boolean isNPCDisabled = false;
public java.io.InputStream data_graveyard_world=HerobrineAI.class.getResourceAsStream("/res/graveyard_world.yml"); private static int pathUpdateINT = 0;
public static int HerobrineHP=200; public static String bukkit_ver_string = "1.6.4 R0.1";
public static int HerobrineMaxHP=200; public static int HerobrineHP = 200;
public static final boolean isDebugging=false; public static int HerobrineMaxHP = 200;
public static final boolean isDebugging = false;
public static boolean isInitDone = false;
public static NPCCore NPCman; public static NPCCore NPCman;
public static HumanNPC HerobrineNPC; public static HumanNPC HerobrineNPC;
@ -64,16 +67,27 @@ public class HerobrineAI extends JavaPlugin implements Listener{
public static List<Material> AllowedBlocks = new ArrayList<Material>(); public static List<Material> AllowedBlocks = new ArrayList<Material>();
public static List<Material> StandBlocks = new ArrayList<Material>(); public static List<Material> StandBlocks = new ArrayList<Material>();
public static List<Material> NonStandBlocks = 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 static Logger log = Logger.getLogger("Minecraft");
public void onEnable(){ public void onEnable() {
boolean errorCheck = true;
try {
Class.forName("net.minecraft.server.v1_6_R3.Entity");
} catch (ClassNotFoundException e) {
errorCheck = false;
isInitDone = false;
}
if (errorCheck) {
isInitDone = true;
HerobrineAI.pluginCore = this;
NPCman = new NPCCore(this); NPCman = new NPCCore(this);
HerobrineAI.pluginCore = this;
this.configdb = new ConfigDB(log);
this.configdb = new ConfigDB(log);
getServer().getPluginManager().registerEvents(new EntityListener(), this); getServer().getPluginManager().registerEvents(new EntityListener(), this);
getServer().getPluginManager().registerEvents(new BlockListener(), this); getServer().getPluginManager().registerEvents(new BlockListener(), this);
@ -109,17 +123,18 @@ public class HerobrineAI extends JavaPlugin implements Listener{
// Spawn Herobrine // Spawn Herobrine
Location nowloc = new Location((World) Bukkit.getServer().getWorlds().get(0),(float) 0,(float) -20,(float) 0); Location nowloc = new Location((World) Bukkit.getServer().getWorlds().get(0), (float) 0, (float) -20,
(float) 0);
nowloc.setYaw((float) 1); nowloc.setYaw((float) 1);
nowloc.setPitch((float) 1); nowloc.setPitch((float) 1);
HerobrineSpawn(nowloc); HerobrineSpawn(nowloc);
HerobrineNPC.setItemInHand(configdb.ItemInHand.getItemStack()); HerobrineNPC.setItemInHand(configdb.ItemInHand.getItemStack());
//Graveyard World // Graveyard World
if (this.configdb.UseGraveyardWorld==true){ if (this.configdb.UseGraveyardWorld == true) {
if (Bukkit.getServer().getWorld("world_herobrineai_graveyard")==null){ if (Bukkit.getServer().getWorld("world_herobrineai_graveyard") == null) {
log.info("[HerobrineAI] Creating Graveyard world..."); log.info("[HerobrineAI] Creating Graveyard world...");
WorldCreator wc = new WorldCreator("world_herobrineai_graveyard"); WorldCreator wc = new WorldCreator("world_herobrineai_graveyard");
wc.generateStructures(false); wc.generateStructures(false);
@ -130,7 +145,7 @@ public class HerobrineAI extends JavaPlugin implements Listener{
} }
} }
log.info("[HerobrineAI] Plugin loaded! Version: "+versionStr+" / Build: "+build); log.info("[HerobrineAI] Plugin loaded! Version: " + versionStr + " / Build: " + build);
// Init Block Types // Init Block Types
@ -173,22 +188,36 @@ public class HerobrineAI extends JavaPlugin implements Listener{
AllowedBlocks.add(Material.getMaterial(77)); AllowedBlocks.add(Material.getMaterial(77));
AllowedBlocks.add(Material.LADDER); 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;} * Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(this,
} * new Runnable() { public void run() {
if (AvailableWorld==false){ *
log.info("**********************************************************"); * for (int i = 0;i<=configdb.useWorlds.size()-1;i++){ if
log.info("[HerobrineAI] There are no available worlds for Herobrine!"); * (Bukkit.getServer().getWorlds().contains(Bukkit.getServer().
log.info("**********************************************************"); * 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() {
Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(AICore.plugin, new Runnable() {
public void run() { 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));
} }
}, 1 * 35L, 1 * 35L); }
}, 1 * 200L, 1 * 200L);
Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(this, new Runnable() { Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(this, new Runnable() {
public void run() { public void run() {
@ -196,156 +225,230 @@ public class HerobrineAI extends JavaPlugin implements Listener{
} }
}, 1 * 5L, 1 * 5L); }, 1 * 5L, 1 * 5L);
// Command Executors
//Command Executors
this.getCommand("hb").setExecutor((CommandExecutor) new CmdExecutor(this)); this.getCommand("hb").setExecutor((CommandExecutor) new CmdExecutor(this));
this.getCommand("hb-ai").setExecutor((CommandExecutor) new CmdExecutor(this)); this.getCommand("hb-ai").setExecutor((CommandExecutor) new CmdExecutor(this));
//Support initialize // Support initialize
this.support = new Support(); this.support = new Support();
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;
}
//Register mobs if (!isNPCDisabled) {
try{ try {
@SuppressWarnings("rawtypes") @SuppressWarnings("rawtypes")
Class[] args = new Class[3]; Class[] args = new Class[3];
args[0] = Class.class; args[0] = Class.class;
args[1] = String.class; args[1] = String.class;
args[2] = int.class; args[2] = int.class;
Method a = net.minecraft.server.v1_5_R2.EntityTypes.class.getDeclaredMethod("a", args); Method a = net.minecraft.server.v1_11_R1.EntityTypes.class.getDeclaredMethod("a", args);
a.setAccessible(true); a.setAccessible(true);
a.invoke(a, CustomZombie.class, "Zombie", 54); a.invoke(a, CustomZombie.class, "Zombie", 54);
a.invoke(a, CustomSkeleton.class, "Skeleton", 51); a.invoke(a, CustomSkeleton.class, "Skeleton", 51);
}catch (Exception e){ } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
this.setEnabled(false); 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 void onDisable() {
public void onDisable(){ if (isInitDone) {
this.entMng.killAllMobs(); this.entMng.killAllMobs();
Bukkit.getServer().getScheduler().cancelTask(pathUpdateINT);
NPCman.DisableTask(); NPCman.DisableTask();
aicore.CancelTarget(CoreType.ANY); 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!"); log.info("[HerobrineAI] Plugin disabled!");
}
} }
public AICore getAICore(){ public java.io.InputStream getInputStreamData(String src) {
return HerobrineAI.class.getResourceAsStream(src);
}
public AICore getAICore() {
return this.aicore; return this.aicore;
} }
public EntityManager getEntityManager(){ public EntityManager getEntityManager() {
return this.entMng; return this.entMng;
} }
public static HerobrineAI getPluginCore(){ public static HerobrineAI getPluginCore() {
return HerobrineAI.pluginCore; return HerobrineAI.pluginCore;
} }
public void HerobrineSpawn(Location loc){ public void HerobrineSpawn(Location loc) {
HerobrineNPC = (HumanNPC) NPCman.spawnHumanNPC(ChatColor.WHITE+"Herobrine", loc); HerobrineNPC = (HumanNPC) NPCman.spawnHumanNPC(ChatColor.WHITE + "Herobrine", loc);
HerobrineEntityID=HerobrineNPC.getBukkitEntity().getEntityId(); HerobrineNPC.getBukkitEntity().setMetadata("NPC", new FixedMetadataValue(this, true));
HerobrineEntityID = HerobrineNPC.getBukkitEntity().getEntityId();
} }
public void HerobrineRemove(){
HerobrineEntityID=0; public void HerobrineRemove() {
HerobrineNPC=null;
HerobrineEntityID = 0;
HerobrineNPC = null;
NPCman.removeAll(); NPCman.removeAll();
} }
public ConfigDB getConfigDB(){
public ConfigDB getConfigDB() {
return this.configdb; return this.configdb;
} }
public String getVersionStr(){
public String getVersionStr() {
return versionStr; return versionStr;
} }
public Support getSupport(){
public Support getSupport() {
return this.support; return this.support;
} }
public PathManager getPathManager(){
public PathManager getPathManager() {
return this.pathMng; return this.pathMng;
} }
public boolean canAttackPlayer(Player player,Player sender){
if (player.isOp()){ public boolean canAttackPlayer(Player player, Player sender) {
if (configdb.AttackOP){
if (player.getGameMode()==GameMode.CREATIVE){ boolean opCheck = true;
if (configdb.AttackCreative){ boolean creativeCheck = true;
return true; boolean ignoreCheck = true;
}else{sender.sendMessage(ChatColor.RED+"[HerobrineAI] Player is in Creative mode.");return false;}
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; return true;
}else{sender.sendMessage(ChatColor.RED+"[HerobrineAI] Player is OP.");return false;} } else {
}else if (player.hasPermission("hb-ai.ignore")){ if (!opCheck) {
sender.sendMessage(ChatColor.RED+"[HerobrineAI] Player has ignore permission."); 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; 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()){ public boolean canAttackPlayerConsole(Player player) {
if (configdb.AttackOP){
if (player.getGameMode()==GameMode.CREATIVE){ boolean opCheck = true;
if (configdb.AttackCreative){ boolean creativeCheck = true;
return true; boolean ignoreCheck = true;
}else{log.info("[HerobrineAI] Player is in Creative mode.");return false;}
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; return true;
}else{log.info("[HerobrineAI] Player is OP.");return false;} } else {
}else if (player.hasPermission("hb-ai.ignore")){ 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."); log.info("[HerobrineAI] Player has ignore permission.");
}
return false; 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){ public boolean canAttackPlayerNoMSG(Player player) {
if (player.isOp()){ boolean opCheck = true;
if (configdb.AttackOP){ boolean creativeCheck = true;
if (player.getGameMode()==GameMode.CREATIVE){ boolean ignoreCheck = true;
if (configdb.AttackCreative){
return true; if (!configdb.AttackOP) {
}else{return false;} 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; return true;
}else{return false;} } else {
}else if (player.hasPermission("hb-ai.ignore")){
return false; return false;
}else if (player.getGameMode()==GameMode.CREATIVE){
if (configdb.AttackCreative){
return true;
}else{return false;}
}else{return true;}
} }
public String getAvailableWorldString(){ }
if (AvailableWorld){
public String getAvailableWorldString() {
if (AvailableWorld) {
return "Yes"; return "Yes";
}else{ } else {
return "No"; return "No";
} }
} }
} }

View File

@ -360,7 +360,7 @@ public class Metrics {
data.append(encode("guid")).append('=').append(encode(guid)); data.append(encode("guid")).append('=').append(encode(guid));
encodeDataPair(data, "version", description.getVersion()); encodeDataPair(data, "version", description.getVersion());
encodeDataPair(data, "server", Bukkit.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)); encodeDataPair(data, "revision", String.valueOf(REVISION));
// If we're pinging, append it // If we're pinging, append it

View File

@ -97,9 +97,12 @@ public class Path {
} }
}else{ }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); HerobrineAI.HerobrineNPC.setPitch(0);
} }

View File

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

View File

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

View File

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

View File

@ -5,13 +5,13 @@ import java.util.List;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
import net.minecraft.server.v1_5_R2.DedicatedServer; import net.minecraft.server.v1_6_R3.DedicatedServer;
import net.minecraft.server.v1_5_R2.MinecraftServer; import net.minecraft.server.v1_6_R3.MinecraftServer;
import net.minecraft.server.v1_5_R2.WorldServer; import net.minecraft.server.v1_6_R3.WorldServer;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Server; import org.bukkit.Server;
import org.bukkit.craftbukkit.v1_5_R2.CraftServer; import org.bukkit.craftbukkit.v1_6_R3.CraftServer;
public class BServer { public class BServer {
private static BServer ins; private static BServer ins;

View File

@ -6,17 +6,17 @@ import java.util.concurrent.Callable;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
import net.minecraft.server.v1_5_R2.AxisAlignedBB; import net.minecraft.server.v1_11_R1.AxisAlignedBB;
import net.minecraft.server.v1_5_R2.Entity; import net.minecraft.server.v1_11_R1.Entity;
import net.minecraft.server.v1_5_R2.EntityPlayer; import net.minecraft.server.v1_11_R1.EntityPlayer;
import net.minecraft.server.v1_5_R2.PlayerChunkMap; import net.minecraft.server.v1_11_R1.PlayerChunkMap;
import net.minecraft.server.v1_5_R2.WorldProvider; import net.minecraft.server.v1_11_R1.WorldProvider;
import net.minecraft.server.v1_5_R2.WorldServer; import net.minecraft.server.v1_11_R1.WorldServer;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.craftbukkit.v1_5_R2.CraftWorld; import org.bukkit.craftbukkit.v1_11_R1.CraftWorld;
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.entity.Player;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;

View File

@ -6,8 +6,8 @@ import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.Map; import java.util.Map;
import net.minecraft.server.v1_5_R2.Entity; import net.minecraft.server.v1_11_R1.Entity;
import net.minecraft.server.v1_5_R2.PlayerInteractManager; import net.minecraft.server.v1_11_R1.PlayerInteractManager;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;
@ -32,8 +32,8 @@ public class NPCCore {
private Map<World, BWorld> bworlds = new HashMap<World, BWorld>(); private Map<World, BWorld> bworlds = new HashMap<World, BWorld>();
private NetworkCore networkCore; private NetworkCore networkCore;
public static JavaPlugin plugin; public static JavaPlugin plugin;
public boolean isInLoaded=false; public boolean isInLoaded = false;
private int lastID=0; private int lastID = 0;
public NPCCore(JavaPlugin plugin) { public NPCCore(JavaPlugin plugin) {
server = BServer.getInstance(); server = BServer.getInstance();
@ -44,7 +44,6 @@ public class NPCCore {
e.printStackTrace(); e.printStackTrace();
} }
taskid = Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable() { taskid = Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable() {
@Override @Override
public void run() { public void run() {
@ -83,7 +82,7 @@ public class NPCCore {
return bworld; return bworld;
} }
public void DisableTask(){ public void DisableTask() {
Bukkit.getServer().getScheduler().cancelTask(taskid); Bukkit.getServer().getScheduler().cancelTask(taskid);
} }
@ -92,21 +91,24 @@ public class NPCCore {
@EventHandler @EventHandler
public void onChunkLoad(ChunkLoadEvent event) throws EventException { public void onChunkLoad(ChunkLoadEvent event) throws EventException {
for (HumanNPC humannpc : npcs) { for (HumanNPC humannpc : npcs) {
if (humannpc != null && event.getChunk() == humannpc.getBukkitEntity().getLocation().getBlock().getChunk()) { if (humannpc != null
&& event.getChunk() == humannpc.getBukkitEntity().getLocation().getBlock().getChunk()) {
if (isInLoaded==false){ if (isInLoaded == false) {
BWorld world = getBWorld(event.getWorld()); BWorld world = getBWorld(event.getWorld());
isInLoaded=true; isInLoaded = true;
}} }
}
} }
} }
@EventHandler @EventHandler
public void onChunkUnload(ChunkUnloadEvent event){ public void onChunkUnload(ChunkUnloadEvent event) {
for (HumanNPC humannpc : npcs) { for (HumanNPC humannpc : npcs) {
if (humannpc != null && event.getChunk() == humannpc.getBukkitEntity().getLocation().getBlock().getChunk()) { if (humannpc != null
&& event.getChunk() == humannpc.getBukkitEntity().getLocation().getBlock().getChunk()) {
} }
} }
@ -123,19 +125,17 @@ public class NPCCore {
BWorld world = getBWorld(l.getWorld()); BWorld world = getBWorld(l.getWorld());
HumanEntity humanEntity = new HumanEntity(this, world, name, new PlayerInteractManager(world.getWorldServer())); HumanEntity humanEntity = new HumanEntity(this, world, name, new PlayerInteractManager(world.getWorldServer()));
((Entity) humanEntity).setLocation(l.getX(), l.getY(), l.getZ(),l.getYaw(),l.getPitch()); ((Entity) humanEntity).setLocation(l.getX(), l.getY(), l.getZ(), l.getYaw(), l.getPitch());
world.getWorldServer().addEntity(humanEntity); world.getWorldServer().addEntity(humanEntity);
HumanNPC humannpc = new HumanNPC(humanEntity,id); HumanNPC humannpc = new HumanNPC(humanEntity, id);
npcs.add(humannpc); npcs.add(humannpc);
return humannpc; return humannpc;
} }
public HumanNPC getHumanNPC(int id) { public HumanNPC getHumanNPC(int id) {
for(HumanNPC n : npcs){ for (HumanNPC n : npcs) {
if (n.getID()==id){ if (n.getID() == id) {
return n; return n;
} }
} }

View File

@ -2,9 +2,9 @@ package org.jakub1221.herobrineai.NPC.Network;
import java.io.IOException; import java.io.IOException;
import net.minecraft.server.v1_5_R2.Connection; import net.minecraft.server.v1_11_R1.Connection;
import net.minecraft.server.v1_5_R2.NetworkManager; import net.minecraft.server.v1_11_R1.NetworkManager;
import net.minecraft.server.v1_5_R2.Packet; import net.minecraft.server.v1_11_R1.Packet;
public class NetworkCore extends NetworkManager{ public class NetworkCore extends NetworkManager{

View File

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

View File

@ -1,11 +1,11 @@
package org.jakub1221.herobrineai.NPC.Network; 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.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.World; 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.entity.Player;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;

View File

@ -3,6 +3,7 @@ package org.jakub1221.herobrineai;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;
import org.jakub1221.herobrineai.support._CustomItems; import org.jakub1221.herobrineai.support._CustomItems;
import org.jakub1221.herobrineai.support._Factions;
import org.jakub1221.herobrineai.support._GriefPrevention; import org.jakub1221.herobrineai.support._GriefPrevention;
import org.jakub1221.herobrineai.support._PreciousStones; import org.jakub1221.herobrineai.support._PreciousStones;
import org.jakub1221.herobrineai.support._Residence; import org.jakub1221.herobrineai.support._Residence;
@ -17,12 +18,14 @@ public class Support {
private boolean B_CustomItems=false; private boolean B_CustomItems=false;
private boolean B_WorldGuard=false; private boolean B_WorldGuard=false;
private boolean B_PreciousStones=false; private boolean B_PreciousStones=false;
private boolean B_Factions=false;
private _Residence ResidenceCore=null; private _Residence ResidenceCore=null;
private _GriefPrevention GriefPreventionCore=null; private _GriefPrevention GriefPreventionCore=null;
private _Towny TownyCore=null; private _Towny TownyCore=null;
private _CustomItems CustomItems=null; private _CustomItems CustomItems=null;
private _WorldGuard WorldGuard=null; private _WorldGuard WorldGuard=null;
private _PreciousStones PreciousStones=null; private _PreciousStones PreciousStones=null;
private _Factions Factions=null;
public Support(){ public Support(){
ResidenceCore=new _Residence(); ResidenceCore=new _Residence();
@ -31,11 +34,12 @@ public class Support {
CustomItems=new _CustomItems(); CustomItems=new _CustomItems();
WorldGuard=new _WorldGuard(); WorldGuard=new _WorldGuard();
PreciousStones=new _PreciousStones(); PreciousStones=new _PreciousStones();
Factions=new _Factions();
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(HerobrineAI.getPluginCore(), new Runnable() { Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(HerobrineAI.getPluginCore(), new Runnable() {
public void run() { public void run() {
CheckForPlugins(); CheckForPlugins();
} }
}, 1 * 10L); }, 1 * 2L);
} }
public boolean isPreciousStones(){ public boolean isPreciousStones(){
@ -53,6 +57,9 @@ public class Support {
public boolean isTowny(){ public boolean isTowny(){
return B_Towny; return B_Towny;
} }
public boolean isFactions(){
return B_Factions;
}
public void CheckForPlugins(){ public void CheckForPlugins(){
if (ResidenceCore.Check()){ if (ResidenceCore.Check()){
B_Residence=true; B_Residence=true;
@ -79,6 +86,10 @@ public class Support {
B_PreciousStones=true; B_PreciousStones=true;
HerobrineAI.log.info("[HerobrineAI] PreciousStones plugin detected!"); 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){ public boolean isSecuredArea(Location loc){
if (B_Residence){ if (B_Residence){
@ -101,6 +112,10 @@ public class Support {
if (PreciousStones.isSecuredArea(loc)){ if (PreciousStones.isSecuredArea(loc)){
return true; return true;
}else{return false;} }else{return false;}
}else if (B_Factions){
if (Factions.isSecuredArea(loc)){
return true;
}else{return false;}
} }
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,40 +1,43 @@
package org.jakub1221.herobrineai.entity; package org.jakub1221.herobrineai.entity;
import java.util.Random;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.entity.Skeleton; import org.bukkit.entity.Skeleton;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.Color; import org.bukkit.Color;
import org.jakub1221.herobrineai.HerobrineAI; import org.jakub1221.herobrineai.HerobrineAI;
import org.jakub1221.herobrineai.Utils;
import org.jakub1221.herobrineai.misc.ItemName; 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; private MobType mobType = null;
public CustomSkeleton(World world,Location loc,MobType mbt) { public CustomSkeleton(World world, Location loc, MobType mbt) {
super(world); super(world);
this.mobType=mbt; this.mobType = mbt;
if (mbt==MobType.DEMON){ if (mbt == MobType.DEMON) {
spawnDemon(loc); spawnDemon(loc);
} }
} }
public void spawnDemon(Location loc){ public void spawnDemon(Location loc) {
this.health=HerobrineAI.getPluginCore().getConfigDB().npc.getInt("npc.Demon.HP"); 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"); 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 entityCast = (Skeleton) this.getBukkitEntity();
((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)); entityCast.getEquipment().setItemInHand(new ItemStack(Material.GOLDEN_APPLE, 1));
((Skeleton)this.getBukkitEntity()).getEquipment().setLeggings(ItemName.colorLeatherArmor(new ItemStack(Material.LEATHER_LEGGINGS,1), Color.RED)); entityCast.getEquipment().setHelmet(ItemName.colorLeatherArmor(new ItemStack(Material.LEATHER_HELMET, 1), Color.RED));
((Skeleton)this.getBukkitEntity()).getEquipment().setBoots(ItemName.colorLeatherArmor(new ItemStack(Material.LEATHER_BOOTS,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); this.getBukkitEntity().teleport(loc);
} }
@ -44,16 +47,22 @@ public class CustomSkeleton extends net.minecraft.server.v1_5_R2.EntitySkeleton
} }
@Override @Override
public void Kill(){ public void Kill() {
for(int i=1;i<=2500;i++){ for (int i = 1; i <= 2500; i++) {
if (HerobrineAI.getPluginCore().getConfigDB().npc.contains("npc.Demon.Drops."+Integer.toString(i))==true){ if (HerobrineAI.getPluginCore().getConfigDB().npc.contains("npc.Demon.Drops." + Integer.toString(i)) == true) {
int chance=new Random().nextInt(100); int chance = Utils.getRandomGen().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"))); 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 @Override

View File

@ -4,51 +4,65 @@ import java.util.Random;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; 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.HerobrineAI;
import org.jakub1221.herobrineai.Utils;
import net.minecraft.server.v1_5_R2.ItemStack; import net.minecraft.server.v1_11_R1.GenericAttributes;
import net.minecraft.server.v1_5_R2.World; import net.minecraft.server.v1_11_R1.World;
public class CustomZombie extends net.minecraft.server.v1_5_R2.EntityZombie implements CustomEntity{ public class CustomZombie extends net.minecraft.server.v1_11_R1.EntityZombie implements CustomEntity {
private MobType mobType=null; private MobType mobType = null;
public CustomZombie(World world,Location loc,MobType mbt) { public CustomZombie(World world, Location loc, MobType mbt) {
super(world); super(world);
this.mobType=mbt; this.mobType = mbt;
if (mbt==MobType.ARTIFACT_GUARDIAN){ if (mbt == MobType.ARTIFACT_GUARDIAN) {
spawnArtifactGuardian(loc); spawnArtifactGuardian(loc);
}else if (mbt==MobType.HEROBRINE_WARRIOR){ } else if (mbt == MobType.HEROBRINE_WARRIOR) {
spawnHerobrineWarrior(loc); spawnHerobrineWarrior(loc);
} }
} }
private void spawnArtifactGuardian(Location loc){ 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.health=HerobrineAI.getPluginCore().getConfigDB().npc.getInt("npc.Guardian.HP");
this.setCustomName("Artifact Guardian"); 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)); Zombie entityCast = (Zombie) this.getBukkitEntity();
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)); entityCast.getEquipment().setItemInMainHand(new ItemStack(Material.GOLD_SWORD, 1));
this.setEquipment(3, new ItemStack(net.minecraft.server.v1_5_R2.Item.GOLD_CHESTPLATE)); entityCast.getEquipment().setHelmet(new ItemStack(Material.GOLD_HELMET, 1));
this.setEquipment(4, new ItemStack(net.minecraft.server.v1_5_R2.Item.GOLD_HELMET)); 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); this.getBukkitEntity().teleport(loc);
} }
private void spawnHerobrineWarrior(Location 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.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); this.getBukkitEntity().teleport(loc);
} }
@ -61,18 +75,28 @@ public class CustomZombie extends net.minecraft.server.v1_5_R2.EntityZombie impl
public void Kill() { public void Kill() {
String mobS = ""; String mobS = "";
if (this.mobType==MobType.ARTIFACT_GUARDIAN){mobS="Guardian";}else{mobS="Warrior";} if (this.mobType == MobType.ARTIFACT_GUARDIAN) {
mobS = "Guardian";
} else {
mobS = "Warrior";
}
for(int i=1;i<=2500;i++){ for (int i = 1; i <= 2500; i++) {
if (HerobrineAI.getPluginCore().getConfigDB().npc.contains("npc."+mobS+".Drops."+Integer.toString(i))==true){ if (HerobrineAI.getPluginCore().getConfigDB().npc.contains("npc." + mobS + ".Drops." + Integer.toString(i)) == true) {
int chance=new Random().nextInt(100); int chance = Utils.getRandomGen().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"))); 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.health=0; this.setHealth(0);
} }
@Override @Override

View File

@ -5,7 +5,6 @@ import java.util.Map;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.World; import org.bukkit.World;
import org.jakub1221.herobrineai.HerobrineAI;
public class EntityManager { public class EntityManager {
@ -14,7 +13,7 @@ public class EntityManager {
public void spawnCustomZombie(Location loc,MobType mbt){ public void spawnCustomZombie(Location loc,MobType mbt){
World world = loc.getWorld(); 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); CustomZombie zmb = new CustomZombie(mcWorld,loc,mbt);
mcWorld.addEntity(zmb); mcWorld.addEntity(zmb);
mobList.put(new Integer(zmb.getBukkitEntity().getEntityId()),zmb); mobList.put(new Integer(zmb.getBukkitEntity().getEntityId()),zmb);
@ -24,7 +23,7 @@ public class EntityManager {
public void spawnCustomSkeleton(Location loc,MobType mbt){ public void spawnCustomSkeleton(Location loc,MobType mbt){
World world = loc.getWorld(); 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); CustomSkeleton zmb = new CustomSkeleton(mcWorld,loc,mbt);
mcWorld.addEntity(zmb); mcWorld.addEntity(zmb);
mobList.put(new Integer(zmb.getBukkitEntity().getEntityId()),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.BlockIgniteEvent;
import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockPlaceEvent; import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.util.Vector;
import org.jakub1221.herobrineai.AI.*; import org.jakub1221.herobrineai.AI.*;
import org.jakub1221.herobrineai.AI.Core.CoreType; import org.jakub1221.herobrineai.AI.Core.CoreType;
import org.jakub1221.herobrineai.AI.cores.Heads; import org.jakub1221.herobrineai.AI.cores.Heads;
import org.jakub1221.herobrineai.HerobrineAI; import org.jakub1221.herobrineai.HerobrineAI;
public class BlockListener implements Listener{ public class BlockListener implements Listener {
Logger log = Logger.getLogger("Minecraft"); Logger log = Logger.getLogger("Minecraft");
@EventHandler @EventHandler
public void onBlockIgnite(BlockIgniteEvent event){ public void onBlockIgnite(BlockIgniteEvent event) {
if (event.getBlock()!=null){ if (event.getBlock() != null) {
Block blockt = (Block) event.getBlock(); Block blockt = (Block) event.getBlock();
Location blockloc = (Location) blockt.getLocation(); Location blockloc = (Location) blockt.getLocation();
if (event.getPlayer()!=null){ if (event.getPlayer() != null) {
blockloc.setY(blockloc.getY()-1); blockloc.setY(blockloc.getY() - 1);
Block block = (Block) blockloc.getWorld().getBlockAt(blockloc); Block block = (Block) blockloc.getWorld().getBlockAt(blockloc);
if (block.getType() == Material.NETHERRACK){ if (block.getType() == Material.NETHERRACK) {
if (block.getWorld().getBlockAt(blockloc.getBlockX(), blockloc.getBlockY()-1, blockloc.getBlockZ()).getType() == Material.NETHERRACK){ Object[][] checkList = {
if (block.getWorld().getBlockAt(blockloc.getBlockX()-1, blockloc.getBlockY()-1, blockloc.getBlockZ()).getType() == Material.GOLD_BLOCK){ { new Vector(0, -1, 0), Material.NETHERRACK },
if (block.getWorld().getBlockAt(blockloc.getBlockX()-1, blockloc.getBlockY()-1, blockloc.getBlockZ()-1).getType() == Material.GOLD_BLOCK){ { new Vector(-1, -1, 0), Material.GOLD_BLOCK },
if (block.getWorld().getBlockAt(blockloc.getBlockX()-1, blockloc.getBlockY()-1, blockloc.getBlockZ()+1).getType() == Material.GOLD_BLOCK){ { new Vector(-1, -1, -1), Material.GOLD_BLOCK },
if (block.getWorld().getBlockAt(blockloc.getBlockX()+1, blockloc.getBlockY()-1, blockloc.getBlockZ()).getType() == Material.GOLD_BLOCK){ { new Vector(-1, -1, 1), Material.GOLD_BLOCK },
if (block.getWorld().getBlockAt(blockloc.getBlockX()+1, blockloc.getBlockY()-1, blockloc.getBlockZ()-1).getType() == Material.GOLD_BLOCK){ { new Vector(1, -1, 0), Material.GOLD_BLOCK },
if (block.getWorld().getBlockAt(blockloc.getBlockX()+1, blockloc.getBlockY()-1, blockloc.getBlockZ()+1).getType() == Material.GOLD_BLOCK){ { new Vector(1, -1, -1), Material.GOLD_BLOCK },
if (block.getWorld().getBlockAt(blockloc.getBlockX(), blockloc.getBlockY()-1, blockloc.getBlockZ()-1).getType() == Material.GOLD_BLOCK){ { new Vector(1, -1, 1), Material.GOLD_BLOCK },
if (block.getWorld().getBlockAt(blockloc.getBlockX(), blockloc.getBlockY()-1, blockloc.getBlockZ()+1).getType() == Material.GOLD_BLOCK){ { new Vector(0, -1, -1), Material.GOLD_BLOCK },
if (block.getWorld().getBlockAt(blockloc.getBlockX(), blockloc.getBlockY(), blockloc.getBlockZ()+1).getType() == Material.REDSTONE_TORCH_ON){ { new Vector(0, -1, +1), Material.GOLD_BLOCK },
if (block.getWorld().getBlockAt(blockloc.getBlockX(), blockloc.getBlockY(), blockloc.getBlockZ()-1).getType() == Material.REDSTONE_TORCH_ON){ { new Vector(0, 0, 1), Material.REDSTONE_TORCH_ON },
if (block.getWorld().getBlockAt(blockloc.getBlockX()+1, blockloc.getBlockY(), blockloc.getBlockZ()).getType() == Material.REDSTONE_TORCH_ON){ { new Vector(0, 0, -1), Material.REDSTONE_TORCH_ON },
if (block.getWorld().getBlockAt(blockloc.getBlockX()-1, blockloc.getBlockY(), blockloc.getBlockZ()).getType() == Material.REDSTONE_TORCH_ON){ { new Vector(1, 0, 0), Material.REDSTONE_TORCH_ON },
{ new Vector(-1, 0, 0), Material.REDSTONE_TORCH_ON }
};
if (HerobrineAI.getPluginCore().getConfigDB().UseTotem==true && AICore.isTotemCalled==false){ 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()); HerobrineAI.getPluginCore().getAICore().PlayerCallTotem(event.getPlayer());
} }
}
}
}
}
}
}
}
}
}
}
}
}
}
} }
} }
} }
if (event.getBlock().getWorld()==Bukkit.getServer().getWorld("world_herobrineai_graveyard")){ if (event.getBlock().getWorld() == Bukkit.getServer().getWorld("world_herobrineai_graveyard")) {
event.setCancelled(true); event.setCancelled(true);
return; return;
} }
} }
@EventHandler @EventHandler
public void onBlockBreak(BlockBreakEvent event){ public void onBlockBreak(BlockBreakEvent event) {
if (event.getBlock().getWorld()==Bukkit.getServer().getWorld("world_herobrineai_graveyard")){ if (event.getBlock().getWorld() == Bukkit.getServer().getWorld("world_herobrineai_graveyard")) {
event.setCancelled(true); event.setCancelled(true);
return; return;
}else{ } else {
Heads h = (Heads) HerobrineAI.getPluginCore().getAICore().getCore(CoreType.HEADS); Heads h = (Heads) HerobrineAI.getPluginCore().getAICore().getCore(CoreType.HEADS);
ArrayList<Block> list = h.getHeadList(); ArrayList<Block> list = h.getHeadList();
if (list.contains(event.getBlock())){ if (list.contains(event.getBlock())) {
event.setCancelled(true); event.setCancelled(true);
return; return;
} }
} }
} }
@EventHandler @EventHandler
public void onBlockPlace(BlockPlaceEvent event){ 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); event.setCancelled(true);
return; return;
} }
} }
} }

View File

@ -7,8 +7,8 @@ import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.entity.Arrow; import org.bukkit.entity.Arrow;
import org.bukkit.entity.CreatureType;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.entity.Projectile; import org.bukkit.entity.Projectile;
@ -25,56 +25,61 @@ import org.bukkit.event.entity.EntityDeathEvent;
import org.bukkit.event.entity.ProjectileHitEvent; import org.bukkit.event.entity.ProjectileHitEvent;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.jakub1221.herobrineai.HerobrineAI; import org.jakub1221.herobrineai.HerobrineAI;
import org.jakub1221.herobrineai.Utils;
import org.jakub1221.herobrineai.AI.*; import org.jakub1221.herobrineai.AI.*;
import org.jakub1221.herobrineai.AI.Core.CoreType; import org.jakub1221.herobrineai.AI.Core.CoreType;
import org.jakub1221.herobrineai.entity.MobType; import org.jakub1221.herobrineai.entity.MobType;
import org.jakub1221.herobrineai.misc.ItemName; import org.jakub1221.herobrineai.misc.ItemName;
import org.bukkit.event.entity.EntityTargetLivingEntityEvent; import org.bukkit.event.entity.EntityTargetLivingEntityEvent;
public class EntityListener implements Listener{ public class EntityListener implements Listener {
private ItemStack itemInHand=null; private ItemStack itemInHand = null;
private ArrayList<String> equalsLore = new ArrayList<String>(); private ArrayList<String> equalsLore = new ArrayList<String>();
private ArrayList<String> equalsLoreS = new ArrayList<String>(); private ArrayList<String> equalsLoreS = new ArrayList<String>();
private ArrayList<String> getLore = new ArrayList<String>(); private ArrayList<String> getLore = new ArrayList<String>();
public EntityListener(){ public EntityListener() {
equalsLore.add("Herobrine´s artifact"); equalsLore.add("Herobrine artifact");
equalsLore.add("Bow of Teleporting"); equalsLore.add("Bow of Teleporting");
equalsLoreS.add("Herobrine´s artifact"); equalsLoreS.add("Herobrine artifact");
equalsLoreS.add("Sword of Lighting"); equalsLoreS.add("Sword of Lighting");
} }
@SuppressWarnings("deprecation")
@EventHandler @EventHandler
public void onCreatureSpawn(CreatureSpawnEvent event){ public void onCreatureSpawn(CreatureSpawnEvent event) {
if (!HerobrineAI.isNPCDisabled) {
if (HerobrineAI.getPluginCore().getConfigDB().useWorlds.contains(event.getEntity().getLocation().getWorld().getName())) {
Entity entity = event.getEntity(); Entity entity = event.getEntity();
CreatureType creatureType = event.getCreatureType(); EntityType creatureType = event.getEntityType();
if (event.isCancelled()) return;
if (creatureType == CreatureType.ZOMBIE){ if (event.isCancelled())
if (HerobrineAI.getPluginCore().getConfigDB().UseNPC_Warrior){ return;
if (new Random().nextInt(100)<HerobrineAI.getPluginCore().getConfigDB().npc.getInt("npc.Warrior.SpawnChance")){
if (HerobrineAI.getPluginCore().getEntityManager().isCustomMob(entity.getEntityId())==false){ 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; LivingEntity ent = (LivingEntity) entity;
ent.setHealth(0); ent.setHealth(0);
HerobrineAI.getPluginCore().getEntityManager().spawnCustomZombie(event.getLocation(),MobType.HEROBRINE_WARRIOR); HerobrineAI.getPluginCore().getEntityManager().spawnCustomZombie(event.getLocation(), MobType.HEROBRINE_WARRIOR);
return; return;
} }
} }
} }
}else if (creatureType == CreatureType.SKELETON){ } else if (creatureType == EntityType.SKELETON) {
if (HerobrineAI.getPluginCore().getConfigDB().UseNPC_Demon){ if (HerobrineAI.getPluginCore().getConfigDB().UseNPC_Demon) {
if (new Random().nextInt(100)<HerobrineAI.getPluginCore().getConfigDB().npc.getInt("npc.Demon.SpawnChance")){ if (Utils.getRandomGen().nextInt(100) < HerobrineAI.getPluginCore().getConfigDB().npc.getInt("npc.Demon.SpawnChance")) {
if (HerobrineAI.getPluginCore().getEntityManager().isCustomMob(entity.getEntityId())==false){ if (HerobrineAI.getPluginCore().getEntityManager().isCustomMob(entity.getEntityId()) == false) {
LivingEntity ent = (LivingEntity) entity; LivingEntity ent = (LivingEntity) entity;
ent.setHealth(0); ent.setHealth(0);
HerobrineAI.getPluginCore().getEntityManager().spawnCustomSkeleton(event.getLocation(),MobType.DEMON); HerobrineAI.getPluginCore().getEntityManager().spawnCustomSkeleton(event.getLocation(), MobType.DEMON);
return; return;
} }
@ -82,44 +87,51 @@ public class EntityListener implements Listener{
} }
} }
} }
}
}
@EventHandler @EventHandler
public void onEntityDeathEvent(EntityDeathEvent event){ public void onEntityDeathEvent(EntityDeathEvent event) {
if (HerobrineAI.getPluginCore().getEntityManager().isCustomMob(event.getEntity().getEntityId())){ if (HerobrineAI.getPluginCore().getEntityManager().isCustomMob(event.getEntity().getEntityId())) {
HerobrineAI.getPluginCore().getEntityManager().removeMob(event.getEntity().getEntityId()); HerobrineAI.getPluginCore().getEntityManager().removeMob(event.getEntity().getEntityId());
} }
} }
@EventHandler @EventHandler
public void EntityTargetEvent(EntityTargetLivingEntityEvent e){ public void EntityTargetEvent(EntityTargetLivingEntityEvent e) {
LivingEntity lv = e.getTarget(); LivingEntity lv = e.getTarget();
if (lv.getEntityId()==HerobrineAI.HerobrineEntityID){ if (lv.getEntityId() == HerobrineAI.HerobrineEntityID) {
e.setCancelled(true); e.setCancelled(true);
return; return;
} }
} }
@EventHandler @EventHandler
public void onProjectileHit(ProjectileHitEvent event){ public void onProjectileHit(ProjectileHitEvent event) {
if (event.getEntity() instanceof Arrow){ if (event.getEntity() instanceof Arrow) {
Arrow arrow = (Arrow) event.getEntity(); Arrow arrow = (Arrow) event.getEntity();
if (arrow.getShooter() instanceof Player){ if (arrow.getShooter() instanceof Player) {
Player player = (Player) arrow.getShooter(); Player player = (Player) arrow.getShooter();
if (player.getItemInHand() != null){ if (player.getItemInHand() != null) {
itemInHand = player.getItemInHand(); itemInHand = player.getItemInHand();
if (itemInHand.getType()!=null){ if (itemInHand.getType() != null) {
if (itemInHand.getType() == Material.BOW){
getLore=ItemName.getLore(itemInHand); if (itemInHand.getType() == Material.BOW) {
if (getLore!=null){ getLore = ItemName.getLore(itemInHand);
if (getLore.containsAll(equalsLore)){ if (getLore != null) {
if (HerobrineAI.getPluginCore().getConfigDB().UseArtifactBow){
if (getLore.containsAll(equalsLore)) {
if (HerobrineAI.getPluginCore().getConfigDB().UseArtifactBow) {
player.teleport(arrow.getLocation()); player.teleport(arrow.getLocation());
} }
} }
} }
} }
} }
} }
} }
@ -127,9 +139,9 @@ public class EntityListener implements Listener{
} }
@EventHandler @EventHandler
public void onEntityDamageByBlock(EntityDamageByBlockEvent event){ public void onEntityDamageByBlock(EntityDamageByBlockEvent event) {
if (event.getEntity().getEntityId() == HerobrineAI.HerobrineEntityID){ if (event.getEntity().getEntityId() == HerobrineAI.HerobrineEntityID) {
event.setCancelled(true); event.setCancelled(true);
event.setDamage(0); event.setDamage(0);
return; return;
@ -137,75 +149,65 @@ public class EntityListener implements Listener{
} }
@SuppressWarnings("static-access")
@EventHandler @EventHandler
public void onEntityDamage(EntityDamageEvent event){ public void onEntityDamage(EntityDamageEvent event) {
if (event.getEntity().getEntityId() == HerobrineAI.HerobrineEntityID){ if (event.getEntity().getEntityId() == HerobrineAI.HerobrineEntityID) {
if (event instanceof EntityDamageByEntityEvent){ if (event instanceof EntityDamageByEntityEvent) {
EntityDamageByEntityEvent dEvent = (EntityDamageByEntityEvent) event; EntityDamageByEntityEvent dEvent = (EntityDamageByEntityEvent) event;
if (HerobrineAI.getPluginCore().getConfigDB().Killable==true && HerobrineAI.getPluginCore().getAICore().getCoreTypeNow()!=CoreType.GRAVEYARD){ if (HerobrineAI.getPluginCore().getConfigDB().Killable == true
if (dEvent.getDamager() instanceof Player){ && HerobrineAI.getPluginCore().getAICore().getCoreTypeNow() != CoreType.GRAVEYARD) {
if (event.getDamage()>=HerobrineAI.HerobrineHP){
if (dEvent.getDamager() instanceof Player) {
if (event.getDamage() >= HerobrineAI.HerobrineHP) {
int i=1; HerobrineDropItems();
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.getPluginCore().getAICore().CancelTarget(CoreType.ANY);
HerobrineAI.HerobrineHP=HerobrineAI.HerobrineMaxHP; HerobrineAI.HerobrineHP = HerobrineAI.HerobrineMaxHP;
Player player = (Player) dEvent.getDamager(); Player player = (Player) dEvent.getDamager();
player.sendMessage("<Herobrine> "+HerobrineAI.getPluginCore().getConfigDB().DeathMessage); player.sendMessage("<Herobrine> " + HerobrineAI.getPluginCore().getConfigDB().DeathMessage);
}else{HerobrineAI.HerobrineHP-=event.getDamage();HerobrineAI.HerobrineNPC.HurtAnimation();AICore.log.info("HIT: "+event.getDamage());} } else {
}else if(dEvent.getDamager() instanceof Projectile){ HerobrineAI.HerobrineHP -= event.getDamage();
HerobrineAI.HerobrineNPC.HurtAnimation();
AICore.log.info("HIT: " + event.getDamage());
}
} else if (dEvent.getDamager() instanceof Projectile) {
Arrow arrow = (Arrow) dEvent.getDamager(); Arrow arrow = (Arrow) dEvent.getDamager();
if (arrow.getShooter() instanceof Player){ if (arrow.getShooter() instanceof Player) {
if (HerobrineAI.getPluginCore().getAICore().getCoreTypeNow() == CoreType.RANDOM_POSITION){ if (HerobrineAI.getPluginCore().getAICore().getCoreTypeNow() == CoreType.RANDOM_POSITION) {
HerobrineAI.getPluginCore().getAICore().CancelTarget(CoreType.ANY); HerobrineAI.getPluginCore().getAICore().CancelTarget(CoreType.ANY);
HerobrineAI.getPluginCore().getAICore().setAttackTarget((Player) arrow.getShooter()); HerobrineAI.getPluginCore().getAICore().setAttackTarget((Player) arrow.getShooter());
}else{ } else {
if (event.getDamage()>=HerobrineAI.HerobrineHP){ if (event.getDamage() >= HerobrineAI.HerobrineHP) {
HerobrineDropItems();
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.getPluginCore().getAICore().CancelTarget(CoreType.ANY);
HerobrineAI.HerobrineHP=HerobrineAI.HerobrineMaxHP; HerobrineAI.HerobrineHP = HerobrineAI.HerobrineMaxHP;
Player player = (Player) arrow.getShooter(); Player player = (Player) arrow.getShooter();
player.sendMessage("<Herobrine> "+HerobrineAI.getPluginCore().getConfigDB().DeathMessage); player.sendMessage("<Herobrine> " + HerobrineAI.getPluginCore().getConfigDB().DeathMessage);
}else{HerobrineAI.HerobrineHP-=event.getDamage();HerobrineAI.HerobrineNPC.HurtAnimation();AICore.log.info("HIT: "+event.getDamage());}
} else {
HerobrineAI.HerobrineHP -= event.getDamage();
HerobrineAI.HerobrineNPC.HurtAnimation();
AICore.log.info("HIT: " + event.getDamage());
}
} }
}else{if (HerobrineAI.getPluginCore().getAICore().getCoreTypeNow() == CoreType.RANDOM_POSITION){ } else {
if (HerobrineAI.getPluginCore().getAICore().getCoreTypeNow() == CoreType.RANDOM_POSITION) {
Location newloc = (Location) HerobrineAI.HerobrineNPC.getBukkitEntity().getLocation(); Location newloc = (Location) HerobrineAI.HerobrineNPC.getBukkitEntity().getLocation();
newloc.setY(-20); newloc.setY(-20);
HerobrineAI.HerobrineNPC.moveTo(newloc); HerobrineAI.HerobrineNPC.moveTo(newloc);
HerobrineAI.getPluginCore().getAICore().CancelTarget(CoreType.ANY); HerobrineAI.getPluginCore().getAICore().CancelTarget(CoreType.ANY);
}} }
}else{ }
if (HerobrineAI.getPluginCore().getAICore().getCoreTypeNow() == CoreType.RANDOM_POSITION){ } else {
if (HerobrineAI.getPluginCore().getAICore().getCoreTypeNow() == CoreType.RANDOM_POSITION) {
Location newloc = (Location) HerobrineAI.HerobrineNPC.getBukkitEntity().getLocation(); Location newloc = (Location) HerobrineAI.HerobrineNPC.getBukkitEntity().getLocation();
newloc.setY(-20); newloc.setY(-20);
HerobrineAI.HerobrineNPC.moveTo(newloc); HerobrineAI.HerobrineNPC.moveTo(newloc);
@ -216,25 +218,23 @@ public class EntityListener implements Listener{
} }
event.setCancelled(true); event.setCancelled(true);
event.setDamage(0); event.setDamage(0);
return; return;
} else {
}else{ if (event instanceof EntityDamageByEntityEvent) {
if (event instanceof EntityDamageByEntityEvent){
EntityDamageByEntityEvent dEvent = (EntityDamageByEntityEvent) event; EntityDamageByEntityEvent dEvent = (EntityDamageByEntityEvent) event;
if (dEvent.getDamager() instanceof Player){ if (dEvent.getDamager() instanceof Player) {
Player player = (Player) dEvent.getDamager(); Player player = (Player) dEvent.getDamager();
if (player.getItemInHand() != null){ if (player.getItemInHand() != null) {
if (player.getItemInHand().getType() == Material.DIAMOND_SWORD){ if (player.getItemInHand().getType() == Material.DIAMOND_SWORD) {
if (ItemName.getLore(player.getItemInHand())!=null){ if (ItemName.getLore(player.getItemInHand()) != null) {
itemInHand = player.getItemInHand(); itemInHand = player.getItemInHand();
getLore=ItemName.getLore(itemInHand); getLore = ItemName.getLore(itemInHand);
if (getLore.containsAll(equalsLoreS)){ if (getLore.containsAll(equalsLoreS)) {
if (HerobrineAI.getPluginCore().getConfigDB().UseArtifactSword){ if (HerobrineAI.getPluginCore().getConfigDB().UseArtifactSword) {
if (new Random().nextBoolean()){ if (Utils.getRandomGen().nextBoolean()) {
player.getLocation().getWorld().strikeLightning(event.getEntity().getLocation()); player.getLocation().getWorld().strikeLightning(event.getEntity().getLocation());
} }
} }
@ -242,34 +242,34 @@ public class EntityListener implements Listener{
} }
} }
} }
}else if (dEvent.getDamager() instanceof Zombie){ } else if (dEvent.getDamager() instanceof Zombie) {
Zombie zmb = (Zombie) dEvent.getDamager(); Zombie zmb = (Zombie) dEvent.getDamager();
if (zmb.getCustomName()=="Artifact Guardian" || zmb.getCustomName()=="Herobrine´s Warrior"){ if (zmb.getCustomName() == "Artifact Guardian" || zmb.getCustomName() == "Herobrine<EFBFBD>s Warrior") {
dEvent.setDamage(dEvent.getDamage()*3); dEvent.setDamage(dEvent.getDamage() * 3);
} }
}else if (dEvent.getDamager() instanceof Skeleton){ } else if (dEvent.getDamager() instanceof Skeleton) {
Skeleton zmb = (Skeleton) dEvent.getDamager(); Skeleton zmb = (Skeleton) dEvent.getDamager();
if (zmb.getCustomName()=="Demon"){ if (zmb.getCustomName() == "Demon") {
dEvent.setDamage(dEvent.getDamage()*3); dEvent.setDamage(dEvent.getDamage() * 3);
} }
} }
} }
if (event.getCause()!=null){ if (event.getCause() != null) {
if (event.getCause() == DamageCause.LIGHTNING){ if (event.getCause() == DamageCause.LIGHTNING) {
if (event.getEntity() instanceof Player){ if (event.getEntity() instanceof Player) {
if (event.getEntity().getEntityId()!=HerobrineAI.HerobrineEntityID){ if (event.getEntity().getEntityId() != HerobrineAI.HerobrineEntityID) {
Player player = (Player) event.getEntity(); Player player = (Player) event.getEntity();
if (player.getItemInHand() != null){ if (player.getItemInHand() != null) {
if (player.getItemInHand().getType() == Material.DIAMOND_SWORD){ if (player.getItemInHand().getType() == Material.DIAMOND_SWORD) {
if (ItemName.getLore(player.getItemInHand())!=null){ if (ItemName.getLore(player.getItemInHand()) != null) {
itemInHand = player.getItemInHand(); itemInHand = player.getItemInHand();
getLore=ItemName.getLore(itemInHand); getLore = ItemName.getLore(itemInHand);
if (getLore.containsAll(equalsLoreS)){ if (getLore.containsAll(equalsLoreS)) {
if (HerobrineAI.getPluginCore().getConfigDB().UseArtifactSword){ if (HerobrineAI.getPluginCore().getConfigDB().UseArtifactSword) {
event.setDamage(0); event.setDamage(0);
event.setCancelled(true); event.setCancelled(true);
return; return;
@ -287,4 +287,28 @@ public class EntityListener implements Listener{
} }
} }
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,22 +12,26 @@ import org.jakub1221.herobrineai.AI.Core.CoreType;
import org.jakub1221.herobrineai.HerobrineAI; import org.jakub1221.herobrineai.HerobrineAI;
import org.jakub1221.herobrineai.misc.ItemName; import org.jakub1221.herobrineai.misc.ItemName;
public class InventoryListener implements Listener{ public class InventoryListener implements Listener {
Logger log = Logger.getLogger("Minecraft"); Logger log = Logger.getLogger("Minecraft");
@EventHandler @EventHandler
public void onInventoryClose(InventoryCloseEvent event){ public void onInventoryClose(InventoryCloseEvent event) {
if (event.getInventory().getType() == InventoryType.CHEST){ if (event.getInventory().getType() == InventoryType.CHEST) {
Object[] data = {event.getPlayer(),event.getInventory()}; Object[] data = { event.getPlayer(), event.getInventory() };
HerobrineAI.getPluginCore().getAICore().getCore(CoreType.BOOK).RunCore(data); HerobrineAI.getPluginCore().getAICore().getCore(CoreType.BOOK).RunCore(data);
if (new Random().nextInt(100)>97){ if (new Random().nextInt(100) > 97) {
if (HerobrineAI.getPluginCore().getConfigDB().UseHeads){
if (event.getInventory().firstEmpty()!=-1){ if (HerobrineAI.getPluginCore().getConfigDB().UseHeads) {
event.getInventory().setItem(event.getInventory().firstEmpty(),ItemName.CreateSkull(event.getPlayer().getName())); if (event.getInventory().firstEmpty() != -1) {
if (HerobrineAI.getPluginCore().getAICore().getResetLimits().isHead()) {
event.getInventory().setItem(event.getInventory().firstEmpty(),
ItemName.CreateSkull(event.getPlayer().getName()));
}
} }
} }
} }
@ -35,20 +39,25 @@ public class InventoryListener implements Listener{
} }
@EventHandler @EventHandler
public void onInventoryOpen(InventoryOpenEvent event){ 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().useWorlds.contains(event.getPlayer().getLocation().getWorld().getName())){
if (HerobrineAI.getPluginCore().getConfigDB().PlaceSigns==true && HerobrineAI.getPluginCore().getSupport().checkSigns(event.getPlayer().getLocation())){ if (HerobrineAI.getPluginCore().getConfigDB().PlaceSigns == true
Object[] data = {event.getPlayer().getLocation(),event.getPlayer().getLocation()}; && 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); HerobrineAI.getPluginCore().getAICore().getCore(CoreType.SIGNS).RunCore(data);
} }
} }
} }
}
} }
} }

View File

@ -1,7 +1,6 @@
package org.jakub1221.herobrineai.listeners; package org.jakub1221.herobrineai.listeners;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Random;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
@ -9,7 +8,7 @@ import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.block.Jukebox; 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.LivingEntity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
@ -25,75 +24,100 @@ import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.event.player.PlayerTeleportEvent; import org.bukkit.event.player.PlayerTeleportEvent;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.jakub1221.herobrineai.HerobrineAI; import org.jakub1221.herobrineai.HerobrineAI;
import org.jakub1221.herobrineai.Utils;
import org.jakub1221.herobrineai.AI.AICore; import org.jakub1221.herobrineai.AI.AICore;
import org.jakub1221.herobrineai.AI.Core.CoreType; import org.jakub1221.herobrineai.AI.Core.CoreType;
import org.jakub1221.herobrineai.misc.ItemName; import org.jakub1221.herobrineai.misc.ItemName;
public class PlayerListener implements Listener{ public class PlayerListener implements Listener {
private ItemStack itemInHand=null;
private ArrayList<String> equalsLoreS = new ArrayList<String>(); private ArrayList<String> equalsLoreS = new ArrayList<String>();
private ArrayList<String> equalsLoreA = 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 ArrayList<LivingEntity> LivingEntities = new ArrayList<LivingEntity>();
private Location le_loc = null; private Location le_loc = null;
private Location p_loc = null; private Location p_loc = null;
private long timestamp = 0; private long timestamp = 0;
private boolean canUse = false; private boolean canUse = false;
public PlayerListener(){ public PlayerListener() {
equalsLoreS.add("Herobrine´s artifact"); equalsLoreS.add("Herobrine artifact");
equalsLoreS.add("Sword of Lighting"); equalsLoreS.add("Sword of Lighting");
equalsLoreA.add("Herobrine´s artifact"); equalsLoreA.add("Herobrine artifact");
equalsLoreA.add("Apple of Death"); equalsLoreA.add("Apple of Death");
} }
@EventHandler @EventHandler
public void onPlayerInteract(PlayerInteractEvent event){ 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){ 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(); ItemStack itemInHand = event.getPlayer().getItemInHand();
if (event.getPlayer().getItemInHand().getType()!=null){ if (event.getPlayer().getItemInHand().getType() != null) {
if (itemInHand.getType() == Material.DIAMOND_SWORD || itemInHand.getType() == Material.GOLDEN_APPLE){
if (ItemName.getLore(itemInHand)!=null){ if (itemInHand.getType() == Material.DIAMOND_SWORD
if (ItemName.getLore(itemInHand).containsAll(equalsLoreS) && HerobrineAI.getPluginCore().getConfigDB().UseArtifactSword){ || itemInHand.getType() == Material.GOLDEN_APPLE) {
if (new Random().nextBoolean()){
event.getPlayer().getLocation().getWorld().strikeLightning(event.getClickedBlock().getLocation()); 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){
} else if (ItemName.getLore(itemInHand).containsAll(equalsLoreA)
&& HerobrineAI.getPluginCore().getConfigDB().UseArtifactApple) {
timestamp = System.currentTimeMillis() / 1000; timestamp = System.currentTimeMillis() / 1000;
canUse=false; canUse = false;
if (HerobrineAI.getPluginCore().PlayerApple.containsKey(event.getPlayer())){
if (HerobrineAI.getPluginCore().PlayerApple.get(event.getPlayer()) < timestamp){ if (HerobrineAI.getPluginCore().PlayerApple.containsKey(event.getPlayer())) {
if (HerobrineAI.getPluginCore().PlayerApple.get(event.getPlayer()) < timestamp) {
HerobrineAI.getPluginCore().PlayerApple.remove(event.getPlayer()); HerobrineAI.getPluginCore().PlayerApple.remove(event.getPlayer());
canUse=true; canUse = true;
}else{canUse=false;} } else {
}else{canUse=true;} canUse = false;
}
} else {
canUse = true;
}
if (canUse == true) {
if (canUse==true){
event.getPlayer().getWorld().createExplosion(event.getPlayer().getLocation(), 0F); event.getPlayer().getWorld().createExplosion(event.getPlayer().getLocation(), 0F);
LivingEntities = (ArrayList<LivingEntity>) event.getPlayer().getLocation().getWorld().getLivingEntities(); LivingEntities = (ArrayList<LivingEntity>) event.getPlayer().getLocation()
HerobrineAI.getPluginCore().PlayerApple.put(event.getPlayer(), timestamp+60); .getWorld().getLivingEntities();
for (int i=0;i<=LivingEntities.size()-1;i++){ 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) {
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); event.getPlayer().getWorld().createExplosion(LivingEntities.get(i).getLocation(), 0F);
LivingEntities.get(i).damage(10000); LivingEntities.get(i).damage(10000);
} }
} }
} }
} }
} }
} else {
}else{ event.getPlayer().sendMessage(ChatColor.RED + "Apple of Death is recharging!");
event.getPlayer().sendMessage(ChatColor.RED+"Apple of Death is recharging!");
} }
} }
} }
@ -102,21 +126,27 @@ public class PlayerListener implements Listener{
} }
} }
if (event.getClickedBlock() != null) {
if (event.getPlayer().getItemInHand() != null) {
if (event.getClickedBlock().getType() == Material.JUKEBOX) {
if (event.getClickedBlock()!=null){
if (event.getPlayer().getItemInHand()!=null){
if (event.getClickedBlock().getType()==Material.JUKEBOX){
ItemStack item = event.getPlayer().getItemInHand(); ItemStack item = event.getPlayer().getItemInHand();
Jukebox block = (Jukebox) event.getClickedBlock().getState(); Jukebox block = (Jukebox) event.getClickedBlock().getState();
if (!block.isPlaying()){
if (item.getType()==Material.getMaterial(2266)){ if (!block.isPlaying()) {
if (item.getType() == Material.getMaterial(2266)) {
HerobrineAI.getPluginCore().getAICore(); HerobrineAI.getPluginCore().getAICore();
if (!AICore.isDiscCalled){
if (!AICore.isDiscCalled) {
final Player player = event.getPlayer(); final Player player = event.getPlayer();
HerobrineAI.getPluginCore().getAICore(); HerobrineAI.getPluginCore().getAICore();
AICore.isDiscCalled=true; AICore.isDiscCalled = true;
HerobrineAI.getPluginCore().getAICore().CancelTarget(CoreType.ANY); HerobrineAI.getPluginCore().getAICore().CancelTarget(CoreType.ANY);
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(AICore.plugin, new Runnable() {
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(AICore.plugin,
new Runnable() {
public void run() { public void run() {
HerobrineAI.getPluginCore().getAICore().callByDisc(player); HerobrineAI.getPluginCore().getAICore().callByDisc(player);
} }
@ -131,8 +161,8 @@ public class PlayerListener implements Listener{
} }
@EventHandler @EventHandler
public void onPlayerEnterBed(PlayerBedEnterEvent event){ public void onPlayerEnterBed(PlayerBedEnterEvent event) {
if (new Random().nextInt(100)>75){ if (Utils.getRandomGen().nextInt(100) > 75) {
Player player = event.getPlayer(); Player player = event.getPlayer();
((CraftPlayer) player).getHandle().a(true, false, false); ((CraftPlayer) player).getHandle().a(true, false, false);
HerobrineAI.getPluginCore().getAICore().playerBedEnter(player); HerobrineAI.getPluginCore().getAICore().playerBedEnter(player);
@ -140,76 +170,84 @@ public class PlayerListener implements Listener{
} }
@EventHandler(priority = EventPriority.HIGHEST) @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());
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) @EventHandler(priority = EventPriority.HIGHEST)
public void onPlayerKick(PlayerKickEvent event){ public void onPlayerKick(PlayerKickEvent event) {
if (event.getPlayer().getEntityId()==HerobrineAI.HerobrineEntityID){ if (event.getPlayer().getEntityId() == HerobrineAI.HerobrineEntityID) {
event.setCancelled(true); event.setCancelled(true);
return; return;
} }
} }
@EventHandler(priority = EventPriority.HIGHEST) @EventHandler(priority = EventPriority.HIGHEST)
public void onPlayerTeleport(PlayerTeleportEvent event){ public void onPlayerTeleport(PlayerTeleportEvent event) {
if(event.getPlayer().getEntityId()==HerobrineAI.HerobrineEntityID){
if (event.getFrom().getWorld()!=event.getTo().getWorld()){ if (event.getPlayer().getEntityId() == HerobrineAI.HerobrineEntityID) {
if (event.getFrom().getWorld() != event.getTo().getWorld()) {
HerobrineAI.getPluginCore().HerobrineRemove(); HerobrineAI.getPluginCore().HerobrineRemove();
HerobrineAI.getPluginCore().HerobrineSpawn(event.getTo()); HerobrineAI.getPluginCore().HerobrineSpawn(event.getTo());
event.setCancelled(true); event.setCancelled(true);
return; return;
} }
if (HerobrineAI.getPluginCore().getAICore().getCoreTypeNow() == CoreType.RANDOM_POSITION){ 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)){ Location herobrineLocation = HerobrineAI.HerobrineNPC.getEntity().getBukkitEntity().getLocation();
if (HerobrineAI.HerobrineNPC.getEntity().getBukkitEntity().getLocation().getBlockZ() > HerobrineAI.getPluginCore().getConfigDB().WalkingModeZRadius){
if (HerobrineAI.HerobrineNPC.getEntity().getBukkitEntity().getLocation().getBlockZ() < (-HerobrineAI.getPluginCore().getConfigDB().WalkingModeZRadius)){ 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.getPluginCore().getAICore().CancelTarget(CoreType.RANDOM_POSITION);
HerobrineAI.HerobrineNPC.moveTo(new Location(Bukkit.getServer().getWorlds().get(0),0,-20,0)); HerobrineAI.HerobrineNPC.moveTo(new Location(Bukkit.getServer().getWorlds().get(0), 0, -20, 0));
}
}
}
} }
} }
} }
} }
@EventHandler @EventHandler
public void onPlayerDeathEvent(PlayerDeathEvent event){ public void onPlayerDeathEvent(PlayerDeathEvent event) {
if (event.getEntity().getEntityId() == HerobrineAI.HerobrineEntityID){ if (event.getEntity().getEntityId() == HerobrineAI.HerobrineEntityID) {
event.setDeathMessage(""); event.setDeathMessage("");
HerobrineAI.getPluginCore().HerobrineRemove(); HerobrineAI.getPluginCore().HerobrineRemove();
Location nowloc = new Location((World) Bukkit.getServer().getWorlds().get(0),(float) 0,(float) -20,(float) 0); Location nowloc = new Location((World) Bukkit.getServer().getWorlds().get(0), 0, -20.f, 0);
nowloc.setYaw((float) 1); nowloc.setYaw(1.f);
nowloc.setPitch((float) 1); nowloc.setPitch(1.f);
HerobrineAI.getPluginCore().HerobrineSpawn(nowloc); HerobrineAI.getPluginCore().HerobrineSpawn(nowloc);
} }
} }
@EventHandler @EventHandler
public void onPlayerMoveEvent(PlayerMoveEvent event){ public void onPlayerMoveEvent(PlayerMoveEvent event) {
if (event.getPlayer().getEntityId()!=HerobrineAI.HerobrineEntityID){ if (event.getPlayer().getEntityId() != HerobrineAI.HerobrineEntityID) {
if (event.getPlayer().getWorld()==Bukkit.getServer().getWorld("world_herobrineai_graveyard")){ if (event.getPlayer().getWorld() == Bukkit.getServer().getWorld("world_herobrineai_graveyard")) {
Player player = (Player) event.getPlayer(); 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)); 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 (HerobrineAI.getPluginCore().getConfigDB().BuildPyramids==true){
if (new Random().nextInt(15)==1){ if (new Random().nextInt(30)==4){
Object[] data = {event.getChunk()}; Object[] data = {event.getChunk()};
HerobrineAI.getPluginCore().getAICore().getCore(CoreType.PYRAMID).RunCore(data); HerobrineAI.getPluginCore().getAICore().getCore(CoreType.PYRAMID).RunCore(data);
} }

View File

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

View File

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

View File

@ -1,6 +1,5 @@
package org.jakub1221.herobrineai.misc; package org.jakub1221.herobrineai.misc;
import java.util.ArrayList; import java.util.ArrayList;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
@ -14,10 +13,10 @@ import org.bukkit.inventory.meta.SkullMeta;
public class ItemName { public class ItemName {
public static ItemMeta meta=null; public static ItemMeta meta = null;
public static SkullMeta skullmeta=null; public static SkullMeta skullmeta = null;
public static ItemStack colorLeatherArmor(ItemStack i,Color color){ public static ItemStack colorLeatherArmor(ItemStack i, Color color) {
LeatherArmorMeta la_meta = (LeatherArmorMeta) i.getItemMeta(); LeatherArmorMeta la_meta = (LeatherArmorMeta) i.getItemMeta();
la_meta.setColor(color); la_meta.setColor(color);
@ -25,37 +24,43 @@ public class ItemName {
return i; 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); meta.setDisplayName(name);
item.setItemMeta(meta); item.setItemMeta(meta);
return item; 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); meta.setLore(lore);
item.setItemMeta(meta); item.setItemMeta(meta);
return item; 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.setDisplayName(name);
meta.setLore(lore); meta.setLore(lore);
item.setItemMeta(meta); item.setItemMeta(meta);
return item; return item;
} }
public static ArrayList<String> getLore(ItemStack item){
public static ArrayList<String> getLore(ItemStack item) {
return (ArrayList<String>) item.getItemMeta().getLore(); return (ArrayList<String>) item.getItemMeta().getLore();
} }
public static String getName(ItemStack item){
public static String getName(ItemStack item) {
return item.getItemMeta().getDisplayName(); return item.getItemMeta().getDisplayName();
} }
public static ItemStack CreateSkull(String data){
ItemStack skull = new ItemStack(Material.SKULL_ITEM, 1, (short)SkullType.PLAYER.ordinal()); public static ItemStack CreateSkull(String data) {
SkullMeta skullmeta = (SkullMeta)skull.getItemMeta(); ItemStack skull = new ItemStack(Material.SKULL_ITEM, 1, (short) SkullType.PLAYER.ordinal());
SkullMeta skullmeta = (SkullMeta) skull.getItemMeta();
skullmeta.setOwner(data); skullmeta.setOwner(data);
skullmeta.setDisplayName(ChatColor.RESET+data); skullmeta.setDisplayName(ChatColor.RESET + data);
skull.setItemMeta(skullmeta); skull.setItemMeta(skullmeta);
return skull; return skull;
} }

View File

@ -10,13 +10,13 @@ import org.bukkit.configuration.file.YamlConfiguration;
public class StructureLoader { public class StructureLoader {
private int current=0; private int current = 0;
private int length=0; private int length = 0;
private InputStream inp; private InputStream inp;
private YamlConfiguration file; private YamlConfiguration file;
public StructureLoader(InputStream in){ public StructureLoader(InputStream in) {
inp=in; inp = in;
file = new YamlConfiguration(); file = new YamlConfiguration();
@ -32,16 +32,23 @@ public class StructureLoader {
e.printStackTrace(); e.printStackTrace();
} }
try {
inp.close();
} catch (IOException e) {
e.printStackTrace();
}
} }
public void Build(World world,int MainX,int MainY,int MainZ){ public void Build(World world, int MainX, int MainY, int MainZ) {
length=file.getInt("DATA.LENGTH")-1; length = file.getInt("DATA.LENGTH") - 1;
for (current=0;current<=length;current++){ 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); 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");
}
}