Search in sources :

Example 1 with AchievementType

use of com.jaoafa.jaoSuperAchievement.jaoAchievement.AchievementType in project MyMaid2 by jaoafa.

the class Event_VoteReceived method VoteReceive.

public static boolean VoteReceive(String name) {
    final int VOTEPOINT = 20;
    String oldVote = "取得できませんでした";
    String newVote = "取得できませんでした";
    String oldjao = "取得できませんでした";
    String newjao = "取得できませんでした";
    /* ------------- 投票イベント関連開始 ------------- */
    /*
		String plusargs = "";
		// ハロウィンイベント Issue #18
		try {
			SimpleDateFormat format = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
			Date start = format.parse("2017/10/15 09:00:00");
			Date end = format.parse("2017/11/01 08:59:59");
			if(isPeriod(start, end)){
				plusargs = "&pluscount=2"; // 2倍
			}
		} catch (ParseException e) {
			BugReporter(e);
		}
		try {
			SimpleDateFormat format = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
			Date start = format.parse("2017/07/01 00:00:00");
			Date end = format.parse("2017/07/14 23:59:59");
			if(Method.isPeriod(start, end)){
				VOTECOUNT += 20;
				Bukkit.broadcastMessage("[MyMaid] " + ChatColor.GREEN + player.getName() + "さんが投票し、七夕イベントボーナスを追加で20ポイントポイント追加しました。");
    			DiscordSend(player.getName() + "さんが投票し、七夕イベントボーナスを追加で20ポイント追加しました。");
			}
		} catch (ParseException e) {
			BugReporter(e);
		}
		 */
    /* ------------- 投票イベント関連終了 ------------- */
    UUID uuid = null;
    try {
        PreparedStatement statement = MySQL.getNewPreparedStatement("SELECT * FROM login WHERE player = ? ORDER BY id DESC");
        statement.setString(1, name);
        ResultSet res = statement.executeQuery();
        if (res.next()) {
            uuid = UUID.fromString(res.getString("uuid"));
        }
    } catch (SQLException | ClassNotFoundException e) {
        // TODO 自動生成された catch ブロック
        DiscordSend("499922840871632896", "<@221991565567066112> :outbox_tray:**投票受信エラー**: " + name + "のプレイヤーデータをデータベースから取得している最中にClassNotFoundExceptionもしくはSQLExceptionが発生したため、投票処理が正常に行われませんでした。");
        BugReporter(e);
        return false;
    }
    if (uuid == null) {
        DiscordSend("499922840871632896", "<@221991565567066112> :outbox_tray:**投票受信エラー**: " + name + "のプレイヤーデータがデータベースから取得できなかったため、投票処理が正常に行われませんでした。");
        return false;
    }
    OfflinePlayer offplayer = Bukkit.getOfflinePlayer(uuid);
    if (offplayer == null) {
        DiscordSend("499922840871632896", "<@221991565567066112> :outbox_tray:**投票受信エラー**: " + name + "のOfflinePlayerを取得できなかったため、投票処理が正常に行われませんでした。");
        return false;
    }
    if (!offplayer.getName().equals(name)) {
        name += "(" + offplayer.getName() + ")";
    }
    boolean first = PlayerVoteData.TodayFirstVote();
    String i;
    try {
        PlayerVoteData pvd = new PlayerVoteData(offplayer);
        oldVote = String.valueOf(pvd.get());
        pvd.add();
        newVote = String.valueOf(pvd.get());
        i = String.valueOf(pvd.get());
    } catch (ClassNotFoundException | SQLException e) {
        DiscordSend("499922840871632896", "<@221991565567066112> :outbox_tray:**投票受信エラー**: " + name + "の投票処理時にClassNotFoundExceptionもしくはSQLExceptionが発生したため、投票処理(投票数追加)が正常に行われませんでした。");
        BugReporter(e);
        return false;
    } catch (NullPointerException e) {
        DiscordSend("499922840871632896", "<@221991565567066112> :outbox_tray:**投票受信エラー**: " + name + "のプレイヤー投票データが取得できなかったため、投票処理(投票数追加)が正常に行われませんでした。");
        return false;
    }
    try {
        Pointjao pointjao = new Pointjao(offplayer);
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd");
        oldjao = "" + pointjao.get();
        pointjao.add(VOTEPOINT, sdf.format(new Date()) + "の投票ボーナス");
        newjao = "" + pointjao.get();
        try {
            SimpleDateFormat format = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
            Date start = format.parse("2018/08/12 00:00:00");
            Date end = format.parse("2018/08/31 23:59:59");
            if (isPeriod(start, end)) {
                Random rnd = new Random();
                int random = rnd.nextInt(40) + 11;
                pointjao.add(random, sdf.format(new Date()) + "の投票ボーナス (サバイバルイベント分)");
                Bukkit.broadcastMessage("[jaoPoint] " + ChatColor.GREEN + name + "さんがサバイバルイベント投票ボーナスによってjaoポイントを追加で" + random + "ポイント追加しました。");
                DiscordSend(name + "さんがサバイバルイベント投票ボーナスによってjaoポイントを追加で" + random + "ポイント追加しました。");
            }
        } catch (ParseException e) {
            BugReporter(e);
        }
    } catch (NullPointerException e) {
        DiscordSend("499922840871632896", "<@221991565567066112> :outbox_tray:**投票受信エラー**: " + name + "のプレイヤーデータが取得できなかったため、投票処理(ポイント追加)が正常に行われませんでした。");
        return false;
    } catch (ClassNotFoundException | SQLException e) {
        DiscordSend("499922840871632896", "<@221991565567066112> :outbox_tray:**投票受信エラー**: " + name + "の投票処理時にClassNotFoundExceptionもしくはSQLExceptionが発生したため、投票処理(投票数追加)が正常に行われませんでした。");
        BugReporter(e);
        return false;
    }
    SimpleDateFormat format = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
    Bukkit.broadcastMessage("[MyMaid] " + ChatColor.GREEN + "プレイヤー「" + name + "」が投票をしました!(現在の投票数:" + i + "回)");
    Bukkit.broadcastMessage("[MyMaid] " + ChatColor.GREEN + "投票をよろしくお願いします! https://jaoafa.com/vote");
    DiscordSend("プレイヤー「" + name + "」が投票をしました!(現在の投票数:" + i + "回)");
    DiscordSend("投票をよろしくお願いします! https://jaoafa.com/vote");
    DiscordSend("499922840871632896", ":inbox_tray:**投票を受信しました。(" + format.format(new Date()) + ")**\n" + "プレイヤー: `" + name + "`\n" + "投票前カウント: " + oldVote + "\n" + "投票後カウント: " + newVote + "\n" + "投票前jaoポイント: " + oldjao + "\n" + "投票後jaoポイント: " + newjao);
    if (first) {
        // 初めての投票だったら、実績獲得 (No.21 / 筆頭株主)
        if (offplayer != null) {
            Achievementjao.getAchievement(offplayer, new AchievementType(21));
        }
    }
    /*
    		if(date.format(Date).equalsIgnoreCase("2017-02")){
    			Random rnd = new Random();
    			int random = rnd.nextInt(50)+1;

    			Pointjao.addjao(player, random, sdf.format(Date) + "の投票ボーナス(2月ポイント補填ボーナス)");
    			Bukkit.broadcastMessage("[MyMaid] " + ChatColor.GREEN + player.getName() + "さんが投票し、2月ポイント補填ボーナスを" + random + "ポイント追加しました。");
    			DiscordSend(player.getName() + "さんが投票し、2月ポイント補填ボーナスを" + random + "ポイント追加しました。");
    		}
		 */
    return true;
}
Also used : SQLException(java.sql.SQLException) PreparedStatement(java.sql.PreparedStatement) Pointjao(com.jaoafa.MyMaid2.Lib.Pointjao) Date(java.util.Date) Random(java.util.Random) AchievementType(com.jaoafa.jaoSuperAchievement.jaoAchievement.AchievementType) ResultSet(java.sql.ResultSet) OfflinePlayer(org.bukkit.OfflinePlayer) ParseException(java.text.ParseException) UUID(java.util.UUID) SimpleDateFormat(java.text.SimpleDateFormat) PlayerVoteData(com.jaoafa.MyMaid2.Lib.PlayerVoteData)

