use of net.minecraft.server.v1_12_R1.PlayerInventory in project MyMaid2 by jaoafa.
the class Jail method JailAdd.
/**
* Jailに理由つきでプレイヤーを追加
* @param cmd コマンド情報
* @param player オフラインのプレイヤー
* @param banned_by 追加したプレイヤー
* @param reason 理由
* @return 実行できたかどうか
* @author mine_book000
* @throws SQLException
* @throws NullPointerException
* @throws ClassNotFoundException
* @throws EscapeJailException
*/
public static boolean JailAdd(OfflinePlayer player, CommandSender banned_by, String reason) throws ClassNotFoundException, NullPointerException, SQLException, EscapeJailException {
if (player == null) {
banned_by.sendMessage("[JAIL] " + ChatColor.GREEN + "指定されたプレイヤーは見つかりません。");
try {
throw new java.lang.NullPointerException("JailAdd OfflinePlayer is null...!");
} catch (java.lang.NullPointerException e) {
BugReporter(e);
}
return false;
}
if (banned_by instanceof Player) {
Player banned_by_player = (Player) banned_by;
Pointjao pointjao = new Pointjao(banned_by_player);
if (!pointjao.has(REQUIRED_jao)) {
// 所持していない
banned_by.sendMessage("[JAIL] " + ChatColor.GREEN + "あなたはJailするためのjaoポイントが足りません。");
return true;
}
}
if (Jail.contains(player.getUniqueId().toString())) {
// 既に牢獄にいるので無理
banned_by.sendMessage("[JAIL] " + ChatColor.GREEN + "指定されたプレイヤーはすでに牢獄にいるため追加できません。");
return false;
}
// Item Check
if (player.isOnline()) {
Boolean EscapeFlag = false;
Player target = player.getPlayer();
PlayerInventory inv = target.getInventory();
for (int n = 0; n < inv.getSize(); n++) {
ItemStack is = inv.getItem(n);
if (is == null) {
continue;
}
if (is.getType() == Material.AIR) {
continue;
}
net.minecraft.server.v1_12_R1.ItemStack nms = CraftItemStack.asNMSCopy(is);
NBTTagCompound nbttag = nms.getTag();
if (nbttag == null) {
continue;
}
String id = nbttag.getString("MyMaid_EscapeJailID");
if (id == null) {
continue;
} else if (id.equals("")) {
continue;
}
PreparedStatement statement = MySQL.getNewPreparedStatement("SELECT * FROM uniqueitem WHERE id = ? AND type = ?");
statement.setString(1, id);
statement.setString(2, "MyMaid_EscapeJailID");
ResultSet res = statement.executeQuery();
if (res.next()) {
// ある
if (res.getBoolean("used")) {
// 使ってる
nbttag.remove("MyMaid_EscapeJailID");
nms.setTag(nbttag);
is = CraftItemStack.asBukkitCopy(nms);
ItemMeta meta = is.getItemMeta();
meta.setDisplayName(meta.getDisplayName() + ChatColor.RED + " [使用済]");
is.setItemMeta(meta);
inv.setItem(n, is);
continue;
}
} else {
// ない
nbttag.remove("MyMaid_EscapeJailID");
nms.setTag(nbttag);
is = CraftItemStack.asBukkitCopy(nms);
ItemMeta meta = is.getItemMeta();
meta.setDisplayName(meta.getDisplayName() + ChatColor.RED + " [無効]");
is.setItemMeta(meta);
inv.setItem(n, is);
continue;
}
// 使ってない
PreparedStatement statement_disable = MySQL.getNewPreparedStatement("UPDATE uniqueitem SET used = ? WHERE id = ? AND type = ?");
statement_disable.setBoolean(1, true);
statement_disable.setString(2, id);
statement_disable.setString(3, "MyMaid_EscapeJailID");
statement_disable.executeUpdate();
nbttag.remove("MyMaid_EscapeJailID");
nms.setTag(nbttag);
is = CraftItemStack.asBukkitCopy(nms);
ItemMeta meta = is.getItemMeta();
meta.setDisplayName(meta.getDisplayName() + ChatColor.RED + " [使用済]");
is.setItemMeta(meta);
inv.setItem(n, is);
EscapeFlag = true;
break;
}
target.updateInventory();
if (EscapeFlag) {
if (banned_by instanceof Player) {
Player banned_by_player = (Player) banned_by;
Pointjao pointjao = new Pointjao(banned_by_player);
pointjao.use(REQUIRED_jao, player.getName() + "をJailに追加しようとしたため。(理由: " + reason + " | EscapeJailによって失敗)");
}
throw new EscapeJailException();
}
}
Jail.add(player.getUniqueId().toString());
// 設置破壊不可
block.put(player.getUniqueId().toString(), false);
// 範囲外移動
area.put(player.getUniqueId().toString(), false);
// まだ遺言を残してない
lasttext.put(player.getUniqueId().toString(), false);
SimpleDateFormat allsdf = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
try {
PreparedStatement statement = MySQL.getNewPreparedStatement("INSERT INTO jail (player, uuid, banned_by, reason, date) VALUES (?, ?, ?, ?, ?)");
statement.setString(1, player.getName());
statement.setString(2, player.getUniqueId().toString());
statement.setString(3, banned_by.getName());
statement.setString(4, reason);
statement.setString(5, allsdf.format(new Date()));
statement.executeUpdate();
} catch (SQLException | ClassNotFoundException e) {
BugReporter(e);
}
try {
PreparedStatement statement = MySQL.getNewPreparedStatement("INSERT INTO banlist (player, uuid, type, bannedby, reason, time) VALUES (?, ?, ?, ?, ?, ?)");
statement.setString(1, player.getName());
statement.setString(2, player.getUniqueId().toString());
statement.setString(3, "jail");
statement.setString(4, banned_by.getName());
statement.setString(5, reason);
statement.setString(6, allsdf.format(new Date()));
statement.executeUpdate();
} catch (SQLException | ClassNotFoundException e) {
BugReporter(e);
}
Bukkit.broadcastMessage("[JAIL] " + ChatColor.GREEN + "プレイヤー:「" + player.getName() + "」を「" + reason + "」という理由で牢獄リストに追加しました。");
DiscordSend("223582668132974594", "***Jail[追加]***: プレイヤー「" + player.getName() + "」が「" + banned_by.getName() + "」によって「" + reason + "」という理由でJailリストに追加されました。");
if (banned_by instanceof Player) {
Player banned_by_player = (Player) banned_by;
Pointjao pointjao = new Pointjao(banned_by_player);
pointjao.use(REQUIRED_jao, player.getName() + "をJailに追加したため。(理由: " + reason + ")");
}
JailBackupSaveTxt(player.getName(), JailType.ADD, banned_by.getName(), reason);
return true;
}
use of net.minecraft.server.v1_12_R1.PlayerInventory in project MyMaid2 by jaoafa.
the class Jail method JailAdd.
/**
* Jailにプレイヤーを追加
* @param cmd コマンド情報
* @param player オフラインのプレイヤー
* @param banned_by 追加したプレイヤー
* @return 実行できたかどうか
* @author mine_book000
* @throws SQLException
* @throws NullPointerException
* @throws ClassNotFoundException
* @throws EscapeJailException
*/
@Deprecated
public static boolean JailAdd(OfflinePlayer player, CommandSender banned_by) throws ClassNotFoundException, NullPointerException, SQLException, EscapeJailException {
if (player == null) {
banned_by.sendMessage("[JAIL] " + ChatColor.GREEN + "指定されたプレイヤーは見つかりません。");
try {
throw new java.lang.NullPointerException("JailAdd OfflinePlayer is null...!");
} catch (java.lang.NullPointerException e) {
BugReporter(e);
}
return false;
}
if (banned_by instanceof Player) {
Player banned_by_player = (Player) banned_by;
Pointjao pointjao = new Pointjao(banned_by_player);
if (!pointjao.has(REQUIRED_jao)) {
// 所持していない
banned_by.sendMessage("[JAIL] " + ChatColor.GREEN + "あなたはJailするためのjaoポイントが足りません。");
return true;
}
}
if (Jail.contains(player.getUniqueId().toString())) {
// 既に牢獄にいるので無理
banned_by.sendMessage("[JAIL] " + ChatColor.GREEN + "指定されたプレイヤーはすでに牢獄にいるため追加できません。");
return false;
}
// Item Check
if (player.isOnline()) {
Boolean EscapeFlag = false;
Player target = player.getPlayer();
PlayerInventory inv = target.getInventory();
for (int n = 0; n < inv.getSize(); n++) {
ItemStack is = inv.getItem(n);
if (is == null) {
continue;
}
if (is.getType() == Material.AIR) {
continue;
}
net.minecraft.server.v1_12_R1.ItemStack nms = CraftItemStack.asNMSCopy(is);
NBTTagCompound nbttag = nms.getTag();
if (nbttag == null) {
continue;
}
String id = nbttag.getString("MyMaid_EscapeJailID");
if (id == null) {
continue;
} else if (id.equals("")) {
continue;
}
PreparedStatement statement = MySQL.getNewPreparedStatement("SELECT * FROM uniqueitem WHERE id = ? AND type = ?");
statement.setString(1, id);
statement.setString(2, "MyMaid_EscapeJailID");
ResultSet res = statement.executeQuery();
if (res.next()) {
// ある
if (res.getBoolean("used")) {
// 使ってる
nbttag.remove("MyMaid_EscapeJailID");
nms.setTag(nbttag);
is = CraftItemStack.asBukkitCopy(nms);
ItemMeta meta = is.getItemMeta();
meta.setDisplayName(meta.getDisplayName() + ChatColor.RED + " [使用済]");
is.setItemMeta(meta);
inv.setItem(n, is);
continue;
}
} else {
// ない
nbttag.remove("MyMaid_EscapeJailID");
nms.setTag(nbttag);
is = CraftItemStack.asBukkitCopy(nms);
ItemMeta meta = is.getItemMeta();
meta.setDisplayName(meta.getDisplayName() + ChatColor.RED + " [無効]");
is.setItemMeta(meta);
inv.setItem(n, is);
continue;
}
// 使ってない
PreparedStatement statement_disable = MySQL.getNewPreparedStatement("UPDATE uniqueitem SET used = ? WHERE id = ? AND type = ?");
statement_disable.setBoolean(1, true);
statement_disable.setString(2, id);
statement_disable.setString(3, "MyMaid_EscapeJailID");
statement_disable.executeUpdate();
nbttag.remove("MyMaid_EscapeJailID");
nms.setTag(nbttag);
is = CraftItemStack.asBukkitCopy(nms);
ItemMeta meta = is.getItemMeta();
meta.setDisplayName(meta.getDisplayName() + ChatColor.RED + " [使用済]");
is.setItemMeta(meta);
inv.setItem(n, is);
EscapeFlag = true;
break;
}
target.updateInventory();
if (EscapeFlag) {
if (banned_by instanceof Player) {
Player banned_by_player = (Player) banned_by;
Pointjao pointjao = new Pointjao(banned_by_player);
pointjao.use(REQUIRED_jao, player.getName() + "をJailに追加しようとしたため。(EscapeJailによって失敗)");
}
throw new EscapeJailException();
}
}
Jail.add(player.getUniqueId().toString());
// 設置破壊不可
block.put(player.getUniqueId().toString(), false);
// 範囲外移動
area.put(player.getUniqueId().toString(), false);
// まだ遺言を残してない
lasttext.put(player.getUniqueId().toString(), false);
// データベース登録なし
Bukkit.broadcastMessage("[JAIL] " + ChatColor.GREEN + "プレイヤー:「" + player.getName() + "」を牢獄リストに追加しました。");
DiscordSend("223582668132974594", "***Jail[追加]***: プレイヤー「" + player.getName() + "」が「" + banned_by.getName() + "」によってJailリストに追加されました。");
if (banned_by instanceof Player) {
Player banned_by_player = (Player) banned_by;
Pointjao pointjao = new Pointjao(banned_by_player);
pointjao.use(REQUIRED_jao, player.getName() + "をJailに追加したため。");
}
JailBackupSaveTxt(player.getName(), JailType.ADD, banned_by.getName(), "");
return true;
}
use of net.minecraft.server.v1_12_R1.PlayerInventory in project MyMaid2 by jaoafa.
the class Jail method JailAdd.
/**
* Jailにプレイヤーを追加
* @param cmd コマンド情報
* @param player プレイヤー
* @param banned_by 追加したプレイヤー
* @return 実行できたかどうか
* @author mine_book000
* @throws SQLException
* @throws NullPointerException
* @throws ClassNotFoundException
* @throws EscapeJailException
*/
@Deprecated
public static boolean JailAdd(Player player, CommandSender banned_by) throws ClassNotFoundException, NullPointerException, SQLException, EscapeJailException {
if (player == null) {
banned_by.sendMessage("[JAIL] " + ChatColor.GREEN + "指定されたプレイヤーは見つかりません。");
try {
throw new java.lang.NullPointerException("JailAdd Player is null...!");
} catch (java.lang.NullPointerException e) {
BugReporter(e);
}
return false;
}
if (banned_by instanceof Player) {
Player banned_by_player = (Player) banned_by;
Pointjao pointjao = new Pointjao(banned_by_player);
if (!pointjao.has(REQUIRED_jao)) {
// 所持していない
banned_by.sendMessage("[JAIL] " + ChatColor.GREEN + "あなたはJailするためのjaoポイントが足りません。");
return true;
}
}
if (Jail.contains(player.getUniqueId().toString())) {
// 既に牢獄にいるので無理
banned_by.sendMessage("[JAIL] " + ChatColor.GREEN + "指定されたプレイヤーはすでに牢獄にいるため追加できません。");
return false;
}
// Item Check
if (player.isOnline()) {
Boolean EscapeFlag = false;
Player target = player.getPlayer();
PlayerInventory inv = target.getInventory();
for (int n = 0; n < inv.getSize(); n++) {
ItemStack is = inv.getItem(n);
if (is == null) {
continue;
}
if (is.getType() == Material.AIR) {
continue;
}
net.minecraft.server.v1_12_R1.ItemStack nms = CraftItemStack.asNMSCopy(is);
NBTTagCompound nbttag = nms.getTag();
if (nbttag == null) {
continue;
}
String id = nbttag.getString("MyMaid_EscapeJailID");
if (id == null) {
continue;
} else if (id.equals("")) {
continue;
}
PreparedStatement statement = MySQL.getNewPreparedStatement("SELECT * FROM uniqueitem WHERE id = ? AND type = ?");
statement.setString(1, id);
statement.setString(2, "MyMaid_EscapeJailID");
ResultSet res = statement.executeQuery();
if (res.next()) {
// ある
if (res.getBoolean("used")) {
// 使ってる
nbttag.remove("MyMaid_EscapeJailID");
nms.setTag(nbttag);
is = CraftItemStack.asBukkitCopy(nms);
ItemMeta meta = is.getItemMeta();
meta.setDisplayName(meta.getDisplayName() + ChatColor.RED + " [使用済]");
is.setItemMeta(meta);
inv.setItem(n, is);
continue;
}
} else {
// ない
nbttag.remove("MyMaid_EscapeJailID");
nms.setTag(nbttag);
is = CraftItemStack.asBukkitCopy(nms);
ItemMeta meta = is.getItemMeta();
meta.setDisplayName(meta.getDisplayName() + ChatColor.RED + " [無効]");
is.setItemMeta(meta);
inv.setItem(n, is);
continue;
}
// 使ってない
PreparedStatement statement_disable = MySQL.getNewPreparedStatement("UPDATE uniqueitem SET used = ? WHERE id = ? AND type = ?");
statement_disable.setBoolean(1, true);
statement_disable.setString(2, id);
statement_disable.setString(3, "MyMaid_EscapeJailID");
statement_disable.executeUpdate();
nbttag.remove("MyMaid_EscapeJailID");
nms.setTag(nbttag);
is = CraftItemStack.asBukkitCopy(nms);
ItemMeta meta = is.getItemMeta();
meta.setDisplayName(meta.getDisplayName() + ChatColor.RED + " [使用済]");
is.setItemMeta(meta);
inv.setItem(n, is);
EscapeFlag = true;
break;
}
target.updateInventory();
if (EscapeFlag) {
if (banned_by instanceof Player) {
Player banned_by_player = (Player) banned_by;
Pointjao pointjao = new Pointjao(banned_by_player);
pointjao.use(REQUIRED_jao, player.getName() + "をJailに追加しようとしたため。(EscapeJailによって失敗)");
}
throw new EscapeJailException();
}
}
Jail.add(player.getUniqueId().toString());
// 設置破壊不可
block.put(player.getUniqueId().toString(), false);
// 範囲外移動
area.put(player.getUniqueId().toString(), false);
// まだ遺言を残してない
lasttext.put(player.getUniqueId().toString(), false);
if (player.getGameMode() == GameMode.SPECTATOR)
player.setGameMode(GameMode.CREATIVE);
World Jao_Afa = Bukkit.getServer().getWorld("Jao_Afa");
Location minami = new Location(Jao_Afa, 2856, 69, 2888);
// テレポート
player.teleport(minami);
SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss");
player.sendMessage(ChatColor.GRAY + "[" + sdf.format(new Date()) + "]" + ChatColor.GOLD + "■jaotan" + ChatColor.WHITE + ": " + "やあ。" + player.getName() + "クン。どうも君はなにかをして南の楽園に来てしまったみたいなんだ");
player.sendMessage(ChatColor.GRAY + "[" + sdf.format(new Date()) + "]" + ChatColor.GOLD + "■jaotan" + ChatColor.WHITE + ": " + "なにをしてしまったのは知らないけどなにかをしたからここに来たんだと思うんだ。");
player.sendMessage(ChatColor.GRAY + "[" + sdf.format(new Date()) + "]" + ChatColor.GOLD + "■jaotan" + ChatColor.WHITE + ": " + "ちょっとやったことを反省してみるのもいいかもしれないね");
player.sendMessage(ChatColor.GRAY + "[" + sdf.format(new Date()) + "]" + ChatColor.GOLD + "■jaotan" + ChatColor.WHITE + ": " + "あ、そうだ、今の君に人権はないよ。");
player.sendMessage(ChatColor.GRAY + "[" + sdf.format(new Date()) + "]" + ChatColor.GOLD + "■jaotan" + ChatColor.WHITE + ": " + "あと、「/testment <LastText>」で遺言を残せるよ!");
// データベース登録なし
Bukkit.broadcastMessage("[JAIL] " + ChatColor.GREEN + "プレイヤー:「" + player.getName() + "」を牢獄リストに追加しました。");
DiscordSend("223582668132974594", "***Jail[追加]***: プレイヤー「" + player.getName() + "」が「" + banned_by.getName() + "」によってJailリストに追加されました。");
if (banned_by instanceof Player) {
Player banned_by_player = (Player) banned_by;
Pointjao pointjao = new Pointjao(banned_by_player);
pointjao.use(REQUIRED_jao, player.getName() + "をJailに追加したため。");
}
JailBackupSaveTxt(player.getName(), JailType.ADD, banned_by.getName(), "");
return true;
}
use of net.minecraft.server.v1_12_R1.PlayerInventory in project VehiclesPlus2.0 by legofreak107.
the class Boat method Boat.
public static void Boat(PacketPlayInSteerVehicle ppisv, Player p) {
ArmorStand a2 = (ArmorStand) p.getVehicle();
a2.setGravity(false);
Seat s = plugin.seatInfo.get(a2);
ArmorStand a = (ArmorStand) s.parent;
Vehicle v = plugin.vehicleInfo.get(a);
v.holder.setGravity(false);
if (p.getOpenInventory() != null && p.getOpenInventory() instanceof PlayerInventory) {
p.openInventory(v.inv);
}
float forward = ppisv.b();
float side = ppisv.a();
if (v.fuelbar == null) {
BossBar b = Bukkit.createBossBar("fuel" + v.owner, BarColor.GREEN, BarStyle.SOLID);
v.fuelbar = b;
}
Location tloc = a2.getLocation().clone();
Location smoke = tloc.add(tloc.getDirection().setY(0).normalize().multiply(-1.5));
smoke.getWorld().spawnParticle(Particle.SMOKE_LARGE, smoke.getX(), smoke.getY() + 1, smoke.getZ(), 1, 0, 0, 0, 0);
v.fuelbar.setTitle("Fuel: " + (int) (v.fuel / v.maxFuel * 100) + "%");
v.fuelbar.setProgress((v.fuel / v.maxFuel));
if (!v.parts.ENGINE) {
} else {
if (v.fuelbar.getPlayers().contains(p)) {
} else {
v.fuelbar.addPlayer(p);
v.fuelbar.setVisible(true);
}
if (v.fuel <= 0.5) {
v.fuelbar.setTitle("Out of fuel!");
} else {
v.fuel -= v.fualUsage / 2;
if (forward > 0) {
// Forward[W]
int broken = randInt(0, 20000);
int brokenEngine = randInt(0, 20000);
if (brokenEngine == 0) {
v.parts.ENGINE = false;
p.getWorld().playSound(p.getLocation(), Sound.ENTITY_GENERIC_EXPLODE, 10, 10);
p.sendMessage("�2It looks like you have blown up your engine...");
}
v.fuel -= v.fualUsage / 2;
if (v.curSpeed <= v.fspeed || v.curSpeed == 0) {
v.curSpeed = v.curSpeed += v.acceleration / 2;
}
Location fb = v.holder.getLocation().add(v.holder.getLocation().getDirection().setY(0).normalize().multiply(4));
float z1 = (float) (fb.getZ() + (4 * Math.sin(Math.toRadians(fb.getYaw() + 90 * 0))));
float x1 = (float) (fb.getX() + (4 * Math.cos(Math.toRadians(fb.getYaw() + 90 * 0))));
float z2 = (float) (fb.getZ() + (-4 * Math.sin(Math.toRadians(fb.getYaw() + 90 * 0))));
float x2 = (float) (fb.getX() + (-4 * Math.cos(Math.toRadians(fb.getYaw() + 90 * 0))));
Location loc1 = new Location(fb.getWorld(), x1, fb.getY(), z1);
Location loc2 = new Location(fb.getWorld(), x2, fb.getY(), z2);
if (fb.getBlock().getType() == Material.STATIONARY_WATER) {
if (side > 0) {
// Side[A]
if (loc1.getBlock().getType() == Material.STATIONARY_WATER && loc2.getBlock().getType() == Material.STATIONARY_WATER) {
v.skinHolder.setHeadPose(new EulerAngle(0, 0, 170));
EntityArmorStand a1 = ((CraftArmorStand) a).getHandle();
Location loc = a.getLocation().clone();
loc.setYaw(loc.getYaw() + 90);
a1.setLocation(a.getLocation().getX(), a.getLocation().getY(), a.getLocation().getZ(), a.getLocation().getYaw() - v.turnSpeed, a.getLocation().getPitch());
a1.move(EnumMoveType.SELF, new Vector(loc.getDirection().multiply(0.5).getX(), 0, loc.getDirection().multiply(0.5).getZ()).multiply(v.curSpeed).getX(), new Vector(loc.getDirection().multiply(0.5).getX(), 0, loc.getDirection().multiply(0.5).getZ()).multiply(v.curSpeed).getY(), new Vector(loc.getDirection().multiply(0.5).getX(), 0, loc.getDirection().multiply(0.5).getZ()).multiply(v.curSpeed).getZ());
a1.move(EnumMoveType.SELF, new Vector(a.getLocation().getDirection().multiply(0.5).getX(), 0, a.getLocation().getDirection().multiply(0.5).getZ()).multiply(v.curSpeed).getX(), new Vector(a.getLocation().getDirection().multiply(0.5).getX(), 0, a.getLocation().getDirection().multiply(0.5).getZ()).multiply(v.curSpeed).getY(), new Vector(a.getLocation().getDirection().multiply(0.5).getX(), 0, a.getLocation().getDirection().multiply(0.5).getZ()).multiply(v.curSpeed).getZ());
v.steering = (int) (v.turnSpeed / 2);
}
} else if (side < 0) {
// Side[D]
if (loc1.getBlock().getType() == Material.STATIONARY_WATER && loc2.getBlock().getType() == Material.STATIONARY_WATER) {
v.skinHolder.setHeadPose(new EulerAngle(0, 0, -170));
EntityArmorStand a1 = ((CraftArmorStand) a).getHandle();
Location loc = a.getLocation().clone();
loc.setYaw(loc.getYaw() - 90);
a1.setLocation(a.getLocation().getX(), a.getLocation().getY(), a.getLocation().getZ(), a.getLocation().getYaw() + v.turnSpeed, a.getLocation().getPitch());
a1.move(EnumMoveType.SELF, new Vector(loc.getDirection().multiply(0.5).getX(), 0, loc.getDirection().multiply(0.5).getZ()).multiply(v.curSpeed).getX(), new Vector(loc.getDirection().multiply(0.5).getX(), 0, loc.getDirection().multiply(0.5).getZ()).multiply(v.curSpeed).getY(), new Vector(loc.getDirection().multiply(0.5).getX(), 0, loc.getDirection().multiply(0.5).getZ()).multiply(v.curSpeed).getZ());
a1.move(EnumMoveType.SELF, new Vector(a.getLocation().getDirection().multiply(0.5).getX(), 0, a.getLocation().getDirection().multiply(0.5).getZ()).multiply(v.curSpeed).getX(), new Vector(a.getLocation().getDirection().multiply(0.5).getX(), 0, a.getLocation().getDirection().multiply(0.5).getZ()).multiply(v.curSpeed).getY(), new Vector(a.getLocation().getDirection().multiply(0.5).getX(), 0, a.getLocation().getDirection().multiply(0.5).getZ()).multiply(v.curSpeed).getZ());
v.steering = -(int) (v.turnSpeed / 2);
}
} else {
v.steering = 0;
v.skinHolder.setHeadPose(new EulerAngle(0, 0, 0));
EntityArmorStand a1 = ((CraftArmorStand) a).getHandle();
a1.move(EnumMoveType.SELF, new Vector(a.getLocation().getDirection().multiply(0.5).getX(), 0, a.getLocation().getDirection().multiply(0.5).getZ()).multiply(v.curSpeed).getX(), new Vector(a.getLocation().getDirection().multiply(0.5).getX(), 0, a.getLocation().getDirection().multiply(0.5).getZ()).multiply(v.curSpeed).getY(), new Vector(a.getLocation().getDirection().multiply(0.5).getX(), 0, a.getLocation().getDirection().multiply(0.5).getZ()).multiply(v.curSpeed).getZ());
}
} else {
v.curSpeed = 0;
}
} else if (forward < 0) {
// Reverse[S]
Location fb = v.holder.getLocation().add(v.holder.getLocation().getDirection().setY(0).normalize().multiply(-4));
float z1 = (float) (fb.getZ() + (4 * Math.sin(Math.toRadians(fb.getYaw() + 90 * 0))));
float x1 = (float) (fb.getX() + (4 * Math.cos(Math.toRadians(fb.getYaw() + 90 * 0))));
float z2 = (float) (fb.getZ() + (-4 * Math.sin(Math.toRadians(fb.getYaw() + 90 * 0))));
float x2 = (float) (fb.getX() + (-4 * Math.cos(Math.toRadians(fb.getYaw() + 90 * 0))));
Location loc1 = new Location(fb.getWorld(), x1, fb.getY(), z1);
Location loc2 = new Location(fb.getWorld(), x2, fb.getY(), z2);
if (fb.getBlock().getType() == Material.STATIONARY_WATER) {
v.skinHolder.setHeadPose(new EulerAngle(0, 0, 0));
v.fuel -= v.fualUsage / 2;
Location loc3 = new Location(a.getWorld(), a.getLocation().getBlockX(), a.getLocation().getBlockY(), a.getLocation().getBlockZ() + 1);
Location loc4 = new Location(a.getWorld(), a.getLocation().getBlockX(), a.getLocation().getBlockY(), a.getLocation().getBlockZ() - 1);
Location loc5 = new Location(a.getWorld(), a.getLocation().getBlockX() - 1, a.getLocation().getBlockY(), a.getLocation().getBlockZ());
if (v.curSpeed >= -v.bspeed || v.curSpeed == 0) {
v.curSpeed = v.curSpeed -= v.acceleration * 2;
}
if ((loc1.getBlock().getType() != Material.AIR && loc1.getBlock().getType() != Material.LONG_GRASS && loc1.getBlock().getType() != Material.CHORUS_FLOWER && loc1.getBlock().getType() != Material.YELLOW_FLOWER && loc1.getBlock().getType() != Material.RED_ROSE && loc1.getBlock().getType() != Material.WHEAT) || (loc2.getBlock().getType() != Material.AIR && loc2.getBlock().getType() != Material.LONG_GRASS && loc2.getBlock().getType() != Material.CHORUS_FLOWER && loc2.getBlock().getType() != Material.YELLOW_FLOWER && loc2.getBlock().getType() != Material.RED_ROSE && loc2.getBlock().getType() != Material.WHEAT) || (loc3.getBlock().getType() != Material.AIR && loc3.getBlock().getType() != Material.LONG_GRASS && loc3.getBlock().getType() != Material.CHORUS_FLOWER && loc3.getBlock().getType() != Material.YELLOW_FLOWER && loc3.getBlock().getType() != Material.RED_ROSE && loc3.getBlock().getType() != Material.WHEAT) || (loc4.getBlock().getType() != Material.AIR && loc4.getBlock().getType() != Material.LONG_GRASS && loc4.getBlock().getType() != Material.CHORUS_FLOWER && loc4.getBlock().getType() != Material.YELLOW_FLOWER && loc4.getBlock().getType() != Material.RED_ROSE && loc4.getBlock().getType() != Material.WHEAT) && loc5.getBlock().getType() != Material.AIR) {
EntityArmorStand a1 = ((CraftArmorStand) a).getHandle();
a1.move(EnumMoveType.SELF, new Vector(a.getLocation().getDirection().multiply(0.5).getX(), 0, a.getLocation().getDirection().multiply(0.5).getZ()).multiply(v.curSpeed).getX(), new Vector(a.getLocation().getDirection().multiply(0.5).getX(), 0, a.getLocation().getDirection().multiply(0.5).getZ()).multiply(v.curSpeed).getY(), // a.setVelocity(new Vector(a.getLocation().getDirection().multiply(0.5).getX(), -1, a.getLocation().getDirection().multiply(0.5).getZ()).multiply(- BwdDriveSpeed.get(a.getUniqueId())));
new Vector(a.getLocation().getDirection().multiply(0.5).getX(), 0, a.getLocation().getDirection().multiply(0.5).getZ()).multiply(v.curSpeed).getZ());
} else {
EntityArmorStand a1 = ((CraftArmorStand) a).getHandle();
a1.move(EnumMoveType.SELF, new Vector(a.getLocation().getDirection().multiply(0.5).getX(), 0, a.getLocation().getDirection().multiply(0.5).getZ()).multiply(v.curSpeed).getX(), new Vector(a.getLocation().getDirection().multiply(0.5).getX(), 0, a.getLocation().getDirection().multiply(0.5).getZ()).multiply(v.curSpeed).getY(), new Vector(a.getLocation().getDirection().multiply(0.5).getX(), 0, a.getLocation().getDirection().multiply(0.5).getZ()).multiply(v.curSpeed).getZ());
}
if (side > 0) {
// Side[A]
if (loc1.getBlock().getType() == Material.STATIONARY_WATER && loc2.getBlock().getType() == Material.STATIONARY_WATER) {
EntityArmorStand a1 = ((CraftArmorStand) a).getHandle();
a1.setLocation(a.getLocation().getX(), a.getLocation().getY(), a.getLocation().getZ(), a.getLocation().getYaw() + v.turnSpeed, a.getLocation().getPitch());
v.steering = (int) (v.turnSpeed / 2);
}
} else if (side < 0) {
// Side[D]
if (loc1.getBlock().getType() == Material.STATIONARY_WATER && loc2.getBlock().getType() == Material.STATIONARY_WATER) {
EntityArmorStand a1 = ((CraftArmorStand) a).getHandle();
a1.setLocation(a.getLocation().getX(), a.getLocation().getY(), a.getLocation().getZ(), a.getLocation().getYaw() - v.turnSpeed, a.getLocation().getPitch());
v.steering = -(int) (v.turnSpeed / 2);
}
} else {
v.steering = 0;
v.skinHolder.setHeadPose(new EulerAngle(0, 0, 0));
}
} else {
v.curSpeed = 0;
}
} else {
v.steering = 0;
if (v.curSpeed > v.acceleration) {
v.curSpeed = v.curSpeed -= v.acceleration;
} else if (v.curSpeed < -v.acceleration) {
v.curSpeed = v.curSpeed += v.acceleration;
} else {
v.curSpeed = 0;
}
EntityArmorStand a1 = ((CraftArmorStand) a).getHandle();
Location fb = v.holder.getLocation().add(v.holder.getLocation().getDirection().setY(0).normalize().multiply(4));
Location fb2 = v.holder.getLocation().add(v.holder.getLocation().getDirection().setY(0).normalize().multiply(-4));
if (fb.getBlock().getType() == Material.STATIONARY_WATER && fb2.getBlock().getType() == Material.STATIONARY_WATER) {
a1.move(EnumMoveType.SELF, new Vector(a.getLocation().getDirection().multiply(0.5).getX(), 0, a.getLocation().getDirection().multiply(0.5).getZ()).multiply(v.curSpeed).getX(), new Vector(a.getLocation().getDirection().multiply(0.5).getX(), 0, a.getLocation().getDirection().multiply(0.5).getZ()).multiply(v.curSpeed).getY(), new Vector(a.getLocation().getDirection().multiply(0.5).getX(), 0, a.getLocation().getDirection().multiply(0.5).getZ()).multiply(v.curSpeed).getZ());
} else {
v.curSpeed = 0;
}
}
}
}
}
use of net.minecraft.server.v1_12_R1.PlayerInventory in project VehiclesPlus2.0 by legofreak107.
the class Bike method Bike.
public static void Bike(PacketPlayInSteerVehicle ppisv, Player p) {
ArmorStand a2 = (ArmorStand) p.getVehicle();
Seat s = plugin.seatInfo.get(a2);
ArmorStand a = (ArmorStand) s.parent;
Vehicle v = plugin.vehicleInfo.get(a);
if (p.getOpenInventory() != null && p.getOpenInventory() instanceof PlayerInventory) {
p.openInventory(v.inv);
}
float forward = ppisv.b();
float side = ppisv.a();
if (v.fuelbar == null) {
BossBar b = Bukkit.createBossBar("fuel" + v.owner, BarColor.GREEN, BarStyle.SOLID);
v.fuelbar = b;
}
Location tloc = a2.getLocation().clone();
Location smoke = tloc.add(tloc.getDirection().setY(0).normalize().multiply(-1.5));
smoke.getWorld().spawnParticle(Particle.SMOKE_LARGE, smoke.getX(), smoke.getY() + 1, smoke.getZ(), 1, 0, 0, 0, 0);
v.fuelbar.setTitle("Fuel: " + (int) (v.fuel / v.maxFuel * 100) + "%");
v.fuelbar.setProgress((v.fuel / v.maxFuel));
if (!v.parts.ENGINE) {
} else {
if (v.fuelbar.getPlayers().contains(p)) {
} else {
v.fuelbar.addPlayer(p);
v.fuelbar.setVisible(true);
}
if (v.fuel <= 0.5) {
v.fuelbar.setTitle("Out of fuel!");
} else {
v.fuel -= v.fualUsage / 2;
if (forward > 0) {
// Forward[W]
int broken = randInt(0, 20000);
int brokenEngine = randInt(0, 20000);
if (brokenEngine == 0) {
v.parts.ENGINE = false;
p.getWorld().playSound(p.getLocation(), Sound.ENTITY_GENERIC_EXPLODE, 10, 10);
p.sendMessage("�2It looks like you have blown up your engine...");
} else if (broken == 1) {
v.parts.WHEELFL = false;
p.sendMessage("�2It looks like your rear tire is flat.");
} else if (broken == 2) {
v.parts.WHEELFR = false;
p.sendMessage("�2It looks like your front tire is flat.");
}
v.fuel -= v.fualUsage / 2;
if (v.curSpeed <= v.fspeed || v.curSpeed == 0) {
v.curSpeed = v.curSpeed += v.acceleration / 2;
}
if (!v.parts.WHEELFL || !v.parts.WHEELFR || !v.parts.WHEELRL || !v.parts.WHEELRR) {
a.setVelocity(new Vector(a.getLocation().getDirection().multiply(0.5).getX(), -v.curSpeed, a.getLocation().getDirection().multiply(0.5).getZ()).multiply(v.curSpeed / 4));
} else {
a.setVelocity(new Vector(a.getLocation().getDirection().multiply(0.5).getX(), -v.curSpeed, a.getLocation().getDirection().multiply(0.5).getZ()).multiply(v.curSpeed));
}
if (side > 0) {
// Side[A]
v.skinHolder.setHeadPose(new EulerAngle(0, 0, 170));
EntityArmorStand a1 = ((CraftArmorStand) a).getHandle();
a1.setLocation(a.getLocation().getX(), a.getLocation().getY(), a.getLocation().getZ(), a.getLocation().getYaw() - v.turnSpeed, a.getLocation().getPitch());
v.steering = (int) (v.turnSpeed / 2);
} else if (side < 0) {
// Side[D]
v.skinHolder.setHeadPose(new EulerAngle(0, 0, -170));
EntityArmorStand a1 = ((CraftArmorStand) a).getHandle();
a1.setLocation(a.getLocation().getX(), a.getLocation().getY(), a.getLocation().getZ(), a.getLocation().getYaw() + v.turnSpeed, a.getLocation().getPitch());
v.steering = -(int) (v.turnSpeed / 2);
} else {
v.steering = 0;
v.skinHolder.setHeadPose(new EulerAngle(0, 0, 0));
}
} else if (forward < 0) {
// Reverse[S]
v.skinHolder.setHeadPose(new EulerAngle(0, 0, 0));
v.fuel -= v.fualUsage / 2;
Location loc1 = new Location(a.getWorld(), a.getLocation().getBlockX() + 1, a.getLocation().getBlockY(), a.getLocation().getBlockZ());
Location loc2 = new Location(a.getWorld(), a.getLocation().getBlockX() - 1, a.getLocation().getBlockY(), a.getLocation().getBlockZ());
Location loc3 = new Location(a.getWorld(), a.getLocation().getBlockX(), a.getLocation().getBlockY(), a.getLocation().getBlockZ() + 1);
Location loc4 = new Location(a.getWorld(), a.getLocation().getBlockX(), a.getLocation().getBlockY(), a.getLocation().getBlockZ() - 1);
Location loc5 = new Location(a.getWorld(), a.getLocation().getBlockX() - 1, a.getLocation().getBlockY(), a.getLocation().getBlockZ());
if (v.curSpeed >= -v.bspeed || v.curSpeed == 0) {
v.curSpeed = v.curSpeed -= v.acceleration * 2;
}
if ((loc1.getBlock().getType() != Material.AIR && loc1.getBlock().getType() != Material.LONG_GRASS && loc1.getBlock().getType() != Material.CHORUS_FLOWER && loc1.getBlock().getType() != Material.YELLOW_FLOWER && loc1.getBlock().getType() != Material.RED_ROSE && loc1.getBlock().getType() != Material.WHEAT) || (loc2.getBlock().getType() != Material.AIR && loc2.getBlock().getType() != Material.LONG_GRASS && loc2.getBlock().getType() != Material.CHORUS_FLOWER && loc2.getBlock().getType() != Material.YELLOW_FLOWER && loc2.getBlock().getType() != Material.RED_ROSE && loc2.getBlock().getType() != Material.WHEAT) || (loc3.getBlock().getType() != Material.AIR && loc3.getBlock().getType() != Material.LONG_GRASS && loc3.getBlock().getType() != Material.CHORUS_FLOWER && loc3.getBlock().getType() != Material.YELLOW_FLOWER && loc3.getBlock().getType() != Material.RED_ROSE && loc3.getBlock().getType() != Material.WHEAT) || (loc4.getBlock().getType() != Material.AIR && loc4.getBlock().getType() != Material.LONG_GRASS && loc4.getBlock().getType() != Material.CHORUS_FLOWER && loc4.getBlock().getType() != Material.YELLOW_FLOWER && loc4.getBlock().getType() != Material.RED_ROSE && loc4.getBlock().getType() != Material.WHEAT) && loc5.getBlock().getType() != Material.AIR) {
a.setVelocity(new Vector(a.getLocation().getDirection().multiply(0.5).getX(), -v.curSpeed, a.getLocation().getDirection().multiply(0.5).getZ()).multiply(v.curSpeed));
// a.setVelocity(new Vector(a.getLocation().getDirection().multiply(0.5).getX(), -1, a.getLocation().getDirection().multiply(0.5).getZ()).multiply(- BwdDriveSpeed.get(a.getUniqueId())));
} else {
a.setVelocity(new Vector(a.getLocation().getDirection().multiply(0.5).getX(), -v.curSpeed, a.getLocation().getDirection().multiply(0.5).getZ()).multiply(v.curSpeed));
}
if (side > 0) {
// Side[A]
EntityArmorStand a1 = ((CraftArmorStand) a).getHandle();
a1.setLocation(a.getLocation().getX(), a.getLocation().getY(), a.getLocation().getZ(), a.getLocation().getYaw() + v.turnSpeed, a.getLocation().getPitch());
v.steering = (int) (v.turnSpeed / 2);
} else if (side < 0) {
// Side[D]
EntityArmorStand a1 = ((CraftArmorStand) a).getHandle();
a1.setLocation(a.getLocation().getX(), a.getLocation().getY(), a.getLocation().getZ(), a.getLocation().getYaw() - v.turnSpeed, a.getLocation().getPitch());
v.steering = -(int) (v.turnSpeed / 2);
} else {
v.steering = 0;
v.skinHolder.setHeadPose(new EulerAngle(0, 0, 0));
}
} else {
v.steering = 0;
if (v.curSpeed > v.acceleration) {
v.curSpeed = v.curSpeed -= v.acceleration;
} else if (v.curSpeed < -v.acceleration) {
v.curSpeed = v.curSpeed += v.acceleration;
} else {
v.curSpeed = 0;
}
a.setVelocity(new Vector(a.getLocation().getDirection().multiply(0.5).getX(), -v.curSpeed, a.getLocation().getDirection().multiply(0.5).getZ()).multiply(v.curSpeed));
}
}
}
}
Aggregations