Any good minigame tutorials?

Discussion in 'Plugin Development' started by xpaintall, Apr 16, 2021.

  1. Offline

    xpaintall

    Ok, so I think that I am capable of making my minigame (despite the questions I asked on Bukkit), and whilst I was searching on youtube, bukkit / spigot tutorials, I couldn't find any good ones. One contained Thread#sleep(1000), the other was outdated and the code did not work, one had unknown GitHub pages, and the last wasn't finished. When you started creating minigames, what tutorial did you follow, and if you can still find it, can you send the link to me? I have been trying this for a while now and I sorta need help.
     
  2. Offline

    darthvader1925

    1. Do you have any java experience?
    2. Have you ever made a plugin?
    3. Thread#sleep will never work, because that will pause everything on the server.
    4. Any tutorials will work, once you understand the basics
     
  3. Offline

    xpaintall

    @darthvader1925 Okay, I have like 6-7 months of java experience, I made a couple of plugins and I have quite a bit of bukkit plugin making experience. I know that Thread#sleep will never work, since I said that it isn't good.
     
  4. Offline

    davidclue

    All you need to do is google anything you don't know but want to add, you didn't tell us anything about the mini-game you want to make so we can't really help you. It's how we all make plugins when we want to add something we search it up for example if you want to spawn custom mobs just search "Bukkit 1.16 how to spawn custom mobs."
     
  5. Offline

    xpaintall

    @davidclue I do understand how to use arenas as objects, how to add them etc... but the thing that is bothering me are GameStates and GameManagers (can I switch a gamestate in an event? Do I register a void in a event from my GameManager?) and similar.
     
  6. Offline

    davidclue

    There are many ways to create mini-games, I do not know what you mean by GameStates and GameManagers as I do not know what type of mini-game you are trying to make, and I do not have any of your code so I do not know how you making it. If you need some help then post some code and tell us what you are trying to acheive.
     
    xpaintall likes this.
  7. Offline

    xpaintall

    @davidclue Ok, the code is good and all after doing some "investigative journalism", but I cannot figure out how to check if a player is in a specific coordinate. The location counts decimals in the coordinate, and that's not what I want.
    now this is my void:
    Code:
    public void win(Arena a, Player player, String name) {
                new BukkitRunnable() {
                    @Override
                    public void run() {
    
                        if (player.getLocation() == getArena(name).getWinLocation()) {
                            List<UUID> winner = new ArrayList<>();
                            winner.add(player.getUniqueId());
                            if (winner.contains(player.getUniqueId())) {
                                for (UUID p : getArena(name).getPlayers()) {
                                    Player player1 = Bukkit.getPlayer(p);
                                    player1.teleport(getArena(name).getMainLobbyLocation());
                                    getArena(a.getName()).setPlayers(null);
                                    GameState.setGameState(GameState.WINNER);
                                    player1.sendMessage(ChatColor.RED + "Game over!");
                                    winner.remove(player.getUniqueId());
                                    cancel();
                                }
                            }
                        }
    
                    }
    
                }.runTaskTimer(f, 0, 1);
            }
    And my regularcommands class:
    Code:
    if(args[0].equalsIgnoreCase("setWinlocation")) {
                    if(args.length == 1) {
                        sender.sendMessage(ChatColor.RED + "Use /first setWinLocation <Arena name>");
                        return true;
                    }
                    String name = args[1];
                    if(!arenamanager.exists(name)) {
                        player.sendMessage("That arena does not exist!");
                    } else {
                        float x = (float) player.getLocation().getX();
                        float y = (float) player.getLocation().getY();
                        float z = (float) player.getLocation().getZ();
    
                        arenamanager.getArena(name).setWinLocation(new Location(player.getWorld(), x, y, z));
                        player.sendMessage("set the win location for arena " + name + " at:");
                        player.sendMessage(String.valueOf(player.getLocation().getX()));
                        player.sendMessage(String.valueOf(player.getLocation().getY()));
                        player.sendMessage(String.valueOf(player.getLocation().getZ()));
                    }
    
                    return true;
                }
    What am I doing wrong? I tried to set it to float, but it just won't work

    BTW, I know u asked what is the minigame that I am trying to make, and that is a parkour race minigame where you need to get to a specific location to win. I can send more code if you want.
     
    Last edited: Apr 17, 2021
  8. Offline

    davidclue

    Alright so first this if statement is completely useless
    Code:
    List<UUID> winner = new ArrayList<>();
    winner.add(player.getUniqueId());
    if (winner.contains(player.getUniqueId())) {
    Next, if you want a specific block to be the win location then you need to use getBlockX()
    Code:
    int x = player.getLocation().getBlockX();
    int y = player.getLocation().getBlockY();
    int z = player.getLocation().getBlockZ();
    And finally, use this to check the radius of the block (I can't test this my eclipse broke again and just won't work anymore)
    Code:
    Location win = getArena(name).getWinLocation();
    Location loc = player.getLocation();
    if (loc.getBlockX().equals(loc.getBlockX()) && loc.getBlockY().equals(loc.getBlockY()) && loc.getBlockZ().equals(loc.getBlockZ())) {
        //run code when player is on win location
    }
    I wanted to use vectors for the location and .distance() but my eclipse won't work :(
     
  9. Offline

    xpaintall

    Oh gee, thanks, but one last question before I get the basics about making a minigame. How do I put a parameter into an events void? like
    Code:
    public void eventSomething(PlayerMoveEvent, Arena a) {
    //but it won't register the event
    }
     
  10. Offline

    davidclue

    You cannot do that, what you are trying to accomplish is custom events, and here is a doc about how to make them. Also, don't forget about adding the @EventHandler above the method.
     
  11. Offline

    xpaintall

    @davidclue thanks for the help! I'll try to make a cool minigame.
     

Share This Page