Example 2 with AchievementType

use of com.jaoafa.jaoSuperAchievement.jaoAchievement.AchievementType in project MyMaid2 by jaoafa.

the class Event_Antijaoium method onPotionSplashEvent.

@SuppressWarnings("deprecation")
@EventHandler
public void onPotionSplashEvent(PotionSplashEvent 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) {
        if (!Achievementjao.getAchievement(player, new AchievementType(13))) {
            player.sendMessage(AchievementAPI.getPrefix() + "実績の解除中に問題が発生しました。もう一度お試しください。");
            return;
        }
        Bukkit.broadcastMessage("[jaoium_Checker] " + ChatColor.GREEN + "プレイヤー「" + player.getName() + "」からjaoiumと同等の性能を持つアイテムが検出されました。");
        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);
    }
}
Also used : Player(org.bukkit.entity.Player) SQLException(java.sql.SQLException) PotionMeta(org.bukkit.inventory.meta.PotionMeta) EscapeJailException(com.jaoafa.MyMaid2.Lib.EscapeJailException) AchievementType(com.jaoafa.jaoSuperAchievement.jaoAchievement.AchievementType) CraftItemStack(org.bukkit.craftbukkit.v1_12_R1.inventory.CraftItemStack) ItemStack(org.bukkit.inventory.ItemStack) Inventory(org.bukkit.inventory.Inventory) EventHandler(org.bukkit.event.EventHandler)

