예제 #1
0
 public void setLastHostname(String ip) {
   lasthostname = ip;
   final JsonConfig conf = getPlayerConfig();
   conf.set("hostname", ip);
   conf.save();
   save();
 }
예제 #2
0
  public void ban(Long time, Text.Literal reason, CommandSource source) {
    JsonConfig conf = getPlayerConfig();
    if (time == null || time == 0L) {
      time = -1L;
    }
    if (reason == null) {
      reason = r.mes("banDefaultReason");
    }
    if (time >= 1) {
      time = time + System.currentTimeMillis();
    }
    conf.set("banned", true);
    conf.set("bantime", time);
    conf.set("banreason", reason);
    conf.save();
    BanData d = getPlayer().getBanData();

    if (time != -1L) {
      d.bans()
          .get()
          .add(
              (Ban.User)
                  Bans.builder()
                      .user(getPlayer())
                      .expirationDate(new Date(time))
                      .reason(reason)
                      .source(source)
                      .build());
    } else {
      d.bans()
          .get()
          .add((Ban.User) Bans.builder().user(getPlayer()).reason(reason).source(source).build());
    }
    save();
  }
예제 #3
0
 public void setLastLocation(RLocation loc) {
   lastLocation = loc;
   JsonConfig conf = getPlayerConfig();
   conf.set("lastLocation", loc == null ? null : LocationUtil.convertLocationToString(loc));
   conf.save();
   save();
 }
예제 #4
0
 public void setLastIp(String ip) {
   lastip = ip;
   final JsonConfig conf = getPlayerConfig();
   conf.set("ip", ip);
   conf.save();
   save();
 }
예제 #5
0
 public void updateLastConnectMillis(Long millis) {
   lastconnect = millis;
   final JsonConfig conf = getPlayerConfig();
   conf.set("lastconnect", millis);
   conf.save();
   save();
 }
예제 #6
0
 public void unjail() {
   jailed = false;
   jail = null;
   jailtime = null;
   JsonConfig conf = getPlayerConfig();
   conf.set("jailed", false);
   conf.set("jail", null);
   conf.set("jailtime", null);
   conf.save();
   save();
   if (tpspawn && getOnlinePlayer() != null) {
     if (bammerbom.ultimatecore.spongeapi.api.UC.getPlayer(getPlayer()).getSpawn(false) == null) {
       LocationUtil.teleport(
           getOnlinePlayer(),
           getOnlinePlayer().getWorld().getSpawnLocation(),
           Cause.of("unjail"),
           false,
           false);
     } else {
       LocationUtil.teleport(
           getOnlinePlayer(),
           bammerbom.ultimatecore.spongeapi.api.UC.getPlayer(getPlayer()).getSpawn(false),
           Cause.of("unjail"),
           false,
           false);
     }
   }
 }
예제 #7
0
 public void updateLastConnectMillis() {
   lastconnect = System.currentTimeMillis();
   final JsonConfig conf = getPlayerConfig();
   conf.set("lastconnect", System.currentTimeMillis());
   conf.save();
   save();
 }
예제 #8
0
 public void setReply(Player pl) {
   reply = pl.getUniqueId();
   JsonConfig conf = getPlayerConfig();
   conf.set("reply", pl.getUniqueId().toString());
   conf.save();
   save();
 }
예제 #9
0
 public void setSpy(Boolean sp) {
   spy = sp;
   JsonConfig conf = getPlayerConfig();
   conf.set("spy", sp);
   conf.save();
   save();
 }
예제 #10
0
 public HashMap<String, RLocation> getHomes() {
   if (homes != null) {
     return homes;
   }
   homes = new HashMap<>();
   JsonConfig conf = getPlayerConfig();
   if (!conf.contains("homes")) {
     return homes;
   }
   for (String hname : conf.listKeys("homes", false)) {
     try {
       homes.put(hname, LocationUtil.convertStringToLocation(conf.getString("homes." + hname)));
     } catch (Exception ex) {
       r.log(
           r.negative
               + "Home "
               + getPlayer().getName()
               + ":"
               + hname
               + " has been removed. (Invalid location)");
     }
   }
   save();
   return homes;
 }
예제 #11
0
 public void setTeleportEnabled(Boolean tpe) {
   teleportEnabled = tpe;
   JsonConfig conf = getPlayerConfig();
   conf.set("teleportenabled", tpe);
   conf.save();
   save();
 }
예제 #12
0
 public Inventory getLastInventory() {
   JsonConfig conf = getPlayerConfig();
   if (!conf.contains("lastinventory")) {
     return null;
   }
   return InventoryUtil.convertStringToInventory(
       conf.getString("lastinventory"), r.mes("inventoryOfflineTitle", "%Name", name));
 }
예제 #13
0
 public void setHomes(HashMap<String, RLocation> nh) {
   homes = nh;
   save();
   JsonConfig conf = getPlayerConfig();
   conf.set("homes", null);
   for (String s : nh.keySet()) {
     conf.set("homes." + s.toLowerCase(), LocationUtil.convertLocationToString(nh.get(s)));
   }
   conf.save();
 }
