CheatingOffenseEntry.java
Upload User: gwt600
Upload Date: 2021-06-03
Package Size: 704k
Code Size: 4k
Category:

Games

Development Platform:

Java

  1. /*
  2. This file is part of the OdinMS Maple Story Server
  3. Copyright (C) 2008 Patrick Huy <patrick.huy@frz.cc> 
  4. Matthias Butz <matze@odinms.de>
  5. Jan Christian Meyer <vimes@odinms.de>
  6. This program is free software: you can redistribute it and/or modify
  7. it under the terms of the GNU Affero General Public License version 3
  8. as published by the Free Software Foundation. You may not use, modify
  9. or distribute this program under any other version of the
  10. GNU Affero General Public License.
  11. This program is distributed in the hope that it will be useful,
  12. but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14. GNU Affero General Public License for more details.
  15. You should have received a copy of the GNU Affero General Public License
  16. along with this program.  If not, see <http://www.gnu.org/licenses/>.
  17.  */
  18. package net.sf.odinms.client.anticheat;
  19. import net.sf.odinms.client.MapleCharacter;
  20. public class CheatingOffenseEntry {
  21.     private CheatingOffense offense;
  22.     private int count = 0;
  23.     private MapleCharacter chrfor;
  24.     private long lastOffense;
  25.     private long firstOffense;
  26.     private String param;
  27.     private int dbid = -1;
  28.     public CheatingOffenseEntry(CheatingOffense offense, MapleCharacter chrfor) {
  29.         super();
  30.         this.offense = offense;
  31.         this.chrfor = chrfor;
  32.         firstOffense = System.currentTimeMillis();
  33.     }
  34.     public CheatingOffense getOffense() {
  35.         return offense;
  36.     }
  37.     public int getCount() {
  38.         return count;
  39.     }
  40.     public MapleCharacter getChrfor() {
  41.         return chrfor;
  42.     }
  43.     public void incrementCount() {
  44.         this.count++;
  45.         lastOffense = System.currentTimeMillis();
  46.     }
  47.     public boolean isExpired() {
  48.         if (lastOffense < (System.currentTimeMillis() - offense.getValidityDuration())) {
  49.             return true;
  50.         }
  51.         return false;
  52.     }
  53.     public int getPoints() {
  54.         return count * offense.getPoints();
  55.     }
  56.     public String getParam() {
  57.         return param;
  58.     }
  59.     public void setParam(String param) {
  60.         this.param = param;
  61.     }
  62.     public long getLastOffenseTime() {
  63.         return lastOffense;
  64.     }
  65.     public int getDbId() {
  66.         return dbid;
  67.     }
  68.     public void setDbId(int dbid) {
  69.         this.dbid = dbid;
  70.     }
  71.     @Override
  72.     public int hashCode() {
  73.         final int prime = 31;
  74.         int result = 1;
  75.         result = prime * result + ((chrfor == null) ? 0 : chrfor.getId());
  76.         result = prime * result + ((offense == null) ? 0 : offense.hashCode());
  77.         result = prime * result + Long.valueOf(firstOffense).hashCode();
  78.         return result;
  79.     }
  80.     @Override
  81.     public boolean equals(Object obj) {
  82.         if (this == obj) {
  83.             return true;
  84.         }
  85.         if (obj == null) {
  86.             return false;
  87.         }
  88.         if (getClass() != obj.getClass()) {
  89.             return false;
  90.         }
  91.         final CheatingOffenseEntry other = (CheatingOffenseEntry) obj;
  92.         if (chrfor == null) {
  93.             if (other.chrfor != null) {
  94.                 return false;
  95.             }
  96.         } else if (chrfor.getId() != other.chrfor.getId()) {
  97.             return false;
  98.         }
  99.         if (offense == null) {
  100.             if (other.offense != null) {
  101.                 return false;
  102.             }
  103.         } else if (!offense.equals(other.offense)) {
  104.             return false;
  105.         }
  106.         if (other.firstOffense != firstOffense) {
  107.             return false;
  108.         }
  109.         return true;
  110.     }
  111. }