Hi, by chance does anyone know how I can have 3 small modes inside a minigame? For example, the paintball minigame divided into 3 modes.
Yes it is just that, I practically want 3 small modes. For example, when you type the command to create the arena and the type of mode, you will need to execute the instructions valid for the type of mode selected. Another example is when the selected mode, for example, is conquest, you will have to select the area, etc. ... (I don't know if I explained myself)
so you need 3 instances that extends a class game which contains what all 3 classes share ie. a player list an id a name, a gamemode etc etc
I think this might help you: https://www.spigotmc.org/threads/creating-custom-modes-or-scenarios.414500/#post-3669309
This was just an example for a different problem. It may not be suitable for this problem, but I don't know because the problem wasn't explained well. What do you think would be a clean way? (What you suggested above is very similar to what I linked)
This could be an example. Code (Text): public class GoldRush extends Experiment { private int totalmined = 0; private List<Block> rollback; public GoldRush(Main main, Game g, List<Location> spawns) { super(main, g, spawns, ExperimentType.GOLD_RUSH); rollback = new ArrayList<Block>(); } @Override public void onStart() { for (Player p : g.getPlayers()) { p.getInventory().setHeldItemSlot(0); ItemStack is = ItemBuilder.create(Material.IRON_PICKAXE, 1, Messages.GOLDRUSH_ITEM.toString(), null); is.addUnsafeEnchantment(Enchantment.DURABILITY, 10); p.getInventory().setItem(0, is); } super.onStart(); } @Override public void preFinish() { for (Player p : g.getPlayers()) { p.getInventory().clear(); } super.preFinish(); } @Override public void onFinish() { totalmined = 0; for (Block b : rollback) { b.setType(Material.GOLD_ORE); } rollback.clear(); super.onFinish(); } @Override public void run(long ticks) { if (rollback.size() >= 30+2.5*g.getPlayers().size()) { g.getPlayers().forEach(p -> p.playSound(rollback.get(0).getLocation(), Sound.ENTITY_CHICKEN_EGG, 1f, 1f)); for (int x = 0; x < Math.round(rollback.size()/1.2); x++) { Block b = rollback.get(0); b.getWorld().playEffect(b.getLocation(), Effect.MOBSPAWNER_FLAMES, 3); b.setType(Material.GOLD_ORE); rollback.remove(0); } } super.run(ticks); } @Override public int updateStatus(ScoreboardStatus status) { status.updateLine(10, Messages.SCOREBOARD_GOLDRUSH_FIRSTLINE.toString()); status.updateLine(9, "" + scores.get(status.getPlayer())); status.updateLine(8, ""); status.updateLine(7, Messages.SCOREBOARD_GOLDRUSH_SECONDLINE.toString()); status.updateLine(6, "" + totalmined); int size = super.updateStatus(status); return size+5; } @EventHandler(priority = EventPriority.HIGHEST) public void onMove(PlayerMoveEvent e) { Player p = e.getPlayer(); if (g.getPlayers().contains(p)) { if (isStarted || g.isExperimentEnding()) { return; } if (e.getFrom().getX() != e.getTo().getX() || e.getFrom().getZ() != e.getTo().getZ()) { Location l = e.getFrom(); l.setY(e.getTo().getY()); l.setYaw(e.getTo().getYaw()); l.setPitch(e.getTo().getPitch()); e.setTo(l); } } } @EventHandler public void onBreak(BlockBreakEvent e) { Player p = e.getPlayer(); if (g.getPlayers().contains(p)) { e.setCancelled(true); if (!rollback.contains(e.getBlock()) && e.getBlock().getType() == Material.GOLD_ORE) { e.getBlock().setType(Material.COBBLESTONE); p.getInventory().addItem(new ItemStack(Material.GOLD_INGOT)); p.getWorld().playSound(p.getLocation(), Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1F, 1F); scores.put(p, scores.get(p) + 1); rollback.add(e.getBlock()); totalmined++; } } } }
In practice, to create these small 3 minigames should I do the same procedure to create a small basic minigame?
Another way you could do it is by using Enums. Create an Enum class and your base game class. Create a start method with a parameter of the game type Enum, then create some listeners which only work if the game type is a certain thing.