mirror of
https://github.com/EssentialsX/Essentials.git
synced 2025-02-08 16:31:58 +01:00
Adding starter/newbie kit to EssentialsSpawn
Optimization to EssentialsSpawn join event.
This commit is contained in:
parent
e55aa3cea7
commit
6a9027da6d
@ -9,6 +9,7 @@ import org.bukkit.command.CommandSender;
|
|||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
import org.bukkit.scheduler.BukkitScheduler;
|
import org.bukkit.scheduler.BukkitScheduler;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @deprecated This will be moved to the api package soon
|
* @deprecated This will be moved to the api package soon
|
||||||
*/
|
*/
|
||||||
|
@ -20,6 +20,8 @@ public interface ISettings extends IConf
|
|||||||
|
|
||||||
boolean getAnnounceNewPlayers();
|
boolean getAnnounceNewPlayers();
|
||||||
|
|
||||||
|
String getNewPlayerKit();
|
||||||
|
|
||||||
String getBackupCommand();
|
String getBackupCommand();
|
||||||
|
|
||||||
long getBackupInterval();
|
long getBackupInterval();
|
||||||
|
@ -63,7 +63,8 @@ public class Kit
|
|||||||
|
|
||||||
public static List<String> getItems(final User user, final Map<String, Object> kit) throws Exception
|
public static List<String> getItems(final User user, final Map<String, Object> kit) throws Exception
|
||||||
{
|
{
|
||||||
if (kit == null) {
|
if (kit == null)
|
||||||
|
{
|
||||||
throw new Exception(_("kitError2"));
|
throw new Exception(_("kitError2"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -351,6 +351,12 @@ public class Settings implements ISettings
|
|||||||
return new SimpleTextInput(Util.replaceColor(config.getString("newbies.announce-format", "&dWelcome {DISPLAYNAME} to the server!")));
|
return new SimpleTextInput(Util.replaceColor(config.getString("newbies.announce-format", "&dWelcome {DISPLAYNAME} to the server!")));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getNewPlayerKit()
|
||||||
|
{
|
||||||
|
return config.getString("newbies.kit", "");
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getNewbieSpawn()
|
public String getNewbieSpawn()
|
||||||
{
|
{
|
||||||
|
@ -548,6 +548,11 @@ newbies:
|
|||||||
# Set to "none" if you want to use the spawn point of the world.
|
# Set to "none" if you want to use the spawn point of the world.
|
||||||
spawnpoint: newbies
|
spawnpoint: newbies
|
||||||
|
|
||||||
|
# Do we want to give users anything on first join? Set to '' to disable
|
||||||
|
# This kit will be given reguardless of cost, and permissions.
|
||||||
|
#kit: ''
|
||||||
|
kit: tools
|
||||||
|
|
||||||
# Set this to lowest, if you want Multiverse to handle the respawning
|
# Set this to lowest, if you want Multiverse to handle the respawning
|
||||||
# Set this to high, if you want EssentialsSpawn to handle the respawning
|
# Set this to high, if you want EssentialsSpawn to handle the respawning
|
||||||
# Set this to highest, if you want to force EssentialsSpawn to handle the respawning
|
# Set this to highest, if you want to force EssentialsSpawn to handle the respawning
|
||||||
|
@ -1,12 +1,13 @@
|
|||||||
package com.earth2me.essentials.spawn;
|
package com.earth2me.essentials.spawn;
|
||||||
|
|
||||||
|
import com.earth2me.essentials.*;
|
||||||
import static com.earth2me.essentials.I18n._;
|
import static com.earth2me.essentials.I18n._;
|
||||||
import com.earth2me.essentials.IEssentials;
|
|
||||||
import com.earth2me.essentials.OfflinePlayer;
|
|
||||||
import com.earth2me.essentials.User;
|
|
||||||
import com.earth2me.essentials.textreader.IText;
|
import com.earth2me.essentials.textreader.IText;
|
||||||
import com.earth2me.essentials.textreader.KeywordReplacer;
|
import com.earth2me.essentials.textreader.KeywordReplacer;
|
||||||
import com.earth2me.essentials.textreader.SimpleTextPager;
|
import com.earth2me.essentials.textreader.SimpleTextPager;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Locale;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
@ -67,13 +68,14 @@ public class EssentialsSpawnPlayerListener implements Listener
|
|||||||
|
|
||||||
public void onPlayerJoin(final PlayerJoinEvent event)
|
public void onPlayerJoin(final PlayerJoinEvent event)
|
||||||
{
|
{
|
||||||
final User user = ess.getUser(event.getPlayer());
|
if (event.getPlayer().hasPlayedBefore())
|
||||||
|
|
||||||
if (user.hasPlayedBefore())
|
|
||||||
{
|
{
|
||||||
LOGGER.log(Level.FINE, "Old player join");
|
LOGGER.log(Level.FINE, "Old player join");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final User user = ess.getUser(event.getPlayer());
|
||||||
|
|
||||||
if (!"none".equalsIgnoreCase(ess.getSettings().getNewbieSpawn()))
|
if (!"none".equalsIgnoreCase(ess.getSettings().getNewbieSpawn()))
|
||||||
{
|
{
|
||||||
ess.scheduleSyncDelayedTask(new NewPlayerTeleport(user), 1L);
|
ess.scheduleSyncDelayedTask(new NewPlayerTeleport(user), 1L);
|
||||||
@ -86,6 +88,21 @@ public class EssentialsSpawnPlayerListener implements Listener
|
|||||||
ess.broadcastMessage(user, pager.getString(0));
|
ess.broadcastMessage(user, pager.getString(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final String kitName = ess.getSettings().getNewPlayerKit();
|
||||||
|
if (!kitName.isEmpty())
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
final Map<String, Object> kit = ess.getSettings().getKit(kitName.toLowerCase(Locale.ENGLISH));
|
||||||
|
final List<String> items = Kit.getItems(user, kit);
|
||||||
|
Kit.expandItems(ess, user, items);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
LOGGER.log(Level.WARNING, ex.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
LOGGER.log(Level.FINE, "New player join");
|
LOGGER.log(Level.FINE, "New player join");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -109,7 +126,7 @@ public class EssentialsSpawnPlayerListener implements Listener
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Location spawn = spawns.getSpawn(ess.getSettings().getNewbieSpawn());
|
final Location spawn = spawns.getSpawn(ess.getSettings().getNewbieSpawn());
|
||||||
if (spawn != null)
|
if (spawn != null)
|
||||||
{
|
{
|
||||||
user.getTeleport().now(spawn, false, TeleportCause.PLUGIN);
|
user.getTeleport().now(spawn, false, TeleportCause.PLUGIN);
|
||||||
|
Loading…
Reference in New Issue
Block a user