Moved the tutorial check from scheduler to PlayerJoinEvent

This commit is contained in:
Grafe 2013-01-23 15:31:44 +01:00
parent 0b1b582d33
commit 53c356165c
2 changed files with 33 additions and 35 deletions

View File

@ -194,34 +194,6 @@ public class P extends JavaPlugin{
GameWorld.update();
GameCheckpoint.update();
DPlayer.update(true);
//Tutorial Mode
if(p.mainConfig.tutorialActivated){
for(Player player:p.getServer().getOnlinePlayers()){
if(DPlayer.get(player)==null){
if(p.mainConfig.tutorialDungeon!=null && p.mainConfig.tutorialStartGroup!=null && p.mainConfig.tutorialEndGroup!=null){
for(String group:p.permission.getPlayerGroups(player)){
if(p.mainConfig.tutorialStartGroup.equalsIgnoreCase(group)){
DGroup dgroup=new DGroup(player, p.mainConfig.tutorialDungeon);
if(dgroup.gworld==null){
dgroup.gworld=GameWorld.load(DGroup.get(player).dungeonname);
dgroup.gworld.isTutorial=true;
}
if(dgroup.gworld!=null){
if(dgroup.gworld.locLobby==null){
new DPlayer(player,dgroup.gworld.world,dgroup.gworld.world.getSpawnLocation(), false);
}else{
new DPlayer(player,dgroup.gworld.world,dgroup.gworld.locLobby, false);
}
}else{
p.msg(player,p.language.get("Error_TutorialNotExist"));
}
}
}
}
}
}
}
}
}, 0L, 20L);
@ -255,7 +227,6 @@ public class P extends JavaPlugin{
return false;
}
//Save and Load
public void saveData(){
File file = new File(this.getDataFolder(), "data.yml");
@ -268,14 +239,11 @@ public class P extends JavaPlugin{
try {
configFile.save(file);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public void loadAll(){
//Load world data
File file = new File(this.getDataFolder(), "data.yml");
FileConfiguration configFile = YamlConfiguration.loadConfiguration(file);
@ -291,7 +259,6 @@ public class P extends JavaPlugin{
DSavePlayer.load();
}
//File Control
public boolean removeDirectory(File directory) {
if (directory.isDirectory()) {

View File

@ -288,10 +288,41 @@ public class PlayerListener implements Listener{
@EventHandler(priority = EventPriority.HIGH)
public void onPlayerJoin(PlayerJoinEvent event){
DPlayer dplayer=DPlayer.get(event.getPlayer().getName());
if(dplayer!=null){
Player player = event.getPlayer();
//Check dplayers
DPlayer dplayer = DPlayer.get(event.getPlayer().getName());
if(dplayer != null){
dplayer.player = event.getPlayer();
}
//Tutorial Mode
if(p.mainConfig.tutorialActivated){
if(DPlayer.get(player) == null){
if(p.mainConfig.tutorialDungeon != null && p.mainConfig.tutorialStartGroup != null && p.mainConfig.tutorialEndGroup != null){
for(String group:p.permission.getPlayerGroups(player)){
if(p.mainConfig.tutorialStartGroup.equalsIgnoreCase(group)){
DGroup dgroup = new DGroup(player, p.mainConfig.tutorialDungeon);
if(dgroup.gworld == null){
dgroup.gworld = GameWorld.load(DGroup.get(player).dungeonname);
dgroup.gworld.isTutorial = true;
}
if(dgroup.gworld != null){
if(dgroup.gworld.locLobby == null){
new DPlayer(player,dgroup.gworld.world,dgroup.gworld.world.getSpawnLocation(), false);
}else{
new DPlayer(player,dgroup.gworld.world,dgroup.gworld.locLobby, false);
}
}else{
p.msg(player,p.language.get("Error_TutorialNotExist"));
}
}
}
}
}
}
}
@EventHandler(priority = EventPriority.HIGH)