Exemplo n.º 1
0
 /**
  * Starts the test for the player.
  *
  * @param player
  */
 public void startTest(Player player) {
   if (plugin.getTest(player) != null) return;
   plugin.getData().set(player.getUniqueId() + ".current.name", name);
   plugin.getData().set(player.getUniqueId() + ".current.chances", maxMistakes);
   plugin
       .getData()
       .set(
           player.getUniqueId() + ".location",
           player.getLocation().getX()
               + ";"
               + player.getLocation().getY()
               + ";"
               + player.getLocation().getZ()
               + ";"
               + player.getLocation().getWorld().getName()
               + ";"
               + player.getLocation().getYaw()
               + ";"
               + player.getLocation().getPitch());
   Category first = categories.get(0);
   players.put(player.getUniqueId(), first);
   chances.put(player.getUniqueId(), maxMistakes);
   if (messageStart != null) player.sendMessage(messageStart.replace('&', '§'));
   first.addPlayer(player);
   new Saver(plugin);
 }
Exemplo n.º 2
0
 /** Resumes the test for the player. */
 public void resumeTest(Player player) {
   if (plugin.getActiveTest(player) != null) return;
   Category first = categories.get(0);
   plugin.getData().set(player.getUniqueId() + ".paused", null);
   paused.remove(player.getUniqueId());
   players.put(player.getUniqueId(), first);
   plugin.getData().set(player.getUniqueId() + ".current.name", name);
   plugin
       .getData()
       .set(player.getUniqueId() + ".current.chances", chances.get(player.getUniqueId()));
   if (messageResume != null) player.sendMessage(messageResume.replace('&', '§'));
   first.addPlayer(player);
   new Saver(plugin);
 }
Exemplo n.º 3
0
 /** Handles the correct answer for this player. */
 public void incorrect(Player player) {
   Category current = players.get(player.getUniqueId());
   current.removePlayer(player);
   int index = categories.indexOf(current);
   Integer chance = chances.get(player.getUniqueId());
   chance--;
   plugin.getData().set(player.getUniqueId() + ".current.chances", chance);
   if (chance <= 0) {
     players.remove(player.getUniqueId());
     chances.remove(player.getUniqueId());
     fail(player);
   } else {
     chances.put(player.getUniqueId(), chance);
     switch (onMistake) {
       case NEXT:
         Category next = categories.get(index + 1);
         players.put(player.getUniqueId(), next);
         next.addPlayer(player);
         break;
       case NOTHING:
         current.addPlayer(player);
         break;
       case RESTART:
         Category first = categories.get(0);
         players.put(player.getUniqueId(), first);
         first.addPlayer(player);
         break;
       case PAUSE:
         players.remove(player.getUniqueId());
         paused.add(player.getUniqueId());
         pause(player);
         break;
     }
   }
   new Saver(plugin);
 }
Exemplo n.º 4
0
 /** Handles the correct answer for this player. */
 public void correct(Player player) {
   Category current = players.get(player.getUniqueId());
   current.removePlayer(player);
   int index = categories.indexOf(current);
   if (index + 1 == categories.size()) {
     players.remove(player.getUniqueId());
     chances.remove(player.getUniqueId());
     pass(player);
   } else {
     Category next = categories.get(index + 1);
     players.put(player.getUniqueId(), next);
     next.addPlayer(player);
   }
   new Saver(plugin);
 }