use of net.minecraft.server.v1_7_R4.NBTTagCompound 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_7_R4.NBTTagCompound in project MyMaid2 by jaoafa.
the class Event_JoinjaoPoint method OnEvent_JoinjaoPoint.
@EventHandler
public void OnEvent_JoinjaoPoint(PlayerJoinEvent event) {
Player player = event.getPlayer();
String uuid = player.getUniqueId().toString();
Calendar cal = Calendar.getInstance();
cal.setTimeZone(TimeZone.getTimeZone("Asia/Tokyo"));
cal.set(cal.get(Calendar.YEAR), cal.get(Calendar.MONTH), cal.get(Calendar.DAY_OF_MONTH), 0, 0, 0);
SimpleDateFormat date_full = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
date_full.setTimeZone(TimeZone.getTimeZone("Asia/Tokyo"));
String today = date_full.format(cal.getTime());
SimpleDateFormat date = new SimpleDateFormat("yyyy/MM/dd");
try {
PreparedStatement statement = MySQL.getNewPreparedStatement("SELECT * FROM login WHERE uuid = ? AND date >= cast(? as datetime) AND login_success = ?");
statement.setString(1, uuid);
statement.setString(2, today);
statement.setBoolean(3, true);
ResultSet res = statement.executeQuery();
if (res.next()) {
return;
}
} catch (SQLException | ClassNotFoundException e) {
BugReporter(e);
}
try {
Pointjao Pjao = new Pointjao(player);
Pjao.add(10, date.format(new Date()) + "のログインボーナス");
} catch (NullPointerException e) {
BugReporter(e);
return;
} catch (ClassNotFoundException | SQLException e) {
BugReporter(e);
return;
}
try {
SimpleDateFormat format = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
Date start = format.parse("2019/03/05 00:00:00");
Date end = format.parse("2019/03/15 23:59:59");
if (isPeriod(start, end)) {
String group = PermissionsManager.getPermissionMainGroup(player);
if (!group.equalsIgnoreCase("Admin") && !group.equalsIgnoreCase("Moderator") && !group.equalsIgnoreCase("Regular") && !group.equalsIgnoreCase("Default")) {
return;
}
ItemStack item = new ItemStack(Material.POTATO_ITEM);
net.minecraft.server.v1_12_R1.ItemStack nms = CraftItemStack.asNMSCopy(item);
NBTTagCompound nbttag = nms.getTag();
if (nbttag == null) {
nbttag = new NBTTagCompound();
}
UUID item_uuid = UUID.randomUUID();
MessageDigest md;
try {
md = MessageDigest.getInstance("SHA-1");
} catch (NoSuchAlgorithmException e) {
BugReporter(e);
player.sendMessage("[EscapeJail] " + ChatColor.RED + "新しいEscapeJailアイテムの精製に失敗しました。(2)");
return;
}
byte[] digest = md.digest(item_uuid.toString().getBytes());
String id = DatatypeConverter.printHexBinary(digest);
if (id == null) {
player.sendMessage("[EscapeJail] " + ChatColor.RED + "新しいEscapeJailアイテムの精製に失敗しました。(3)");
return;
}
nbttag.setString("MyMaid_EscapeJailID", id);
nms.setTag(nbttag);
item = CraftItemStack.asBukkitCopy(nms);
ItemMeta meta = item.getItemMeta();
meta.setDisplayName("EscapeItem - IMO");
List<String> lore = new ArrayList<String>();
lore.add("このアイテムをインベントリ内に配置しておくと、Jail(EBan除く)を無効化できます!(アイテム1つにつき1回限り)");
lore.add(ChatColor.RED + "NBTデータを削除してしまうと、アイテムは無効となります。また、複製をしても1つしか有効ではありません。");
meta.setLore(lore);
meta.addEnchant(Enchantment.LOOT_BONUS_BLOCKS, 999, true);
item.setItemMeta(meta);
try {
PreparedStatement statement = MySQL.getNewPreparedStatement("INSERT INTO uniqueitem (id, type) VALUES (?, ?)");
statement.setString(1, id);
statement.setString(2, "MyMaid_EscapeJailID");
statement.executeUpdate();
} catch (SQLException | ClassNotFoundException e) {
BugReporter(e);
player.sendMessage("[EscapeJail] " + ChatColor.RED + "新しいEscapeJailアイテムの精製に失敗しました。(3)");
return;
}
player.sendMessage("[EscapeJail] " + ChatColor.RED + "新しいEscapeJailアイテムの精製に成功しました。");
player.sendMessage("[EscapeJail] " + ChatColor.RED + "このアイテムをインベントリの中に配置しておくと、Jail(EBan除く)をアイテム個数分だけ無効化できます!");
if (player.getInventory().firstEmpty() == -1) {
player.getLocation().getWorld().dropItem(player.getLocation(), item);
player.sendMessage("[EscapeJail] " + ChatColor.RED + "インベントリがいっぱいだったため、あなたの足元にアイテムをドロップしました。");
Bukkit.getLogger().info("[EscapeJail] dropped to " + player.getName());
} else {
player.getInventory().addItem(item);
Bukkit.getLogger().info("[EscapeJail] gived to " + player.getName());
}
}
} catch (ParseException e) {
BugReporter(e);
}
}
use of net.minecraft.server.v1_7_R4.NBTTagCompound in project MyMaid2 by jaoafa.
the class Event_Antijaoium method setjaoiumItemData.
private void setjaoiumItemData(Player player, ItemStack is) {
if (ItemData.containsKey(player.getName()))
return;
YamlConfiguration yaml = new YamlConfiguration();
yaml.set("data", is);
StringBuilder builder = new StringBuilder();
// "/give @p <アイテム> "
builder.append("/give @p splash_potion ");
// "/give @p <アイテム> [個数]"
builder.append(is.getAmount());
// "/give @p <アイテム> [個数] "
builder.append(" ");
// "/give @p <アイテム> [個数] [データ]"
builder.append(is.getDurability());
net.minecraft.server.v1_12_R1.ItemStack nmsItem = CraftItemStack.asNMSCopy(is);
NBTTagCompound nbttag = nmsItem.getTag();
if (nbttag != null) {
// "/give @p <アイテム> [個数] [データ] "
builder.append(" ");
// "/give @p <アイテム> [個数] [データ] [データタグ]"
builder.append(nbttag.toString());
}
String command = builder.toString();
yaml.set("command", command);
String code = yaml.saveToString();
String name = "MyMaid2 Antijaoium jaoium ItemData & Command";
try {
PreparedStatement statement = MySQL.getNewPreparedStatement("INSERT INTO cmd (player, uuid, title, command) VALUES (?, ?, ?, ?);", Statement.RETURN_GENERATED_KEYS);
statement.setString(1, player.getName());
statement.setString(2, player.getUniqueId().toString());
statement.setString(3, name);
statement.setString(4, code);
statement.executeUpdate();
ResultSet res = statement.getGeneratedKeys();
if (res == null || !res.next()) {
throw new IllegalStateException();
}
int id = res.getInt(1);
ItemData.put(player.getName(), "https://jaoafa.com/cmd/" + id);
} catch (SQLException | ClassNotFoundException e) {
ItemData.put(player.getName(), "null");
}
}
use of net.minecraft.server.v1_7_R4.NBTTagCompound in project Denizen-For-Bukkit by DenizenScript.
the class BlockHelper_v1_8_R3 method getNbtData.
@Override
public CompoundTag getNbtData(Block block) {
TileEntity tileEntity = ((CraftBlockState) block.getState()).getTileEntity();
if (tileEntity == null) {
return null;
}
NBTTagCompound nbtTagCompound = new NBTTagCompound();
tileEntity.b(new NBTTagCompound());
return CompoundTag_v1_8_R3.fromNMSTag(nbtTagCompound);
}
use of net.minecraft.server.v1_7_R4.NBTTagCompound in project Denizen-For-Bukkit by DenizenScript.
the class ItemHelper_v1_11_R1 method setSkullSkin.
@Override
public ItemStack setSkullSkin(ItemStack itemStack, PlayerProfile playerProfile) {
GameProfile gameProfile = new GameProfile(playerProfile.getUniqueId(), playerProfile.getName());
if (playerProfile.hasTexture()) {
gameProfile.getProperties().get("textures").clear();
if (playerProfile.getTextureSignature() != null) {
gameProfile.getProperties().put("textures", new Property("textures", playerProfile.getTexture(), playerProfile.getTextureSignature()));
} else {
gameProfile.getProperties().put("textures", new Property("textures", playerProfile.getTexture()));
}
}
net.minecraft.server.v1_11_R1.ItemStack nmsItemStack = CraftItemStack.asNMSCopy(itemStack);
NBTTagCompound tag = nmsItemStack.hasTag() ? nmsItemStack.getTag() : new NBTTagCompound();
tag.set("SkullOwner", GameProfileSerializer.serialize(new NBTTagCompound(), gameProfile));
nmsItemStack.setTag(tag);
return CraftItemStack.asBukkitCopy(nmsItemStack);
}
Aggregations