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(); GameWorld.update();
GameCheckpoint.update(); GameCheckpoint.update();
DPlayer.update(true); 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); }, 0L, 20L);
@ -255,7 +227,6 @@ public class P extends JavaPlugin{
return false; return false;
} }
//Save and Load //Save and Load
public void saveData(){ public void saveData(){
File file = new File(this.getDataFolder(), "data.yml"); File file = new File(this.getDataFolder(), "data.yml");
@ -268,14 +239,11 @@ public class P extends JavaPlugin{
try { try {
configFile.save(file); configFile.save(file);
} catch (IOException e) { } catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace(); e.printStackTrace();
} }
} }
public void loadAll(){ public void loadAll(){
//Load world data //Load world data
File file = new File(this.getDataFolder(), "data.yml"); File file = new File(this.getDataFolder(), "data.yml");
FileConfiguration configFile = YamlConfiguration.loadConfiguration(file); FileConfiguration configFile = YamlConfiguration.loadConfiguration(file);
@ -291,7 +259,6 @@ public class P extends JavaPlugin{
DSavePlayer.load(); DSavePlayer.load();
} }
//File Control //File Control
public boolean removeDirectory(File directory) { public boolean removeDirectory(File directory) {
if (directory.isDirectory()) { if (directory.isDirectory()) {

View File

@ -288,10 +288,41 @@ public class PlayerListener implements Listener{
@EventHandler(priority = EventPriority.HIGH) @EventHandler(priority = EventPriority.HIGH)
public void onPlayerJoin(PlayerJoinEvent event){ public void onPlayerJoin(PlayerJoinEvent event){
DPlayer dplayer=DPlayer.get(event.getPlayer().getName()); Player player = event.getPlayer();
if(dplayer!=null){
//Check dplayers
DPlayer dplayer = DPlayer.get(event.getPlayer().getName());
if(dplayer != null){
dplayer.player = event.getPlayer(); 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) @EventHandler(priority = EventPriority.HIGH)