mirror of
https://github.com/Zrips/Jobs.git
synced 2024-11-29 14:05:25 +01:00
Auto job join
This commit is contained in:
parent
dd602cbb67
commit
2f2a6caf87
@ -69,7 +69,7 @@ import net.coreprotect.CoreProtectAPI;
|
||||
public class Jobs {
|
||||
public static Jobs instance = new Jobs();
|
||||
// public static JobsPlugin plugin = new JobsPlugin();
|
||||
private static PlayerManager pManager = new PlayerManager();
|
||||
private static PlayerManager pManager = null;
|
||||
private static JobsCommands cManager = null;
|
||||
private static Language lManager = null;
|
||||
private static LanguageManager lmManager = null;
|
||||
@ -180,6 +180,10 @@ public class Jobs {
|
||||
return pManager;
|
||||
}
|
||||
|
||||
public static void setPlayerManager(JobsPlugin jobsPlugin) {
|
||||
pManager = new PlayerManager (jobsPlugin);
|
||||
}
|
||||
|
||||
public static void setRestrictedBlockManager(JobsPlugin plugin) {
|
||||
RBManager = new RestrictedBlockManager(plugin);
|
||||
}
|
||||
|
@ -94,6 +94,8 @@ public class JobsPlugin extends JavaPlugin {
|
||||
|
||||
Jobs.setPermissionHandler(new PermissionHandler(this));
|
||||
|
||||
Jobs.setPlayerManager(this);
|
||||
|
||||
Jobs.setScboard(this);
|
||||
Jobs.setLanguage(this);
|
||||
Jobs.setGUIManager(this);
|
||||
|
@ -58,6 +58,11 @@ public class PlayerManager {
|
||||
private PointsData PointsDatabase = new PointsData();
|
||||
|
||||
private HashMap<String, PlayerInfo> PlayerMap = new HashMap<String, PlayerInfo>();
|
||||
JobsPlugin plugin;
|
||||
|
||||
public PlayerManager(JobsPlugin plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
public PointsData getPointsData() {
|
||||
return PointsDatabase;
|
||||
@ -108,6 +113,7 @@ public class PlayerManager {
|
||||
JobsPlayer.loadLogFromDao(jPlayer);
|
||||
players.put(player.getName().toLowerCase(), jPlayer);
|
||||
}
|
||||
AutoJoinJobs(player);
|
||||
jPlayer.onConnect();
|
||||
jPlayer.reloadHonorific();
|
||||
Jobs.getPermissionHandler().recalculatePermissions(jPlayer);
|
||||
@ -804,4 +810,28 @@ public class PlayerManager {
|
||||
|
||||
return new BoostMultiplier(Fmoney, Fpoints, Fexp);
|
||||
}
|
||||
|
||||
public void AutoJoinJobs(final Player player) {
|
||||
if (player == null)
|
||||
return;
|
||||
// ignoring OP players for obvious reasons
|
||||
if (player.isOp())
|
||||
return;
|
||||
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
|
||||
public void run() {
|
||||
if (!player.isOnline())
|
||||
return;
|
||||
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(player);
|
||||
if (jPlayer == null)
|
||||
return;
|
||||
for (Job one : Jobs.getJobs()) {
|
||||
JobProgression cur = jPlayer.getJobProgression(one);
|
||||
if (cur == null && player.hasPermission("jobs.autojoin." + one.getName().toLowerCase())) {
|
||||
Jobs.getPlayerManager().joinJob(jPlayer, one);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
}, Jobs.getGCManager().AutoJobJoinDelay * 20L);
|
||||
}
|
||||
}
|
||||
|
@ -120,6 +120,7 @@ public class GeneralConfigManager {
|
||||
public boolean UseTaxes;
|
||||
public boolean TransferToServerAccount;
|
||||
public boolean TakeFromPlayersPayment;
|
||||
public int AutoJobJoinDelay;
|
||||
|
||||
//BossBar
|
||||
public boolean BossBarEnabled;
|
||||
@ -402,6 +403,12 @@ public class GeneralConfigManager {
|
||||
"Only enable this if you have a multi-server setup, or have a really good reason for enabling this.", "Turning this on will decrease database performance.");
|
||||
saveOnDisconnect = c.get("save-on-disconnect", false);
|
||||
|
||||
c.getW().addComment("Optimizations.AutoJobJoinDelay", "Delay in seconds to perform auto join job if used after player joins server",
|
||||
"If you using offline server, try to keep it slightly more than your login plugin gives time to enter password",
|
||||
"For player to auto join job add permission node jobs.autojoin.[jobname]",
|
||||
"Op players are ignored");
|
||||
AutoJobJoinDelay = c.get("Optimizations.AutoJobJoinDelay", 15);
|
||||
|
||||
c.getW().addComment("Optimizations.UseLocalOfflinePlayersData", "With this set to true, offline player data will be taken from local player data files",
|
||||
"This will eliminate small lag spikes when request is being send to mojangs servers for offline players data",
|
||||
"Theroticali this should work without issues, but if you havving some, just disable",
|
||||
|
Loading…
Reference in New Issue
Block a user