Initialize online players when Factions is enabled
This commit is contained in:
parent
2955370c9e
commit
b52805f7a4
@ -33,13 +33,6 @@ public class P extends MPlugin {
|
|||||||
// Single 4 life.
|
// Single 4 life.
|
||||||
public static P p;
|
public static P p;
|
||||||
|
|
||||||
// Listeners
|
|
||||||
public final FactionsPlayerListener playerListener;
|
|
||||||
public final FactionsChatListener chatListener;
|
|
||||||
public final FactionsEntityListener entityListener;
|
|
||||||
public final FactionsExploitListener exploitListener;
|
|
||||||
public final FactionsBlockListener blockListener;
|
|
||||||
|
|
||||||
// Persistence related
|
// Persistence related
|
||||||
private boolean locked = false;
|
private boolean locked = false;
|
||||||
|
|
||||||
@ -60,11 +53,6 @@ public class P extends MPlugin {
|
|||||||
|
|
||||||
public P() {
|
public P() {
|
||||||
p = this;
|
p = this;
|
||||||
this.playerListener = new FactionsPlayerListener(this);
|
|
||||||
this.chatListener = new FactionsChatListener(this);
|
|
||||||
this.entityListener = new FactionsEntityListener(this);
|
|
||||||
this.exploitListener = new FactionsExploitListener();
|
|
||||||
this.blockListener = new FactionsBlockListener(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -73,6 +61,7 @@ public class P extends MPlugin {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.loadSuccessful = false;
|
this.loadSuccessful = false;
|
||||||
|
saveDefaultConfig();
|
||||||
|
|
||||||
// Load Conf from disk
|
// Load Conf from disk
|
||||||
Conf.load();
|
Conf.load();
|
||||||
@ -108,13 +97,11 @@ public class P extends MPlugin {
|
|||||||
startAutoLeaveTask(false);
|
startAutoLeaveTask(false);
|
||||||
|
|
||||||
// Register Event Handlers
|
// Register Event Handlers
|
||||||
getServer().getPluginManager().registerEvents(playerListener, this);
|
getServer().getPluginManager().registerEvents(new FactionsPlayerListener(this), this);
|
||||||
getServer().getPluginManager().registerEvents(chatListener, this);
|
getServer().getPluginManager().registerEvents(new FactionsChatListener(this), this);
|
||||||
getServer().getPluginManager().registerEvents(entityListener, this);
|
getServer().getPluginManager().registerEvents(new FactionsEntityListener(this), this);
|
||||||
getServer().getPluginManager().registerEvents(exploitListener, this);
|
getServer().getPluginManager().registerEvents(new FactionsExploitListener(), this);
|
||||||
getServer().getPluginManager().registerEvents(blockListener, this);
|
getServer().getPluginManager().registerEvents(new FactionsBlockListener(this), this);
|
||||||
|
|
||||||
saveDefaultConfig();
|
|
||||||
|
|
||||||
// since some other plugins execute commands directly through this command interface, provide it
|
// since some other plugins execute commands directly through this command interface, provide it
|
||||||
this.getCommand(this.refCommand).setExecutor(this);
|
this.getCommand(this.refCommand).setExecutor(this);
|
||||||
|
@ -37,18 +37,25 @@ public class FactionsPlayerListener implements Listener {
|
|||||||
|
|
||||||
public FactionsPlayerListener(P p) {
|
public FactionsPlayerListener(P p) {
|
||||||
this.p = p;
|
this.p = p;
|
||||||
|
for (Player player : p.getServer().getOnlinePlayers()) {
|
||||||
|
initPlayer(player);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.NORMAL)
|
@EventHandler(priority = EventPriority.NORMAL)
|
||||||
public void onPlayerJoin(PlayerJoinEvent event) {
|
public void onPlayerJoin(PlayerJoinEvent event) {
|
||||||
|
initPlayer(event.getPlayer());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initPlayer(Player player) {
|
||||||
// Make sure that all online players do have a fplayer.
|
// Make sure that all online players do have a fplayer.
|
||||||
final FPlayer me = FPlayers.getInstance().getByPlayer(event.getPlayer());
|
final FPlayer me = FPlayers.getInstance().getByPlayer(player);
|
||||||
|
|
||||||
// Update the lastLoginTime for this fplayer
|
// Update the lastLoginTime for this fplayer
|
||||||
me.setLastLoginTime(System.currentTimeMillis());
|
me.setLastLoginTime(System.currentTimeMillis());
|
||||||
|
|
||||||
// Store player's current FLocation and notify them where they are
|
// Store player's current FLocation and notify them where they are
|
||||||
me.setLastStoodAt(new FLocation(event.getPlayer().getLocation()));
|
me.setLastStoodAt(new FLocation(player.getLocation()));
|
||||||
|
|
||||||
// Check for Faction announcements. Let's delay this so they actually see it.
|
// Check for Faction announcements. Let's delay this so they actually see it.
|
||||||
Bukkit.getScheduler().runTaskLater(P.p, new Runnable() {
|
Bukkit.getScheduler().runTaskLater(P.p, new Runnable() {
|
||||||
@ -68,9 +75,9 @@ public class FactionsPlayerListener implements Listener {
|
|||||||
|
|
||||||
Faction myFaction = me.getFaction();
|
Faction myFaction = me.getFaction();
|
||||||
if (!myFaction.isNone()) {
|
if (!myFaction.isNone()) {
|
||||||
for (FPlayer player : myFaction.getFPlayersWhereOnline(true)) {
|
for (FPlayer other : myFaction.getFPlayersWhereOnline(true)) {
|
||||||
if (player != me && player.isMonitoringJoins()) {
|
if (other != me && other.isMonitoringJoins()) {
|
||||||
player.msg(TL.FACTION_LOGIN, me.getName());
|
other.msg(TL.FACTION_LOGIN, me.getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user