예제 #14
0
 public void unban() {
   save();
   JsonConfig conf = getPlayerConfig();
   conf.set("banned", false);
   conf.set("bantime", null);
   conf.set("banreason", null);
   conf.save();
   BanData d = getPlayer().getBanData();
   while (!d.bans().get().isEmpty()) {
     d.bans().get().remove(0);
   }
   getPlayer().offer(d);
 }
예제 #15
0
 public boolean hasPowertool(ItemType mat) {
   if (pts == null) {
     JsonConfig data = getPlayerConfig();
     pts = new HashMap<>();
     if (data.contains("powertool")) {
       for (String s : data.listKeys("powertool", false)) {
         ArrayList<String> l = (ArrayList<String>) data.getStringList("powertool." + s);
         pts.put(ItemDatabase.getItem(s).getItem(), l);
       }
     }
     save();
   }
   return pts.containsKey(mat);
 }
예제 #16
0
 public void jail(String n, Long l) {
   jailed = true;
   jail = n;
   if (l >= 1) {
     l = l + System.currentTimeMillis();
   }
   jailtime = l;
   JsonConfig conf = getPlayerConfig();
   conf.set("jailed", true);
   conf.set("jail", n);
   conf.set("jailtime", l == null ? 0L : l);
   conf.save();
   save();
 }
예제 #17
0
 public void setFrozen(Boolean fr, Long time) {
   JsonConfig conf = getPlayerConfig();
   if (freezetime == null || freezetime == 0L) {
     freezetime = -1L;
   }
   if (time >= 1) {
     time = time + System.currentTimeMillis();
   }
   conf.set("freeze", fr);
   conf.set("freezetime", time);
   conf.save();
   freeze = fr;
   freezetime = fr ? time : 0L;
   save();
 }
예제 #18
0
 public void setMuted(Boolean fr, Long time) {
   JsonConfig conf = getPlayerConfig();
   if (mutetime == null || mutetime == 0L) {
     mutetime = -1L;
   }
   if (time >= 1) {
     time = time + System.currentTimeMillis();
   }
   conf.set("mute", fr);
   conf.set("mutetime", time);
   conf.save();
   mute = fr;
   mutetime = fr ? time : -1L;
   save();
 }
예제 #19
0
 public void setDeaf(Boolean dea, Long time) {
   JsonConfig conf = getPlayerConfig();
   if (deaftime == null || deaftime == 0L) {
     deaftime = -1L;
   }
   if (time >= 1) {
     time = time + System.currentTimeMillis();
   }
   conf.set("deaf", dea);
   conf.set("deaftime", time);
   conf.save();
   deaf = dea;
   deaftime = deaf ? time : 0L;
   save();
 }
예제 #20
0
 public void setGod(Boolean fr, Long time) {
   JsonConfig conf = getPlayerConfig();
   if (godtime == null || godtime == 0L) {
     godtime = -1L;
   }
   if (time >= 1) {
     time = time + System.currentTimeMillis();
   }
   conf.set("god", fr);
   conf.set("godtime", time);
   conf.save();
   god = fr;
   godtime = fr ? time : 0L;
   save();
 }
예제 #21
0
 public String getLastHostname() {
   if (lasthostname != null) {
     return lasthostname;
   }
   final JsonConfig conf = getPlayerConfig();
   if (conf.get("hostname") != null) {
     lastip = conf.getString("hostname");
     save();
     return lastip;
   } else {
     if (getPlayer().isOnline()) {
       setLastHostname(getOnlinePlayer().getConnection().getAddress().getHostName());
       return lastip;
     }
     return null;
   }
 }
예제 #22
0
 public void setNick(Text.Literal str) {
   nickname = str == null ? null : str + TextColors.RESET;
   save();
   if (str != null) {
     if (getPlayer().isOnline()) {
       getOnlinePlayer()
           .offer(
               getOnlinePlayer().getDisplayNameData().setDisplayName(nickname.replace("&y", "")));
     }
   } else {
     if (getPlayer().isOnline()) {
       getPlayer().getPlayer().setDisplayName(getPlayer().getPlayer().getName());
     }
   }
   JsonConfig data = getPlayerConfig();
   data.set("nick", str);
   data.save(UltimateFileLoader.getPlayerFile(getPlayer()));
 }
예제 #23
0
 public void setVanish(Boolean fr, Long time) {
   JsonConfig conf = getPlayerConfig();
   if (vanishtime == null || vanishtime == 0L) {
     vanishtime = -1L;
   }
   if (time >= 1) {
     time = time + System.currentTimeMillis();
   }
   conf.set("vanish", fr);
   conf.set("vanishtime", time);
   conf.save();
   vanish = fr;
   vanishtime = fr ? time : 0L;
   if (getOnlinePlayer() != null) {
     getOnlinePlayer().offer(Keys.INVISIBLE, true);
   }
   save();
 }
