use of gg.projecteden.nexus.utils.WorldGroup in project Nexus by ProjectEdenGG.
the class HomeListener method onPlayerRespawn.
@EventHandler(priority = EventPriority.HIGHEST)
public void onPlayerRespawn(PlayerRespawnEvent event) {
WorldGroup group = WorldGroup.of(event.getPlayer());
if (!Arrays.asList(WorldGroup.SURVIVAL, WorldGroup.SKYBLOCK).contains(group))
return;
HomeOwner homeOwner = new HomeService().get(event.getPlayer().getUniqueId());
Optional<Home> respawn = homeOwner.getHomes().stream().filter(Home::isRespawn).findFirst();
Optional<Home> main = homeOwner.getHome("home");
Optional<Home> first = homeOwner.getHomes().stream().findFirst();
if (respawn.isPresent())
event.setRespawnLocation(respawn.get().getLocation());
else if (main.isPresent())
event.setRespawnLocation(main.get().getLocation());
else if (first.isPresent())
event.setRespawnLocation(first.get().getLocation());
else
event.setRespawnLocation(Warps.getSpawn());
}
use of gg.projecteden.nexus.utils.WorldGroup in project Nexus by ProjectEdenGG.
the class WorldBanCommand method onWorldChange.
@EventHandler
public void onWorldChange(PlayerChangedWorldEvent event) {
Player player = event.getPlayer();
WorldBan worldBan = new WorldBanService().get(player);
WorldGroup worldGroup = WorldGroup.of(player);
if (worldBan.getBans().contains(worldGroup))
removeFromBannedWorld(player, worldGroup);
}
use of gg.projecteden.nexus.utils.WorldGroup in project Nexus by ProjectEdenGG.
the class KitCommand method kit.
@Path("<kit>")
void kit(Kit kit) {
WorldGroup worldGroup = worldGroup();
if (worldGroup != WorldGroup.SURVIVAL && worldGroup != WorldGroup.CREATIVE)
error("Kits may only be claimed in survival and creative");
if (!player().hasPermission("kit." + kit.getName()))
error("You do not have permission to use this kit");
CooldownService service = new CooldownService();
if (!service.check(player(), "kit-" + kit.getName(), kit.getDelay()))
error("You must wait " + service.getDiff(player(), "kit-" + kit.getName()) + " before you can receive that kit again");
PlayerUtils.giveItems(player(), Arrays.asList(kit.getItems()));
send(PREFIX + "You have been given the &e" + StringUtils.camelCase(kit.getName()) + " &3kit");
}
use of gg.projecteden.nexus.utils.WorldGroup in project Nexus by ProjectEdenGG.
the class MailCommand method onWorldChange.
@EventHandler
public void onWorldChange(PlayerChangedWorldEvent event) {
Player player = event.getPlayer();
WorldGroup worldGroup = WorldGroup.of(player);
Mailer mailer = service.get(player);
List<Mail> mails = new ArrayList<>(mailer.getMail(worldGroup));
if (isNullOrEmpty(mails))
return;
if (!new CooldownService().check(player, "youhavemail", TickTime.MINUTE.x(5)))
return;
mailer.sendNotification();
}
use of gg.projecteden.nexus.utils.WorldGroup in project Nexus by ProjectEdenGG.
the class WorldBanCommand method worldBan.
@Path("<player> [worldGroup]")
void worldBan(OfflinePlayer player, WorldGroup worldGroup) {
WorldBan worldBan = service.get(player);
if (worldGroup == null) {
if (worldBan.getBans().size() == 0)
error(player.getName() + " is not world banned");
else
send(PREFIX + "&e" + player.getName() + "&7 - &3" + String.join("&e, &3", worldBan.getBanNames()));
} else {
if (worldGroup.equals(WorldGroup.SURVIVAL) || worldGroup.equals(WorldGroup.UNKNOWN))
error("Cannot world ban from " + worldGroup);
List<WorldGroup> worldList = worldBan.getBans();
if (worldList.contains(worldGroup))
error(player.getName() + " is already banned from " + worldGroup);
worldList.add(worldGroup);
service.save(worldBan);
String message = "&a" + name() + " &fhas world banned &a" + player.getName() + " &ffrom &a" + worldGroup;
Broadcast.log().prefix("Justice").message(message).send();
if (player.isOnline() && player.getPlayer() != null)
if (WorldGroup.of(player.getPlayer()).equals(worldGroup)) {
if (player.getPlayer().getVehicle() != null)
player.getPlayer().getVehicle().removePassenger(player.getPlayer());
removeFromBannedWorld(player.getPlayer(), worldGroup);
}
}
}
Aggregations