Freeze Tutorial

Discussion in 'Plugin Development' started by SimplyCoded, Jul 11, 2014.

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

    SimplyCoded

    Okay, So im making a command from mineplex but Im trying to find a less glitchy way to freeze players anyone?
     
  2. Offline

    _Filip

    Start off by learning java.
     
    Funergy and simolus3 like this.
  3. Offline

    teej107

  4. Offline

    NonameSL

    SimplyCoded , do you know bukkit coding?
    If you don't know java, start off by learning Java.
    After you have learnt java, start learning simple bukkit stuff, like config, permissions, commands, events, locations, hashmaps... Dont start your learning with freezing a player for 5 seconds.
    I suggest PogoStick29 's youtube channel, PogoStick29Dev. He has over 50 episodes of bukkit coding.
    Then, when you truly start understanding bukkit, start practicing by coding plugins. If you don't know something - google it.
     
    PogoStick29 likes this.
  5. Offline

    SimplyCoded

    Yes i do im just stuck atm I can do the timer i just need to know a good method of freezing the player there are a couple threads saying it looks like its laggy or its glitchy so I want one thats not
     
  6. Offline

    Dealyise

    You could use a List and store the players which executed /tutorial.
    Then, continue with the PlayerMoveEvent.
    When List contains the player, cancel it. If not, continue.
    Like others said before, I would suggest you to learn Java and after that get started with BukkitAPI.
    There are many tutorials outside on YouTube and also here.
     
  7. Offline

    SimplyCoded

    OMFG stop saying learn java u dont know if i did or didnt. WHY DONT U READ
     
    Europia79 likes this.
  8. Offline

    AoH_Ruthless

    SimplyCoded
    In a PlayerMoveEvent, listen for if the to block is different from the from block. If they are different blocks, cancel the event.
     
  9. Offline

    Dealyise

    SimplyCoded
    There is a method, setWalkSpeed.
    If you did learn java and know the BukkitAPI, then you should know how to use that method I gave you.
     
    ZodiacTheories likes this.
  10. Offline

    SimplyCoded

    Okay if i never tried it how would i Know if its glitchy or not just stop coming to this threads you are really annoying you do not know if a person has or hasnt just by looking at something not everyone knows the answer to each thing god damn ur annoying that is annoying "LEARN JAVA LEARN JAVA" STFU

    I do not learn by videos im not that type of learner im learning by DOING

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

    Dealyise

    SimplyCoded

    Okay then, you just told us to stop helping you because it's annoying when we come to your thread.
    So, you want to learn by doing, then start doing it.
    setWalkSpeed - that's my help you get.
    Good day.
     
  12. Offline

    SimplyCoded

    No i said YOU!
     
  13. just use the event OnPlayerMove, and OnMove teleport player to previeus location
     
  14. Offline

    SimplyCoded

    I cant find any other good method so yea im gonna use that

    Why isn't this working I didnt add the actual tutorial yet but this is what I have so far
    Code:
    package com.sistancecoding.khg.events;
     
    import java.util.ArrayList;
     
    import org.bukkit.Bukkit;
    import org.bukkit.ChatColor;
    import org.bukkit.Location;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandExecutor;
    import org.bukkit.command.CommandSender;
    import org.bukkit.entity.Player;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.player.PlayerMoveEvent;
     
    import com.sistancecoding.khg.Main;
     
    public class Tutorial implements Listener, CommandExecutor {
        ArrayList<String> tut = new ArrayList<String>();
     
        public Tutorial(Main main) {
        }
     
        public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
            Player p = (Player)sender;
            if(cmd.getName().equalsIgnoreCase("tutorial")) {
                if (!(sender instanceof Player)) {
                    sender.sendMessage(ChatColor.RED + "You must be a player to execute this command!");
                }
                p.sendMessage(ChatColor.GOLD + "You have started the tutorial.");
                Tutorial.this.tut.add(p.getName());
                Location tut  = new Location(Bukkit.getServer().getWorld("world"), 180, 64, 100);
                p.teleport(tut);
               
                if(this.tut.contains(p)) {
                    p.sendMessage(ChatColor.RED + "You hae ended the tutorial without completing it, So you did not get the reward.");
                    Location leave = new Location(Bukkit.getServer().getWorld("world"), 184, 74, 263);
                    p.teleport(leave);
                    Tutorial.this.tut.remove(p.getName());
                }
            }
            return true;
        }
     
     
        @EventHandler
        public void addHimHer(PlayerMoveEvent e) {
            Player p = e.getPlayer();
            if(this.tut.contains(p)) {
                Location loc = p.getLocation();
                p.teleport(loc);
            }else{
                return;
            }
        }
    }
    I just put random coords for now

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 9, 2016
  15. Offline

    jthort

  16. Offline

    SimplyCoded

    there is none its just not freezing them and when I run the command again it dosnt remove them please reply back soon
     
  17. Offline

    tommyhoogstra

    I feel you man, people came in here just saying you need to learn java instantly, without evidence you don't know it at all.

    On topic: PlayerMoveEvent, on command add all players in an area to a list, if theyre on that list, cancel the event.
     
  18. Offline

    SimplyCoded

    k thanks ill try it
     
  19. Offline

    Dealyise

    I told you some posts ago, use setWalkSpeed if you don't want that it glitches.
     
    tommyhoogstra likes this.
  20. Offline

    tommyhoogstra

    This won't stop players from jumping and moving at the same time.
     
  21. Offline

    SimplyCoded

    do you know a better method
     
  22. Offline

    tommyhoogstra

    You can still use both setWalkSpeed and setFlySpeed and then check in the PlayerMoveEvent if the players Y has changed, and if it has, teleport the player back to the original location. (Don't cancel the event, it is glitchy as shit)

    That should work.

    Edit: Set the walkspeed and flyspeed to 0, and then do the regular check to see whether they have moved at all. It will be a lot less buggy than some servers, as it allows the players to rotate, if you want them to.
     
  23. Offline

    SimplyCoded

    k

    Everything but the event works it doesnt work.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 9, 2016
  24. Offline

    tommyhoogstra

    Does it look like this:
    Code:java
    1. if(e.getFrom().getY() != e.getTo().getY() || e.getFrom().getX() != e.getTo().getX() || e.getFrom().getZ() != e.getTo().getZ() ){
    2. p.teleport(e.getFrom());
    3. }
     
  25. SimplyCoded I'm not going to assume you don't know java. Make an event listener, PlayerMoveEvent and when the player moves check when they walk from one block to another, teleport the player to himself, So that makes it less buggy. When you cancel the event its pretty buggy and annoying.
     
  26. Offline

    SimplyCoded

    I DID

    Code:
        public void onHitWithBlazeRod(EntityDamageByEntityEvent e) {
            Player p = (Player)e.getEntity();
            Entity dam = e.getDamager();
            if ((e.getCause().equals(EntityDamageEvent.DamageCause.ENTITY_ATTACK)) &&
                    (((HumanEntity) dam).getItemInHand().equals(Material.BLAZE_ROD)))
                p.getItemInHand().setType(Material.WOOD_SWORD);
        }
    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 9, 2016
  27. Offline

    Necrodoom

  28. Offline

    SimplyCoded

    oh wrong one

    Code:
    package com.sistancecoding.khg.events;
     
    import java.util.ArrayList;
     
    import org.bukkit.Bukkit;
    import org.bukkit.ChatColor;
    import org.bukkit.Location;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandExecutor;
    import org.bukkit.command.CommandSender;
    import org.bukkit.entity.Player;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.player.PlayerMoveEvent;
     
    import com.sistancecoding.khg.Main;
     
    public class Tutorial implements Listener, CommandExecutor {
        ArrayList<String> tut = new ArrayList<String>();
        Location tut1 = new Location(Bukkit.getServer().getWorld("world"), 180, 64, 100);
     
        public Tutorial(Main main) {
        }
     
        public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
            Player p = (Player)sender;
            if(cmd.getName().equalsIgnoreCase("tutorial")) {
                if (!(sender instanceof Player)) {
                    sender.sendMessage(ChatColor.RED + "You must be a player to execute this command!");
                }
                if(this.tut.contains(p.getName())) {
                    p.sendMessage(ChatColor.RED + "You have ended the tutorial without completing it, So you did not get the reward.");
                    Location leave = new Location(Bukkit.getServer().getWorld("world"), 184, 74, 263);
                    p.teleport(leave);
                    Tutorial.this.tut.remove(p.getName());
                }else{
     
                    Tutorial.this.tut.add(p.getName());
                    p.sendMessage(ChatColor.GOLD + "You have started the tutorial.");
                    p.teleport(tut1);
                }
            }
            return true;
        }
     
     
        @EventHandler
        public void addHimHer(PlayerMoveEvent e) {
            Player p = e.getPlayer();
            if(this.tut.contains(p.getName())) {
                p.teleport(tut1);
            }
        }
    }
    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 9, 2016
  29. Offline

    pluginsbyjason

    I found a tutorial that might help you:
     
  30. Offline

    Necrodoom

    SimplyCoded did you register the listener? Did you make sure the listener works/player is in list using debug?
     
Thread Status:
Not open for further replies.

Share This Page