Example 3 with AchievementType

use of com.jaoafa.jaoSuperAchievement.jaoAchievement.AchievementType in project MyMaid2 by jaoafa.

the class Event_Antijaoium method onPlayerItemHeldEvent.

@SuppressWarnings("deprecation")
@EventHandler(ignoreCancelled = true)
public void onPlayerItemHeldEvent(PlayerItemHeldEvent event) {
    Player player = event.getPlayer();
    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を始末しよう!");
        }
    }
}
Also used : Player(org.bukkit.entity.Player) SQLException(java.sql.SQLException) PotionMeta(org.bukkit.inventory.meta.PotionMeta) EscapeJailException(com.jaoafa.MyMaid2.Lib.EscapeJailException) AchievementType(com.jaoafa.jaoSuperAchievement.jaoAchievement.AchievementType) CraftItemStack(org.bukkit.craftbukkit.v1_12_R1.inventory.CraftItemStack) ItemStack(org.bukkit.inventory.ItemStack) Inventory(org.bukkit.inventory.Inventory) EventHandler(org.bukkit.event.EventHandler)

Example 4 with AchievementType

use of com.jaoafa.jaoSuperAchievement.jaoAchievement.AchievementType in project MyMaid2 by jaoafa.

the class Event_Antijaoium method InvClick.

@SuppressWarnings("deprecation")
@EventHandler(priority = EventPriority.HIGHEST)
public void InvClick(InventoryClickEvent event) {
    if (!(event.getWhoClicked() instanceof Player)) {
        return;
    }
    Player player = (Player) event.getWhoClicked();
    Inventory inventory = event.getInventory();
    Inventory clickedinventory = event.getClickedInventory();
    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);
                if (inventory.getItem(n) != null)
                    inventory.clear(n);
                jaoium = _jaoium;
                if (isMalicious(potion) != null) {
                    malicious = isMalicious(potion);
                }
            }
        }
    }
    if (jaoium) {
        inventory.clear();
    }
    if (clickedinventory != null) {
        is = clickedinventory.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 _jaoium = isjaoium(potion.getCustomEffects());
                if (_jaoium) {
                    setjaoiumItemData(player, hand);
                    clickedinventory.clear(n);
                    jaoium = _jaoium;
                    if (isMalicious(potion) != null) {
                        malicious = isMalicious(potion);
                    }
                }
            }
        }
        if (jaoium) {
            clickedinventory.clear();
        }
    }
    if (jaoium) {
        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を始末しよう!");
        }
    }
}
Also used : Player(org.bukkit.entity.Player) SQLException(java.sql.SQLException) PotionMeta(org.bukkit.inventory.meta.PotionMeta) EscapeJailException(com.jaoafa.MyMaid2.Lib.EscapeJailException) AchievementType(com.jaoafa.jaoSuperAchievement.jaoAchievement.AchievementType) CraftItemStack(org.bukkit.craftbukkit.v1_12_R1.inventory.CraftItemStack) ItemStack(org.bukkit.inventory.ItemStack) Inventory(org.bukkit.inventory.Inventory) EventHandler(org.bukkit.event.EventHandler)

