Advertisement
Guest User

Untitled

a guest
Nov 26th, 2014
176
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 4.46 KB | None | 0 0
  1. package com.sean.game.model.player;
  2.  
  3. import java.io.Serializable;
  4.  
  5. import com.sean.game.net.packet.codec.context.VarBitContext;
  6. import com.sean.game.net.packet.codec.encoders.VarBitEncoder;
  7.  
  8. /**
  9.  *
  10.  * @author Dennis
  11.  *
  12.  */
  13. public final class Preferences implements Serializable {
  14.  
  15.     /**
  16.      * The serial version UID.
  17.      */
  18.     private static final long serialVersionUID = -1014769258411933653L;
  19.  
  20.     /**
  21.      * The player.
  22.      */
  23.     private transient Player player;
  24.  
  25.     /**
  26.      * Whether the player accepts aid.
  27.      */
  28.     private boolean acceptAid;
  29.    
  30.     /**
  31.      * Whether the players profanity filter is enabled.
  32.      */
  33.     private boolean profanityFilter;
  34.    
  35.     /**
  36.      * Whether the chat effects are enabled.
  37.      */
  38.     private boolean chatEffects;
  39.    
  40.     /**
  41.      * Whether the player is using 2 mouse buttons.
  42.      */
  43.     private boolean mouseButtons;
  44.    
  45.     /**
  46.      * Whether the player has a right click report option.
  47.      */
  48.     private boolean rightClickReport;
  49.  
  50.     public Preferences(Player player) {
  51.         this.player = player;
  52.         acceptAid = true;
  53.         profanityFilter = true;
  54.         chatEffects = true;
  55.         mouseButtons = true;
  56.     }
  57.    
  58.     /**
  59.      * Refreshes the preferences.
  60.      */
  61.     public void refresh() {
  62.         refreshAcceptAid();
  63.         refreshProfanityFilter();
  64.         refreshChatEffects();
  65.         refreshMouseButtons();
  66.         refreshRightClickReport();
  67.     }
  68.  
  69.     /**
  70.      * @return the acceptAid
  71.      */
  72.     public boolean isAcceptAid() {
  73.         return acceptAid;
  74.     }
  75.  
  76.     /**
  77.      * @param acceptAid
  78.      *            the acceptAid to set
  79.      */
  80.     public void setAcceptAid(boolean acceptAid) {
  81.         this.acceptAid = acceptAid;
  82.     }
  83.  
  84.     /**
  85.      * Toggles the accept aid.
  86.      */
  87.     public void toggleAcceptAid() {
  88.         this.acceptAid = !acceptAid;
  89.         refreshAcceptAid();
  90.     }
  91.  
  92.     /**
  93.      * Refreshes the accept aid option.
  94.      */
  95.     public void refreshAcceptAid() {
  96.         player.getVarsManager().sendVar(427, acceptAid ? 1 : 0);
  97.     }
  98.  
  99.     /**
  100.      * @return the profanityFilter
  101.      */
  102.     public boolean isProfanityFilter() {
  103.         return profanityFilter;
  104.     }
  105.  
  106.     /**
  107.      * @param profanityFilter the profanityFilter to set
  108.      */
  109.     public void setProfanityFilter(boolean profanityFilter) {
  110.         this.profanityFilter = profanityFilter;
  111.     }
  112.    
  113.     /**
  114.      * Toggles the profanity filter.
  115.      */
  116.     public void toggleProfanityFilter() {
  117.         this.profanityFilter = !profanityFilter;
  118.         refreshProfanityFilter();
  119.     }
  120.    
  121.     /**
  122.      * Refreshes the profanity filter option.
  123.      */
  124.     public void refreshProfanityFilter() {
  125.         player.encode(VarBitEncoder.class, new VarBitContext(8780, profanityFilter ? 0 : 1));
  126.     }
  127.  
  128.     /**
  129.      * @return the chatEffects
  130.      */
  131.     public boolean isChatEffects() {
  132.         return chatEffects;
  133.     }
  134.  
  135.     /**
  136.      * @param chatEffects the chatEffects to set
  137.      */
  138.     public void setChatEffects(boolean chatEffects) {
  139.         this.chatEffects = chatEffects;
  140.     }
  141.    
  142.     /**
  143.      * Toggles the chat effects.
  144.      */
  145.     public void toggleChatEffects() {
  146.         this.chatEffects = !chatEffects;
  147.         refreshChatEffects();
  148.     }
  149.    
  150.     /**
  151.      * Refreshes the chat effects option.
  152.      */
  153.     public void refreshChatEffects() {
  154.         player.getVarsManager().sendVar(171, chatEffects ? 0 : 1);
  155.     }
  156.  
  157.     /**
  158.      * @return the mouseButtons
  159.      */
  160.     public boolean isMouseButtons() {
  161.         return mouseButtons;
  162.     }
  163.  
  164.     /**
  165.      * @param mouseButtons the mouseButtons to set
  166.      */
  167.     public void setMouseButtons(boolean mouseButtons) {
  168.         this.mouseButtons = mouseButtons;
  169.     }
  170.    
  171.     /**
  172.      * Toggles the mouse buttons.
  173.      */
  174.     public void toggleMouseButtons() {
  175.         this.mouseButtons = !mouseButtons;
  176.         refreshMouseButtons();
  177.     }
  178.    
  179.     /**
  180.      * Refreshes the mouse buttons option.
  181.      */
  182.     public void refreshMouseButtons() {
  183.         player.getVarsManager().sendVar(170, mouseButtons ? 0 : 1);
  184.     }
  185.  
  186.     /**
  187.      * @return the rightClickReport
  188.      */
  189.     public boolean isRightClickReport() {
  190.         return rightClickReport;
  191.     }
  192.  
  193.     /**
  194.      * @param rightClickReport the rightClickReport to set
  195.      */
  196.     public void setRightClickReport(boolean rightClickReport) {
  197.         this.rightClickReport = rightClickReport;
  198.     }
  199.    
  200.     /**
  201.      * Toggles the right click report.
  202.      */
  203.     public void toggleRightClickReport() {
  204.         this.rightClickReport = !rightClickReport;
  205.         refreshRightClickReport();
  206.     }
  207.    
  208.     /**
  209.      * Refreshes the right click report.
  210.      */
  211.     public void refreshRightClickReport() {
  212.         player.sendPlayerOption(rightClickReport ? "Report" : "null", 6, false);
  213.         // TODO config
  214.     }
  215.  
  216.     /**
  217.      * @return the player
  218.      */
  219.     public Player getPlayer() {
  220.         return player;
  221.     }
  222.  
  223.     /**
  224.      * @param player
  225.      *            the player to set
  226.      */
  227.     public void setPlayer(Player player) {
  228.         this.player = player;
  229.     }
  230.  
  231. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement