Problems on my Knock-out PvP Mini-Game

Discussion in 'Plugin Development' started by RamonSGomes, Dec 9, 2013.

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

    RamonSGomes

    Ok, I own a Mini-Games server and I have just added a new Mini-Game, the PvP knock-out tournament, but I've got some problems on the invisibility system.

    It works like that: 16 players join the server, after some time they got splited in pairs and are teleported to the center of the ring. Here comes the magic, players can only see their pairs so and only who stays in the watching area(in case of non-pair players remaining) can see everyone.

    But sometimes, there's a bug that hide one of the players from his opponent and it doesn't get fixed even after using a for() to show all players to each other. I think that is some bug with bukkit function to teleport players to close to each other, since I tried to give GM 1 to players in order to get some distance from each other and when it gets out of chunk view and then come back to the ring the bug gots fixed.

    Anyone have an idea about what is causing that?

    Read also: http://forums.bukkit.org/threads/problems-on-my-one-in-the-chamber-mine-game.204452/
     
    Blooder likes this.
  2. Offline

    ShredNyx

    Code?
     
  3. Offline

    RamonSGomes

    ShredNyx

    The function that put the players on the ring:
    Code:java
    1. public void putPlayersInTheRing(final Player p1, final Player p2) {
    2. in1v1.add(p1);
    3. in1v1.add(p2);
    4. p1.setGameMode(GameMode.ADVENTURE);
    5. p2.setGameMode(GameMode.ADVENTURE);
    6. Location loc1 = new Location(Bukkit.getWorld("world"), 732.5, 14.0, -135.5, 180, 0);
    7. Location loc2 = new Location(Bukkit.getWorld("world"), 732.5, 14.0, -155.5, 0, 0);
    8. p1.teleport(loc1);
    9. p2.teleport(loc2);
    10. p1.getInventory().setHeldItemSlot(0);
    11. p2.getInventory().setHeldItemSlot(0);
    12. preparePlayer(p1);
    13. preparePlayer(p2);
    14. pairs.put(p1, p2);
    15. getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
    16. public void run() {
    17. invisiblePair(p1, p2, true);
    18. }
    19. });
    20. }


    And the function that make players only visible to each other:
    Code:java
    1. public void invisiblePair(Player p1, Player p2, boolean fade) {
    2. if(fade) {
    3. for(Player p : players) {
    4. if(!p.equals(p2)) {
    5. if(p.getLocation().getY() < 16.0D) {
    6. p1.hidePlayer(p);
    7. }
    8. }
    9. if(!p.equals(p1)){
    10. if(p.getLocation().getY() < 16.0D) {
    11. p2.hidePlayer(p);
    12. }
    13. }
    14. }
    15. } else {
    16. for(Player p : players) {
    17. if(!p.equals(p2)) {
    18. p1.showPlayer(p);
    19. }
    20. if(!p.equals(p1)) {
    21. p2.showPlayer(p);
    22. }
    23. }
    24. }
    25. }


    The check for the player Y is to know if he's in the watching area.
     
  4. Offline

    onCommand

    Code:java
    1.  
    2. public void invisiblePair(Player p1, Player p2, boolean fade){
    3. if(fade){
    4. for(Player p : players){
    5. if(!p.equals(p2)){
    6. if(p.getLocation().getY() < 16.0D){
    7. p1.hidePlayer(p);
    8. }
    9.  
    10. if(!p.equals(p1)){
    11. if(p.getLocation().getY() < 16.0D) p2.hidePlayer(p);
    12. }
    13. }
    14. }
    15. }
    16.  
    17. else {
    18. for(Player p : players){
    19. if(!p.equals(p2)) p1.showPlayer(p);
    20. if(!p.equals(p1)) p2.showPlayer(p);
    21. }
    22. }
    23. }
    24.  


    I can't find anything in your code x) It looks messy as .... . Maybe you missed some Bracktes :x
     
  5. Offline

    RamonSGomes

  6. Offline

    onCommand

    Code:java
    1. public void setInvisible(Player p1, Player p2, boolean b){
    2.  
    3. if(b){
    4.  
    5. for(Player p : Bukkit.getServer().getOnlinePlayers()){
    6.  
    7. if(p != p2 && p != p1){
    8. p1.hidePlayer(p);
    9. p2.hidePlayer(p);
    10. }
    11. }
    12.  
    13. } else {
    14.  
    15. for(Player p : Bukkit.getServer().getOnlinePlayers()){
    16.  
    17. if(p != p2 && p != p1){
    18. p1.showPlayer(p);
    19. p2.showPlayer(p);
    20. }
    21. }
    22. }
    23. }


    Hm I really have no clue. This code seems fine.
    I'm sorry.
     
  7. Offline

    RamonSGomes

    onCommand
    But the question isn't really about the code, the bug seems to be a bukkit bug, something about chunks, but I don't think that it's about the cod
     
  8. Offline

    RamonSGomes

  9. Offline

    RamonSGomes

  10. Offline

    RamonSGomes

  11. Offline

    Garris0n

    This is a bug with teleports, not your code. There was a way to fix it but I really don't know how anymore.

    Edit: You could try forcing some NamedEntitySpawn packets...
     
Thread Status:
Not open for further replies.

Share This Page