Example 5 with AchievementType

use of com.jaoafa.jaoSuperAchievement.jaoAchievement.AchievementType in project MyMaid2 by jaoafa.

the class Cmd_AFK method setAFK_True.

/**
 * プレイヤーをAFKにする
 *
 * @param player 設定するプレイヤー
 * @author mine_book000
 */
public static void setAFK_True(Player player) {
    if (getHeadICE(player)) {
        PlayerInventory playerinv = player.getInventory();
        head.put(player.getName(), playerinv.getHelmet());
        player.getInventory().setHelmet(new ItemStack(Material.ICE));
        player.updateInventory();
    }
    Bukkit.broadcastMessage(ChatColor.DARK_GRAY + player.getName() + " is afk!");
    DiscordSend(player.getName() + " is afk!");
    if (!Achievementjao.getAchievement(player, new AchievementType(11))) {
        player.sendMessage(AchievementAPI.getPrefix() + "実績の解除中に問題が発生しました。もう一度お試しください。");
        return;
    }
    String listname = player.getPlayerListName().replaceAll(player.getName(), ChatColor.DARK_GRAY + player.getName());
    player.setPlayerListName(listname);
    TitleAPI.sendTitle(player, 0, 99999999, 0, ChatColor.RED + "AFK NOW!", ChatColor.BLUE + "" + ChatColor.BOLD + "When you are back, please enter the command '/afk' or Move.");
    try {
        BukkitTask task = new Task_AFKING(player).runTaskTimer(JavaPlugin(), 0L, 5L);
        afking.put(player.getName(), task);
    } catch (java.lang.NoClassDefFoundError e) {
        BugReporter(e);
        afking.put(player.getName(), null);
    }
}
Also used : Task_AFKING(com.jaoafa.MyMaid2.Task.Task_AFKING) AchievementType(com.jaoafa.jaoSuperAchievement.jaoAchievement.AchievementType) BukkitTask(org.bukkit.scheduler.BukkitTask) PlayerInventory(org.bukkit.inventory.PlayerInventory) ItemStack(org.bukkit.inventory.ItemStack)

Aggregations

AchievementType (com.jaoafa.jaoSuperAchievement.jaoAchievement.AchievementType)9 SQLException (java.sql.SQLException)8 Player (org.bukkit.entity.Player)7 ItemStack (org.bukkit.inventory.ItemStack)7 CraftItemStack (org.bukkit.craftbukkit.v1_12_R1.inventory.CraftItemStack)6 EscapeJailException (com.jaoafa.MyMaid2.Lib.EscapeJailException)4 OfflinePlayer (org.bukkit.OfflinePlayer)4 EventHandler (org.bukkit.event.EventHandler)4 Inventory (org.bukkit.inventory.Inventory)4 PotionMeta (org.bukkit.inventory.meta.PotionMeta)4 PreparedStatement (java.sql.PreparedStatement)3 ResultSet (java.sql.ResultSet)3 SimpleDateFormat (java.text.SimpleDateFormat)3 Date (java.util.Date)3 Location (org.bukkit.Location)3 PlayerInventory (org.bukkit.inventory.PlayerInventory)3 Pointjao (com.jaoafa.MyMaid2.Lib.Pointjao)2 NBTTagCompound (net.minecraft.server.v1_12_R1.NBTTagCompound)2 World (org.bukkit.World)2 ItemMeta (org.bukkit.inventory.meta.ItemMeta)2