Unsure what's happening. On snowball launch

Discussion in 'Plugin Development' started by TheManiacGamers, Jan 27, 2019.

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

    TheManiacGamers

    Okay, so, I am making a Hub plugin, of which will have things such as double jump, pvp, kotl, mazes, parkour, etc.

    I have one feature, where when the player throws a snowball, they travel along the snowball (as a passenger)..
    It was working completely fine at one stage, now all of a sudden... it does not work.

    Before hand, I can double jump, I can do everything, it all works (except snowball)
    After I try throwing that snowball, it does not work. It teleports me to the side a little bit (as if I'm getting on the snowball to ride it).. then it says "Cannot send chat message" whenever I write, or do a command.

    Does not produce any errors in console.

    ProjectileLaunchEvent (open)
    Code:
    if (e.getEntity().getType().equals(EntityType.SNOWBALL)) {
                if (e.getEntity().getShooter() instanceof Player) {
                    Player p = (Player) e.getEntity().getShooter();
                    API.hashCheck(p, "kotl");
                    API.hashCheck(p, "parkour");
                    API.hashCheck(p, "maze");
                    removeFromGames(p);
                    e.getEntity().setPassenger(p);
                }
            }


    hashCheck method (open)

    Code:
        public static void hashCheck(Player p, String s) {
            if (s.equalsIgnoreCase("parkour")) {
                if (Main.parkour_isInParkour.get(p.getUniqueId()) == null) {
                    Main.parkour_isInParkour.put(p.getUniqueId(), "no");
                }
                if (Main.parkour_playerCheckpoints.get(p.getUniqueId()) == null) {
                    Main.parkour_isInParkour.put(p.getUniqueId(), "zero");
                }
                if (Main.canDoubleJump.get(p.getUniqueId()) == null) {
                    Main.canDoubleJump.put(p.getUniqueId(), "yes");
                }
            } else if (s.equalsIgnoreCase("maze")) {
                if (Main.maze_isInMaze.get(p.getUniqueId()) == null) {
                    Main.maze_isInMaze.put(p.getUniqueId(), "no");
                }
                if (Main.maze_playerEffectSeconds.get(p.getUniqueId()) == null) {
                    Main.maze_playerEffectSeconds.put(p.getUniqueId(), 0);
                }
                if (Main.canDoubleJump.get(p.getUniqueId()) == null) {
                    Main.canDoubleJump.put(p.getUniqueId(), "yes");
                }
            } else if (s.equalsIgnoreCase("flying")) {
                if (Main.isFlying.get(p.getUniqueId()) == null) {
                    Main.isFlying.put(p.getUniqueId(), "no");
                }
            } else if (s.equalsIgnoreCase("kotl")) {
                if (Main.kotl_playerInRegion.get(p.getUniqueId()) == null) {
                    Main.kotl_playerInRegion.put(p.getUniqueId(), "no");
                }
                if (Main.kotl_toldInRegion.get(p.getUniqueId()) == null) {
                    Main.kotl_toldInRegion.put(p.getUniqueId(), "no");
                }
            } else {
                Main.logError("There was an error doing a hashCheck: string not found.");
            }
        }


    removeFromGames method (open)

    Code:
    public static void removeFromGames(Player p) {
            API.hashCheck(p, "parkour");
            API.hashCheck(p, "maze");
            API.hashCheck(p, "flying");
            if (Main.parkour_isInParkour.get(p.getUniqueId()).equalsIgnoreCase("yes")) {
                Main.parkour_isInParkour.put(p.getUniqueId(), "no");
                Main.parkour_playerCheckpoints.put(p.getUniqueId(), "zero");
                p.sendMessage(Strings.getMessage("parkour_stop"));
            }
            if (Main.maze_isInMaze.get(p.getUniqueId()).equalsIgnoreCase("yes")) {
                Main.maze_isInMaze.put(p.getUniqueId(), "no");
                p.sendMessage(Strings.getMessage("maze_stop"));
            }
        }


    Plugins installed:
    WorldEdit,
    Essentials,
    EssentialsProtect,
    EssentialsChat,
    EssentialsAntiBuild,
    PermissionsEx,
    NoteBlockAPI,
    Hub (my plugin),
    Vault,
    EssentialsSpawn,
    Multiverse-Core,
    WorldGuard (could be issue?),
    ProtocolLib,
    JukeBox,
    WorldGuardExtraFlags,
    iPortal,
    UltraBar,
    GadgetsMenu,
    MarriageMaster,
    HolographicDisplays,
    LiteBans.
     
  2. Offline

    TheManiacGamers

    Sorry, I know, double command/post..
    I just made it so it was only
    Code:
        @EventHandler
        public void onProjectileThrow(ProjectileLaunchEvent e) {
            if (e.getEntity().getType().equals(EntityType.ENDER_PEARL)) {
                e.setCancelled(true);
            } else if (e.getEntity().getType().equals(EntityType.SNOWBALL)) {
                if (e.getEntity().getShooter() instanceof Player) {
                    Player p = (Player) e.getEntity().getShooter();
    //                API.hashCheck(p, "kotl");
    //                API.hashCheck(p, "parkour");
    //                API.hashCheck(p, "maze");
    //                removeFromGames(p);
                    e.getEntity().setPassenger(p);
                }
            }
        }
    Still doesn't work, still returns "Cannot send chat message" whenever i write a message or send a command. Still teleports me to the side a little bit when i throw the snowball.
     
Thread Status:
Not open for further replies.

Share This Page