use of com.earth2me.essentials.Kit in project Essentials by drtshock.
the class SignKit method onSignInteract.
@Override
protected boolean onSignInteract(final ISign sign, final User player, final String username, final IEssentials ess) throws SignException, ChargeException {
final String kitName = sign.getLine(1).toLowerCase(Locale.ENGLISH).trim();
final String group = sign.getLine(2).trim();
if ((!group.isEmpty() && ("§2Everyone".equals(group) || player.inGroup(group))) || (group.isEmpty() && (player.isAuthorized("essentials.kits." + kitName)))) {
final Trade charge = getTrade(sign, 3, ess);
charge.isAffordableFor(player);
try {
final Kit kit = new Kit(kitName, ess);
kit.checkDelay(player);
kit.setTime(player);
kit.expandItems(player);
charge.charge(player);
Trade.log("Sign", "Kit", "Interact", username, null, username, charge, sign.getBlock().getLocation(), ess);
} catch (NoChargeException ex) {
return false;
} catch (Exception ex) {
throw new SignException(ex.getMessage(), ex);
}
return true;
} else {
if (group.isEmpty()) {
throw new SignException(tl("noKitPermission", "essentials.kits." + kitName));
} else {
throw new SignException(tl("noKitGroup", group));
}
}
}
use of com.earth2me.essentials.Kit in project Essentials by drtshock.
the class Commandshowkit method run.
@Override
public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception {
if (args.length != 1) {
throw new NotEnoughArgumentsException();
}
final String[] kits = args[0].toLowerCase(Locale.ENGLISH).split(",");
for (final String kitName : kits) {
Kit kit = new Kit(kitName, ess);
user.sendMessage(tl("kitContains", kitName));
for (String s : kit.getItems()) {
user.sendMessage(tl("kitItem", s));
}
}
}
use of com.earth2me.essentials.Kit in project Essentials by EssentialsX.
the class SignKit method onSignInteract.
@Override
protected boolean onSignInteract(final ISign sign, final User player, final String username, final IEssentials ess) throws SignException, ChargeException {
final String kitName = sign.getLine(1).toLowerCase(Locale.ENGLISH).trim();
final String group = sign.getLine(2).trim();
if ((!group.isEmpty() && ("§2Everyone".equals(group) || player.inGroup(group))) || (group.isEmpty() && (player.isAuthorized("essentials.kits." + kitName)))) {
final Trade charge = getTrade(sign, 3, ess);
charge.isAffordableFor(player);
try {
final Kit kit = new Kit(kitName, ess);
kit.checkDelay(player);
kit.setTime(player);
kit.expandItems(player);
charge.charge(player);
Trade.log("Sign", "Kit", "Interact", username, null, username, charge, sign.getBlock().getLocation(), ess);
} catch (NoChargeException ex) {
return false;
} catch (Exception ex) {
throw new SignException(ex.getMessage(), ex);
}
return true;
} else {
if (group.isEmpty()) {
throw new SignException(tl("noKitPermission", "essentials.kits." + kitName));
} else {
throw new SignException(tl("noKitGroup", group));
}
}
}
use of com.earth2me.essentials.Kit in project Essentials by drtshock.
the class Commandkit method run.
@Override
public void run(final Server server, final CommandSource sender, final String commandLabel, final String[] args) throws Exception {
if (args.length < 2) {
final String kitList = ess.getKits().listKits(ess, null);
sender.sendMessage(kitList.length() > 0 ? tl("kits", kitList) : tl("noKits"));
throw new NoChargeException();
} else {
final User userTo = getPlayer(server, args, 1, true, false);
final String[] kits = args[0].toLowerCase(Locale.ENGLISH).split(",");
for (final String kitName : kits) {
final Kit kit = new Kit(kitName, ess);
kit.expandItems(userTo);
sender.sendMessage(tl("kitGiveTo", kitName, userTo.getDisplayName()));
userTo.sendMessage(tl("kitReceive", kitName));
}
}
}
use of com.earth2me.essentials.Kit in project Essentials by drtshock.
the class EssentialsSpawnPlayerListener method delayedJoin.
public void delayedJoin(final Player player) {
if (player.hasPlayedBefore()) {
LOGGER.log(Level.FINE, "Old player join");
List<String> spawnOnJoinGroups = ess.getSettings().getSpawnOnJoinGroups();
if (!spawnOnJoinGroups.isEmpty()) {
final User user = ess.getUser(player);
if (ess.getSettings().isUserInSpawnOnJoinGroup(user) && !user.isAuthorized("essentials.spawn-on-join.exempt")) {
ess.scheduleSyncDelayedTask(new Runnable() {
@Override
public void run() {
Location spawn = spawns.getSpawn(user.getGroup());
try {
// We don't use user.getTeleport() because it stores last location, which is unwanted in this case.
user.getBase().teleport(spawn, TeleportCause.PLUGIN);
} catch (Exception e) {
ess.showError(user.getSource(), e, "spawn-on-join");
}
}
});
}
}
return;
}
final User user = ess.getUser(player);
if (!"none".equalsIgnoreCase(ess.getSettings().getNewbieSpawn())) {
ess.scheduleSyncDelayedTask(new NewPlayerTeleport(user), 1L);
}
ess.scheduleSyncDelayedTask(new Runnable() {
@Override
public void run() {
if (!user.getBase().isOnline()) {
return;
}
// This method allows for multiple line player announce messages using multiline yaml syntax #EasterEgg
if (ess.getSettings().getAnnounceNewPlayers()) {
final IText output = new KeywordReplacer(ess.getSettings().getAnnounceNewPlayerFormat(), user.getSource(), ess);
final SimpleTextPager pager = new SimpleTextPager(output);
for (String line : pager.getLines()) {
ess.broadcastMessage(user, line);
}
}
final String kitName = ess.getSettings().getNewPlayerKit();
if (!kitName.isEmpty()) {
try {
final Kit kit = new Kit(kitName.toLowerCase(Locale.ENGLISH), ess);
kit.expandItems(user);
} catch (Exception ex) {
LOGGER.log(Level.WARNING, ex.getMessage());
}
}
LOGGER.log(Level.FINE, "New player join");
}
}, 2L);
}
Aggregations