Continued updating codebase for 1.14.4

This commit is contained in:
David Berdik 2019-09-02 19:14:10 -04:00
parent 2334f1fd78
commit e7fb908aaa
9 changed files with 31 additions and 68 deletions

View File

@ -211,13 +211,6 @@ public class HerobrineAI extends JavaPlugin implements Listener {
argst[0] = Class.class;
argst[1] = String.class;
argst[2] = int.class;
try {
Method ab = net.minecraft.server.v1_14_R1.EntityTypes.class.getDeclaredMethod("a", argst);
} catch (NoSuchMethodException e1) {
isNPCDisabled = true;
} catch (SecurityException e1) {
isNPCDisabled = true;
}
if (!isNPCDisabled) {
try {

View File

@ -24,7 +24,7 @@ public class BWorld {
}
public PlayerChunkMap getPlayerManager() {
return wServer.getPlayerChunkMap();
return wServer.getChunkProvider().playerChunkMap;
}
public CraftWorld getCraftWorld() {

View File

@ -11,11 +11,6 @@ import net.minecraft.server.v1_14_R1.PlayerInteractManager;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.event.EventException;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.world.ChunkLoadEvent;
import org.bukkit.event.world.ChunkUnloadEvent;
import org.bukkit.plugin.java.JavaPlugin;
import org.jakub1221.herobrineai.HerobrineAI;
import org.jakub1221.herobrineai.NPC.Entity.HumanEntity;
@ -104,35 +99,6 @@ public class NPCCore {
Bukkit.getServer().getScheduler().cancelTask(taskid);
}
private class WorldL implements Listener {
@SuppressWarnings("unused")
@EventHandler
public void onChunkLoad(ChunkLoadEvent event) throws EventException {
for (HumanNPC humannpc : npcs) {
if (humannpc != null
&& event.getChunk() == humannpc.getBukkitEntity().getLocation().getBlock().getChunk()) {
if (isInLoaded == false) {
BWorld world = getBWorld(event.getWorld());
isInLoaded = true;
}
}
}
}
@EventHandler
public void onChunkUnload(ChunkUnloadEvent event) {
for (HumanNPC humannpc : npcs) {
if (humannpc != null
&& event.getChunk() == humannpc.getBukkitEntity().getLocation().getBlock().getChunk()) {
}
}
}
}
public HumanNPC spawnHumanNPC(String name, Location l) {
lastID++;
int id = lastID;

View File

@ -20,7 +20,7 @@ public class CmdExecutor implements CommandExecutor {
"bury", "curse", "burn", "pyramid", "cave", "temple", "graveyard" };
public CmdExecutor(HerobrineAI p) {
log = p.log;
log = HerobrineAI.log;
subCommands.put("reload", new CmdReload(p, log));
subCommands.put("cancel", new CmdCancel(p, log));

View File

@ -35,7 +35,7 @@ public class CustomSkeleton extends net.minecraft.server.v1_14_R1.EntitySkeleton
Skeleton entityCast = (Skeleton) this.getBukkitEntity();
entityCast.getEquipment().setItemInHand(new ItemStack(Material.GOLDEN_APPLE, 1));
entityCast.getEquipment().setItemInMainHand(new ItemStack(Material.GOLDEN_APPLE, 1));
entityCast.getEquipment().setHelmet(ItemName.colorLeatherArmor(new ItemStack(Material.LEATHER_HELMET, 1), Color.RED));
entityCast.getEquipment().setChestplate(ItemName.colorLeatherArmor(new ItemStack(Material.LEATHER_CHESTPLATE, 1), Color.RED));
entityCast.getEquipment().setLeggings(ItemName.colorLeatherArmor(new ItemStack(Material.LEATHER_LEGGINGS, 1), Color.RED));

View File

@ -120,9 +120,9 @@ public class EntityListener implements Listener {
if (arrow.getShooter() instanceof Player) {
Player player = (Player) arrow.getShooter();
if (player.getItemInHand() != null) {
if (player.getInventory().getItemInMainHand() != null) {
itemInHand = player.getItemInHand();
itemInHand = player.getInventory().getItemInMainHand();
if (itemInHand.getType() != null) {
if (itemInHand.getType() == Material.BOW) {
@ -233,10 +233,10 @@ public class EntityListener implements Listener {
EntityDamageByEntityEvent dEvent = (EntityDamageByEntityEvent) event;
if (dEvent.getDamager() instanceof Player) {
Player player = (Player) dEvent.getDamager();
if (player.getItemInHand() != null) {
if (player.getItemInHand().getType() == Material.DIAMOND_SWORD) {
if (ItemName.getLore(player.getItemInHand()) != null) {
itemInHand = player.getItemInHand();
if (player.getInventory().getItemInMainHand() != null) {
if (player.getInventory().getItemInMainHand().getType() == Material.DIAMOND_SWORD) {
if (ItemName.getLore(player.getInventory().getItemInMainHand()) != null) {
itemInHand = player.getInventory().getItemInMainHand();
getLore = ItemName.getLore(itemInHand);
if (getLore.containsAll(equalsLoreS)) {
if (PluginCore.getConfigDB().UseArtifactSword) {
@ -269,10 +269,10 @@ public class EntityListener implements Listener {
if (event.getEntity() instanceof Player) {
if (event.getEntity().getEntityId() != PluginCore.HerobrineEntityID) {
Player player = (Player) event.getEntity();
if (player.getItemInHand() != null) {
if (player.getItemInHand().getType() == Material.DIAMOND_SWORD) {
if (ItemName.getLore(player.getItemInHand()) != null) {
itemInHand = player.getItemInHand();
if (player.getInventory().getItemInMainHand() != null) {
if (player.getInventory().getItemInMainHand().getType() == Material.DIAMOND_SWORD) {
if (ItemName.getLore(player.getInventory().getItemInMainHand()) != null) {
itemInHand = player.getInventory().getItemInMainHand();
getLore = ItemName.getLore(itemInHand);
if (getLore.containsAll(equalsLoreS)) {
if (PluginCore.getConfigDB().UseArtifactSword) {

View File

@ -51,10 +51,10 @@ public class PlayerListener implements Listener {
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.getClickedBlock() != null && event.getPlayer().getInventory().getItemInMainHand() != null) {
ItemStack itemInHand = event.getPlayer().getItemInHand();
if (event.getPlayer().getItemInHand().getType() != null) {
ItemStack itemInHand = event.getPlayer().getInventory().getItemInMainHand();
if (event.getPlayer().getInventory().getItemInMainHand().getType() != null) {
if (itemInHand.getType() == Material.DIAMOND_SWORD
|| itemInHand.getType() == Material.GOLDEN_APPLE) {
@ -128,10 +128,10 @@ public class PlayerListener implements Listener {
}
if (event.getClickedBlock() != null) {
if (event.getPlayer().getItemInHand() != null) {
if (event.getPlayer().getInventory().getItemInMainHand() != null) {
if (event.getClickedBlock().getType() == Material.JUKEBOX) {
ItemStack item = event.getPlayer().getItemInHand();
ItemStack item = event.getPlayer().getInventory().getItemInMainHand();
Jukebox block = (Jukebox) event.getClickedBlock().getState();
if (!block.isPlaying()) {
@ -175,11 +175,11 @@ public class PlayerListener implements Listener {
public void onPlayerQuit(PlayerQuitEvent event) {
if (event.getPlayer().getEntityId() != PluginCore.HerobrineEntityID) {
if (PluginCore.getAICore().PlayerTarget == event.getPlayer()
if (AICore.PlayerTarget == event.getPlayer()
&& PluginCore.getAICore().getCoreTypeNow() == CoreType.GRAVEYARD
&& event.getPlayer().getLocation().getWorld() == Bukkit.getServer()
.getWorld("world_herobrineai_graveyard")
&& PluginCore.getAICore().isTarget) {
&& AICore.isTarget) {
if (Utils.getRandomGen().nextBoolean()) {
event.getPlayer()

View File

@ -3,7 +3,10 @@ package org.jakub1221.herobrineai.misc;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.configuration.InvalidConfigurationException;
import org.bukkit.configuration.file.YamlConfiguration;
@ -21,7 +24,7 @@ public class StructureLoader {
file = new YamlConfiguration();
try {
file.load(inp);
file.load(new InputStreamReader(inp, StandardCharsets.UTF_8));
} catch (FileNotFoundException e) {
e.printStackTrace();
@ -41,12 +44,11 @@ public class StructureLoader {
}
public void Build(World world, int MainX, int MainY, int MainZ) {
length = file.getInt("DATA.LENGTH") - 1;
for (current = 0; current <= length; current++) {
world.getBlockAt(MainX + file.getInt("DATA." + current + ".X"),
MainY + file.getInt("DATA." + current + ".Y"), MainZ + file.getInt("DATA." + current + ".Z"))
.setTypeIdAndData(+file.getInt("DATA." + current + ".ID"),(byte) +file.getInt("DATA." + current + ".DATA"), false);
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"))
.setType(Material.valueOf(file.getString("DATA." + current + ".MATERIAL")));
}
}

View File

@ -5,6 +5,7 @@ import org.bukkit.Location;
import com.palmergames.bukkit.towny.Towny;
import com.palmergames.bukkit.towny.object.TownBlock;
import com.palmergames.bukkit.towny.object.TownyUniverse;
public class TownyHook {
public boolean Check() {
@ -15,7 +16,8 @@ public class TownyHook {
public boolean isSecuredArea(Location loc) {
Towny towny = (Towny) Bukkit.getServer().getPluginManager().getPlugin("Towny");
TownBlock block = towny.getTownyUniverse().getTownBlock(loc);
towny.getTownyUniverse();
TownBlock block = TownyUniverse.getTownBlock(loc);
return (block != null);
}
}