예제 #24
0
 public String getLastIp() {
   if (lastip != null) {
     return lastip;
   }
   final JsonConfig conf = getPlayerConfig();
   if (conf.get("ip") != null) {
     lastip = conf.getString("ip");
     save();
     return lastip;
   } else {
     if (getPlayer().isOnline()) {
       setLastIp(
           getOnlinePlayer().getConnection().getAddress().toString().split("/")[1].split(":")[0]);
       return lastip;
     }
     return null;
   }
 }
예제 #25
0
 public Text.Literal getNick() {
   if (nickname != null) {
     return nickname;
   }
   JsonConfig data = getPlayerConfig();
   if (data.get("nick") == null) {
     return null;
   }
   String nick = r.translateAlternateColorCodes('&', data.getString("nick"));
   if (getPlayer().isOnline()) {
     getOnlinePlayer()
         .offer(getOnlinePlayer().getDisplayNameData().setDisplayName(nick.replace("&y", "")));
   }
   if (getPlayer().isOnline()
       && r.perm((CommandSource) getPlayer(), "uc.chat.rainbow", false, false)) {
     nick = nick.replaceAll("&y", r.getRandomTextColors() + "");
   }
   nickname = nick + TextColors.RESET;
   save();
   return nick + TextColors.RESET;
 }
예제 #26
0
 public long getLastConnectMillis() {
   if (lastconnect != null) {
     return lastconnect;
   }
   final JsonConfig conf = getPlayerConfig();
   if (conf.get("lastconnect") != null) {
     lastconnect = conf.getLong("lastconnect");
     save();
     return lastconnect;
   } else {
     lastconnect =
         getPlayer().getOrCreate(CatalogEntityData.JOIN_DATA).get().lastPlayed().get().getTime();
     save();
     return getPlayer()
         .getOrCreate(CatalogEntityData.JOIN_DATA)
         .get()
         .lastPlayed()
         .get()
         .getTime();
   }
 }
예제 #27
0
 public void clearPowertool(ItemType mat) {
   if (pts == null) {
     JsonConfig data = getPlayerConfig();
     pts = new HashMap<>();
     if (data.contains("powertool")) {
       for (String s : data.listKeys("powertool", false)) {
         ArrayList<String> l = (ArrayList<String>) data.getStringList("powertool." + s);
         pts.put(ItemDatabase.getItem(s).getItem(), l);
       }
     }
   }
   pts.remove(mat);
   JsonConfig data = getPlayerConfig();
   data.set("powertool." + mat.toString(), null);
   data.save();
   save();
 }
예제 #28
0
 public RLocation getSpawn(Boolean firstjoin) {
   JsonConfig conf = new JsonConfig(UltimateFileLoader.Dspawns);
   String loc;
   Player p = r.searchPlayer(uuid);
   Boolean world = conf.contains("worlds.world." + p.getWorld().getName() + ".global");
   String world_ =
       world ? conf.getString("worlds.world." + p.getWorld().getName() + ".global") : null;
   Boolean group =
       r.getVault() != null
           && r.getVault().getPermission() != null
           && r.getVault().getPermission().getPrimaryGroup(p) != null
           && conf.contains("global.group." + r.getVault().getPermission().getPrimaryGroup(p));
   String group_ =
       r.getVault() != null
               && r.getVault().getPermission() != null
               && r.getVault().getPermission().getPrimaryGroup(p) != null
           ? (group
               ? conf.getString("global.group." + r.getVault().getPermission().getPrimaryGroup(p))
               : null)
           : null;
   Boolean gw =
       r.getVault() != null
           && r.getVault().getPermission() != null
           && r.getVault().getPermission().getPrimaryGroup(p) != null
           && conf.contains(
               "worlds.world."
                   + p.getWorld().getName()
                   + ".group."
                   + r.getVault().getPermission().getPrimaryGroup(p));
   String gw_ =
       r.getVault() != null
               && r.getVault().getPermission() != null
               && r.getVault().getPermission().getPrimaryGroup(p) != null
           ? conf.getString(
               "worlds.world."
                   + p.getWorld().getName()
                   + ".group."
                   + r.getVault().getPermission().getPrimaryGroup(p))
           : null;
   if (firstjoin && conf.contains("global.firstjoin")) {
     loc = conf.getString("global.firstjoin");
   } else if (gw) {
     loc = gw_;
   } else if (world && group) {
     if (r.getCnfg().getBoolean("Command.Spawn.WorldOrGroup")) {
       loc = world_;
     } else {
       loc = group_;
     }
   } else if (world) {
     loc = world_;
   } else if (group) {
     loc = group_;
   } else if (conf.contains("global")) {
     loc = conf.getString("global");
   } else {
     return null;
   }
   return LocationUtil.convertStringToLocation(loc);
 }
예제 #29
0
 public void updateLastInventory() {
   JsonConfig conf = getPlayerConfig();
   conf.set(
       "lastinventory", InventoryUtil.convertInventoryToString(getOnlinePlayer().getInventory()));
   conf.save();
 }