use of com.jaoafa.jaoSuperAchievement.jaoAchievement.AchievementType in project MyMaid2 by jaoafa.
the class Cmd_jao method onCommand.
@SuppressWarnings("deprecation")
public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
if (args.length >= 1 && args[0].equalsIgnoreCase("help")) {
SendUsageMessage(sender, cmd);
return true;
}
if (args.length == 1) {
OfflinePlayer offplayer = Bukkit.getOfflinePlayer(args[0]);
try {
Pointjao Pjao = new Pointjao(offplayer);
int now = Pjao.get();
SendMessage(sender, cmd, "現在" + offplayer.getName() + "が所持しているポイント数は" + now + "ポイントです。");
return true;
} catch (UnsupportedOperationException e) {
SendMessage(sender, cmd, "jaoポイントデータが存在しません。");
return true;
} catch (NullPointerException e) {
SendMessage(sender, cmd, "プレイヤーが見つかりません。");
return true;
} catch (ClassNotFoundException | SQLException e) {
BugReporter(e);
SendMessage(sender, cmd, "操作に失敗しました。");
SendMessage(sender, cmd, "詳しくはサーバコンソールをご確認ください");
SendMessage(sender, cmd, "再度実行しなおすと動作するかもしれません。");
return true;
}
} else if (args.length >= 4) {
// /jao use player point reason
if (args[0].equalsIgnoreCase("add")) {
// /jao add player point reason
OfflinePlayer offplayer = Bukkit.getOfflinePlayer(args[1]);
if (offplayer == null) {
SendMessage(sender, cmd, "プレイヤーが見つかりません。");
return true;
}
int point;
try {
point = Integer.parseInt(args[2]);
} catch (NumberFormatException e) {
SendMessage(sender, cmd, "ポイントには数値を指定してください。");
return true;
}
if (point <= 0) {
SendMessage(sender, cmd, "ポイントは1以上を指定してください。");
return true;
}
String reason = "";
int c = 3;
while (args.length > c) {
reason += args[c];
if (args.length != (c + 1)) {
reason += " ";
}
c++;
}
if (sender instanceof Player) {
reason += " (Player: " + sender.getName() + ")";
} else if (sender instanceof BlockCommandSender) {
BlockCommandSender bcs = (BlockCommandSender) sender;
Block block = bcs.getBlock();
reason += " (CmdBlock: " + block.getX() + " " + block.getY() + " " + block.getZ() + ")";
} else if (sender instanceof CommandMinecart) {
CommandMinecart cm = (CommandMinecart) sender;
Location loc = cm.getLocation();
reason += " (CmdCart: " + loc.getX() + " " + loc.getY() + " " + loc.getZ() + ")";
} else if (sender instanceof RemoteConsoleCommandSender) {
reason += " (Rcon)";
} else if (sender instanceof ConsoleCommandSender) {
reason += " (Console)";
} else if (sender instanceof ProxiedCommandSender) {
ProxiedCommandSender pcs = (ProxiedCommandSender) sender;
// コマンドの呼び出しに使用されているCommandSenderを返します。(コマンド実行させられているCommandSender?)
CommandSender Callee_sender = pcs.getCallee();
// このプロキシされたコマンドをトリガしたCommandSenderを返します。(executeコマンドを実行したCommandSender?)
CommandSender Caller_sender = pcs.getCaller();
reason += " (Execute: " + Callee_sender.getName() + " [" + Callee_sender + "] => " + Caller_sender.getName() + " [" + Caller_sender + "])";
} else {
reason += " (実行元特定不能: " + sender.getName() + "|" + sender.toString() + ")";
}
try {
Pointjao Pjao = new Pointjao(offplayer);
boolean bool = Pjao.add(point, reason);
if (bool) {
SendMessage(sender, cmd, "プレイヤー「" + offplayer.getName() + "」に" + point + "ポイントを追加しました。");
} else {
SendMessage(sender, cmd, "プレイヤー「" + offplayer.getName() + "」に" + point + "ポイントを追加できませんでした。");
}
return true;
} catch (UnsupportedOperationException e) {
SendMessage(sender, cmd, "jaoポイントデータが存在しません。");
return true;
} catch (NullPointerException e) {
SendMessage(sender, cmd, "プレイヤーが見つかりません。");
return true;
} catch (ClassNotFoundException | SQLException e) {
BugReporter(e);
SendMessage(sender, cmd, "操作に失敗しました。");
SendMessage(sender, cmd, "詳しくはサーバコンソールをご確認ください");
SendMessage(sender, cmd, "再度実行しなおすと動作するかもしれません。");
return true;
}
} else if (args[0].equalsIgnoreCase("use")) {
// /jao use player point reason
OfflinePlayer offplayer = Bukkit.getOfflinePlayer(args[1]);
if (offplayer == null) {
SendMessage(sender, cmd, "プレイヤーが見つかりません。");
return true;
}
int point;
try {
point = Integer.parseInt(args[2]);
} catch (NumberFormatException e) {
SendMessage(sender, cmd, "ポイントには数値を指定してください。");
return true;
}
if (point <= 0) {
SendMessage(sender, cmd, "ポイントは1以上を指定してください。");
return true;
}
String reason = "";
int c = 3;
while (args.length > c) {
reason += args[c];
if (args.length != (c + 1)) {
reason += " ";
}
c++;
}
if (sender instanceof Player) {
reason += " (Player: " + sender.getName() + ")";
} else if (sender instanceof BlockCommandSender) {
BlockCommandSender bcs = (BlockCommandSender) sender;
Block block = bcs.getBlock();
reason += " (CmdBlock: " + block.getX() + " " + block.getY() + " " + block.getZ() + ")";
} else if (sender instanceof CommandMinecart) {
CommandMinecart cm = (CommandMinecart) sender;
Location loc = cm.getLocation();
reason += " (CmdCart: " + loc.getX() + " " + loc.getY() + " " + loc.getZ() + ")";
} else if (sender instanceof RemoteConsoleCommandSender) {
reason += " (Rcon)";
} else if (sender instanceof ConsoleCommandSender) {
reason += " (Console)";
} else if (sender instanceof ProxiedCommandSender) {
ProxiedCommandSender pcs = (ProxiedCommandSender) sender;
// コマンドの呼び出しに使用されているCommandSenderを返します。(コマンド実行させられているCommandSender?)
CommandSender Callee_sender = pcs.getCallee();
// このプロキシされたコマンドをトリガしたCommandSenderを返します。(executeコマンドを実行したCommandSender?)
CommandSender Caller_sender = pcs.getCaller();
reason += " (Execute: " + Callee_sender.getName() + " [" + Callee_sender + "] => " + Caller_sender.getName() + " [" + Caller_sender + "])";
} else {
reason += " (実行元特定不能: " + sender.getName() + "|" + sender.toString() + ")";
}
try {
Pointjao Pjao = new Pointjao(offplayer);
boolean bool = Pjao.use(point, reason);
if (bool) {
SendMessage(sender, cmd, "プレイヤー「" + offplayer.getName() + "」から" + point + "ポイントを減算しました。");
} else {
SendMessage(sender, cmd, "プレイヤー「" + offplayer.getName() + "」から" + point + "ポイントを減算できませんでした。");
}
return true;
} catch (UnsupportedOperationException e) {
SendMessage(sender, cmd, "jaoポイントデータが存在しません。");
return true;
} catch (NullPointerException e) {
SendMessage(sender, cmd, "プレイヤーが見つかりません。");
return true;
} catch (ClassNotFoundException | SQLException e) {
BugReporter(e);
SendMessage(sender, cmd, "操作に失敗しました。");
SendMessage(sender, cmd, "詳しくはサーバコンソールをご確認ください");
SendMessage(sender, cmd, "再度実行しなおすと動作するかもしれません。");
return true;
}
} else if (args[0].equalsIgnoreCase("pay")) {
// /jao pay player point reason
if (!(sender instanceof Player)) {
SendMessage(sender, cmd, "このコマンドはゲーム内から実行してください。");
return true;
}
Player player = (Player) sender;
OfflinePlayer offplayer = Bukkit.getOfflinePlayer(args[1]);
if (offplayer == null) {
SendMessage(sender, cmd, "プレイヤーが見つかりません。");
return true;
}
int point;
try {
point = Integer.parseInt(args[2]);
} catch (NumberFormatException e) {
SendMessage(sender, cmd, "ポイントには数値を指定してください。");
return true;
}
if (point <= 0) {
SendMessage(sender, cmd, "ポイントは1以上を指定してください。");
return true;
}
String reason = "";
int c = 3;
while (args.length > c) {
reason += args[c];
if (args.length != (c + 1)) {
reason += " ";
}
c++;
}
String add_reason = "プレイヤー「" + offplayer.getName() + "」へ「" + reason + "」という理由での支払い。";
String use_reason = "プレイヤー「" + player.getName() + "」から「" + reason + "」という理由での支払い。";
try {
Pointjao playerPjao = new Pointjao(player);
Pointjao offplayerPjao = new Pointjao(offplayer);
boolean use_bool = playerPjao.use(point, add_reason);
if (use_bool) {
boolean add_bool = offplayerPjao.add(point, use_reason);
if (add_bool) {
SendMessage(sender, cmd, "プレイヤー「" + offplayer.getName() + "」に" + point + "ポイントを支払いました。");
if (!Achievementjao.getAchievement(player, new AchievementType(23))) {
player.sendMessage(AchievementAPI.getPrefix() + "実績の解除中に問題が発生しました。もう一度お試しください。");
}
} else {
SendMessage(sender, cmd, "プレイヤー「" + offplayer.getName() + "」に" + point + "ポイントを支払えませんでした。");
playerPjao.add(point, "『" + add_reason + "』の失敗による返却");
}
} else {
SendMessage(sender, cmd, "プレイヤー「" + offplayer.getName() + "」から" + point + "ポイントを減算できませんでした。");
}
return true;
} catch (UnsupportedOperationException e) {
SendMessage(sender, cmd, "jaoポイントデータが存在しません。");
return true;
} catch (NullPointerException e) {
SendMessage(sender, cmd, "プレイヤーが見つかりません。");
return true;
} catch (ClassNotFoundException | SQLException e) {
BugReporter(e);
SendMessage(sender, cmd, "操作に失敗しました。");
SendMessage(sender, cmd, "詳しくはサーバコンソールをご確認ください");
SendMessage(sender, cmd, "再度実行しなおすと動作するかもしれません。");
return true;
}
}
}
if (!(sender instanceof Player)) {
SendMessage(sender, cmd, "このコマンドはゲーム内から実行してください。");
return true;
}
Player player = (Player) sender;
try {
Pointjao Pjao = new Pointjao(player);
int now = Pjao.get();
SendMessage(sender, cmd, "現在あなたが所持しているポイント数は" + now + "ポイントです。");
return true;
} catch (UnsupportedOperationException e) {
SendMessage(sender, cmd, "jaoポイントデータが存在しません。");
return true;
} catch (NullPointerException e) {
SendMessage(sender, cmd, "プレイヤーが見つかりません。");
return true;
} catch (ClassNotFoundException | SQLException e) {
BugReporter(e);
SendMessage(sender, cmd, "操作に失敗しました。");
SendMessage(sender, cmd, "詳しくはサーバコンソールをご確認ください");
SendMessage(sender, cmd, "再度実行しなおすと動作するかもしれません。");
return true;
}
}
use of com.jaoafa.jaoSuperAchievement.jaoAchievement.AchievementType in project MyMaid2 by jaoafa.
the class Event_Antijaoium method onProjectileLaunchEvent.
@SuppressWarnings("deprecation")
@EventHandler
public void onProjectileLaunchEvent(ProjectileLaunchEvent event) {
if (!(event.getEntity().getShooter() instanceof Player)) {
return;
}
Player player = (Player) event.getEntity().getShooter();
Inventory inventory = player.getInventory();
Inventory enderchestinventory = player.getEnderChest();
ItemStack[] is = inventory.getContents();
if (Jail.isJail(player)) {
return;
}
boolean jaoium = false;
String malicious = null;
for (int n = 0; n < is.length; n++) {
if (is[n] == null) {
continue;
}
ItemStack hand = is[n];
if (hand.getType() == Material.SPLASH_POTION || hand.getType() == Material.LINGERING_POTION) {
PotionMeta potion = (PotionMeta) hand.getItemMeta();
boolean _jaoium = isjaoium(potion.getCustomEffects());
if (_jaoium) {
setjaoiumItemData(player, hand);
inventory.clear(n);
jaoium = _jaoium;
if (isMalicious(potion) != null) {
malicious = isMalicious(potion);
}
}
}
}
if (jaoium) {
inventory.clear();
}
boolean enderjaoium = false;
if (enderchestinventory != null) {
is = enderchestinventory.getContents();
for (int n = 0; n < is.length; n++) {
if (is[n] == null) {
continue;
}
ItemStack hand = is[n];
if (hand.getType() == Material.SPLASH_POTION || hand.getType() == Material.LINGERING_POTION) {
PotionMeta potion = (PotionMeta) hand.getItemMeta();
boolean _enderjaoium = isjaoium(potion.getCustomEffects());
if (_enderjaoium) {
setjaoiumItemData(player, hand);
enderchestinventory.clear(n);
enderjaoium = _enderjaoium;
if (isMalicious(potion) != null) {
malicious = isMalicious(potion);
}
}
}
}
if (enderjaoium) {
enderchestinventory.clear();
}
}
if (jaoium || enderjaoium) {
Bukkit.broadcastMessage("[jaoium_Checker] " + ChatColor.GREEN + "プレイヤー「" + player.getName() + "」からjaoiumと同等の性能を持つアイテムが検出されました。");
if (!Achievementjao.getAchievement(player, new AchievementType(13))) {
player.sendMessage(AchievementAPI.getPrefix() + "実績の解除中に問題が発生しました。もう一度お試しください。");
return;
}
checkjaoiumLocation(player);
try {
if (malicious != null) {
EBan.Add(player, Bukkit.getOfflinePlayer("jaotan"), "禁止クライアントMod「" + malicious + "」使用の疑い。方針「クライアントModの導入・利用に関する規則」の「禁止事項」への違反");
} else {
Jail.JailAdd(player, Bukkit.getOfflinePlayer("jaotan"), "jaoium所持", true);
}
} catch (ClassNotFoundException | NullPointerException | SQLException e) {
BugReporter(e);
} catch (EscapeJailException e) {
// EscapeJailアイテムで止められた
// 痛くもない雷を落とす
player.getWorld().strikeLightningEffect(player.getLocation());
player.sendMessage("[jaoium_Checker] " + ChatColor.GREEN + "EscapeJailアイテムによって、jaotanからの「jaoium所持」という理由によるJailを無効化しました!");
player.sendMessage("[jaoium_Checker] " + ChatColor.GREEN + "早くjaoiumを始末しよう!");
}
event.setCancelled(true);
}
}
use of com.jaoafa.jaoSuperAchievement.jaoAchievement.AchievementType in project MyMaid2 by jaoafa.
the class Jail method JailAdd.
/**
* Jailに理由つきでプレイヤーを追加
* @param cmd コマンド情報
* @param player プレイヤー
* @param banned_by 追加したプレイヤー
* @param reason 理由
* @param InvRemove インベントリを削除するか
* @return 実行できたかどうか
* @author mine_book000
* @throws SQLException
* @throws NullPointerException
* @throws ClassNotFoundException
* @throws EscapeJailException
*/
public static boolean JailAdd(Player player, OfflinePlayer banned_by, String reason, boolean InvRemove) throws ClassNotFoundException, NullPointerException, SQLException, EscapeJailException {
if (player == null) {
try {
throw new java.lang.NullPointerException("JailAdd Player is null...!");
} catch (java.lang.NullPointerException e) {
BugReporter(e);
}
return false;
}
if (banned_by == null) {
try {
throw new java.lang.NullPointerException("JailAdd OfflinePlayer(banned_by) 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)) {
// 所持していない
((Player) banned_by).sendMessage("[JAIL] " + ChatColor.GREEN + "あなたはJailするためのjaoポイントが足りません。");
return false;
}
}
if (Jail.contains(player.getUniqueId().toString())) {
// 既に牢獄にいるので無理
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);
if (InvRemove) {
player.getInventory().clear();
// player.getEnderChest().clear(); - さすがにエンダーチェスト消すのはかわいそうかなと思ってきた
}
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");
SimpleDateFormat allsdf = new SimpleDateFormat("yyyy/MM/dd 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 + ": " + "話を聞けば、「" + reason + "」という理由でここにきたみたいだね。");
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>」で遺言を残せるよ!");
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 (!Achievementjao.getAchievement(player, new AchievementType(20))) {
player.sendMessage(AchievementAPI.getPrefix() + "実績の解除中に問題が発生しました。");
}
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 com.jaoafa.jaoSuperAchievement.jaoAchievement.AchievementType in project MyMaid2 by jaoafa.
the class Jail method JailAdd.
/**
* Jailに理由つきでプレイヤーを追加
* @param cmd コマンド情報
* @param player プレイヤー
* @param banned_by 追加したプレイヤー
* @param reason 理由
* @param InvRemove インベントリを削除するか
* @return 実行できたかどうか
* @author mine_book000
* @throws SQLException
* @throws NullPointerException
* @throws ClassNotFoundException
* @throws EscapeJailException
*/
public static boolean JailAdd(Player player, CommandSender banned_by, String reason, boolean InvRemove) 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に追加しようとしたため。(理由: " + 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);
if (InvRemove) {
player.getInventory().clear();
// player.getEnderChest().clear(); - さすがにエンダーチェスト消すのはかわいそうかなと思ってきた
}
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 allsdf = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
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 + ": " + "話を聞けば、「" + reason + "」という理由でここにきたみたいだね。");
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>」で遺言を残せるよ!");
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 (!Achievementjao.getAchievement(player, new AchievementType(20))) {
player.sendMessage(AchievementAPI.getPrefix() + "実績の解除中に問題が発生しました。");
}
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;
}
Aggregations