1. Welcome to the Brawl website! Feel free to look around our forums. Join our growing community by typing /register in-game!

Idea Add this :D

Discussion in 'MC-WarZ' started by BeastyBoo, Aug 2, 2017.

Thread Status:
Please be aware that this thread is more than 30 days old. Do not post unless the topic can still be discussed. Read more...
  1. BeastyBoo

    BeastyBoo Insert custom title here

    Joined:
    May 10, 2015
    Messages:
    349
    Ratings:
    +21
    Code:
    package com.beastcraft3.wut;
    
    import java.util.HashSet;
    import java.util.UUID;
    
    import org.bukkit.entity.Player;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.player.PlayerJoinEvent;
    import org.bukkit.event.player.PlayerQuitEvent;
    
    public class Brawl implements Listener{
        
        private boolean isBrawlPlayable;
        private HashSet<UUID> players = new HashSet<UUID>();
        private Main main;
        
        
        @EventHandler
        public void onjoin(PlayerJoinEvent e){
            
            Player p = e.getPlayer();
            
            if(!players.contains(p.getUniqueId())){
                players.add(p.getUniqueId());
                
                p.sendMessage("Added... There is now: " + String.valueOf(players.size()) + " players online.");
                int players_online = main.getConfig().getInt("players_online");
                main.getConfig().set("players_online", players_online + 1);
                main.saveConfig();
                
                brawlIsPlayable(p);
                
            } else {
                
                p.sendMessage("Already inside. ***** wut?");
                
            }
            
        }
        
        @EventHandler
        public void onLeave(PlayerQuitEvent e){
            Player p = e.getPlayer();
            
            if(players.contains(p.getUniqueId())) {
                players.remove(p.getUniqueId());
                int players_online = Integer.valueOf(main.getConfig().getInt("players_online"));
                main.getConfig().set("players_online", players_online - 1);
                main.saveConfig();
            }
            
        }
        
        public void brawlIsPlayable(Player p){
            if(players.size() >= 300){
                
                setBrawlPlayable(true);
                p.sendMessage("Brawl is playable atm");
                
            } else {
                
                setBrawlPlayable(false);
                p.sendMessage("Brawl is not playable atm");
                
            }
        }
        
    
    
        public boolean isBrawlPlayable() {
            return isBrawlPlayable;
        }
    
    
        public void setBrawlPlayable(boolean isBrawlPlayable) {
            this.isBrawlPlayable = isBrawlPlayable;
        }
        
        
    
    }
    
    dunt complain, made it in like 5 min cuz bored
     
  2. Carnotauros

    Carnotauros Raid & Events Manager

    Joined:
    Jun 13, 2015
    Messages:
    1,496
    Ratings:
    +595
    Discord:
    Leon#9397
    What's that? :0
    Apply for dev already
     
  3. Paul

    Paul Well-Known Member

    Joined:
    Aug 21, 2013
    Messages:
    1,987
    Ratings:
    +904
    why do you have the players online stored in a file where it can easily be accessed in memory lol.

    also no events are registered so none of that code will even run to begin with.

    so inefficient and ironic xd
     
    • Winner Winner x 1
  4. BeastyBoo

    BeastyBoo Insert custom title here

    Joined:
    May 10, 2015
    Messages:
    349
    Ratings:
    +21
    Yeah, no point having the hashset really when I store it in the config(incase of reload), and I didnt bother to register it since thats just a random class in a premade plugin and I dont actually want the plugin to run this class.

    And I made it in like 5 min for a joke against brawl since its unplayable with a low playerbase at times :smile:
     
  5. Paul

    Paul Well-Known Member

    Joined:
    Aug 21, 2013
    Messages:
    1,987
    Ratings:
    +904
    ik, and the irony is hilarious.
     
    • Like Like x 1
  6. BeastyBoo

    BeastyBoo Insert custom title here

    Joined:
    May 10, 2015
    Messages:
    349
    Ratings:
    +21
    [​IMG]
     
Thread Status:
Please be aware that this thread is more than 30 days old. Do not post unless the topic can still be discussed. Read more...