more notes
This commit is contained in:
@@ -126,6 +126,8 @@ public class Bot extends EntityPlayer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void updateLocation() {
|
private void updateLocation() {
|
||||||
|
// Eventually there will be a whole algorithm here to slow a player down to a certain velocity depending on the liquid a player is in
|
||||||
|
|
||||||
velocity.setY(velocity.getY() - 0.1);
|
velocity.setY(velocity.getY() - 0.1);
|
||||||
|
|
||||||
double y;
|
double y;
|
||||||
@@ -181,15 +183,6 @@ public class Bot extends EntityPlayer {
|
|||||||
velocity.setZ(velocity.getZ() * 0.5);
|
velocity.setZ(velocity.getZ() * 0.5);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void die() {
|
|
||||||
super.die();
|
|
||||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
|
||||||
PlayerConnection connection = ((CraftPlayer) player).getHandle().playerConnection;
|
|
||||||
connection.sendPacket(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.REMOVE_PLAYER, this));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void despawn() {
|
public void despawn() {
|
||||||
getBukkitEntity().remove();
|
getBukkitEntity().remove();
|
||||||
}
|
}
|
||||||
@@ -254,6 +247,10 @@ public class Bot extends EntityPlayer {
|
|||||||
kbTicks = 10;
|
kbTicks = 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Location getLocation() {
|
||||||
|
return getBukkitEntity().getLocation();
|
||||||
|
}
|
||||||
|
|
||||||
public void faceLocation(Location loc) {
|
public void faceLocation(Location loc) {
|
||||||
try {
|
try {
|
||||||
CraftPlayer playerBot = this.getBukkitEntity();
|
CraftPlayer playerBot = this.getBukkitEntity();
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ public class PlayerAICommand extends CommandInstance {
|
|||||||
@Command(name = "create", desc = "Create bots.", usage = "<name> [skin]")
|
@Command(name = "create", desc = "Create bots.", usage = "<name> [skin]")
|
||||||
@Require("playerai.manage")
|
@Require("playerai.manage")
|
||||||
public void createBotCommand(@Sender Player sender, String name, @OptArg String skin) {
|
public void createBotCommand(@Sender Player sender, String name, @OptArg String skin) {
|
||||||
|
// make 16 character limit on name
|
||||||
Bot.createBot(name, sender.getLocation(), skin == null ? name : skin);
|
Bot.createBot(name, sender.getLocation(), skin == null ? name : skin);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,11 +3,14 @@ package net.nuggetmc.ai.utils;
|
|||||||
import com.google.gson.JsonObject;
|
import com.google.gson.JsonObject;
|
||||||
import com.google.gson.JsonParser;
|
import com.google.gson.JsonParser;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
|
||||||
public class MojangAPI {
|
public class MojangAPI {
|
||||||
|
|
||||||
|
// Eventually create some sort of cache that stores the skin data so it doesn't have to keep pulling from the API
|
||||||
|
// CATCHING NULLPOINTEREXCEPTION BAD!!!! eventually fix from the getAsJsonObject thingy
|
||||||
public static String[] getSkin(String name) {
|
public static String[] getSkin(String name) {
|
||||||
try {
|
try {
|
||||||
String uuid = new JsonParser().parse(new InputStreamReader(new URL("https://api.mojang.com/users/profiles/minecraft/" + name)
|
String uuid = new JsonParser().parse(new InputStreamReader(new URL("https://api.mojang.com/users/profiles/minecraft/" + name)
|
||||||
@@ -16,7 +19,7 @@ public class MojangAPI {
|
|||||||
.parse(new InputStreamReader(new URL("https://sessionserver.mojang.com/session/minecraft/profile/" + uuid + "?unsigned=false")
|
.parse(new InputStreamReader(new URL("https://sessionserver.mojang.com/session/minecraft/profile/" + uuid + "?unsigned=false")
|
||||||
.openStream())).getAsJsonObject().get("properties").getAsJsonArray().get(0).getAsJsonObject();
|
.openStream())).getAsJsonObject().get("properties").getAsJsonArray().get(0).getAsJsonObject();
|
||||||
return new String[] {property.get("value").getAsString(), property.get("signature").getAsString()};
|
return new String[] {property.get("value").getAsString(), property.get("signature").getAsString()};
|
||||||
} catch (Exception e) {
|
} catch (IOException | NullPointerException e) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user