Last Acess

  • Автор темы Автор темы lBrazza
  • Дата начала Дата начала

lBrazza

Знаменитый
Участник
Сообщения
19
Розыгрыши
0
Репутация
0
Реакции
20
Баллы
1 288
Someone shed some light, I've already added it several times, changed several variables and this code doesn't work, can anyone help? I wanted to add LastAcess to the CommunityBoard.


Код:
EnterWorld.java

  @Override
    protected void runImpl() {
        Player player = getClient().getPlayer();
        if (player == null) {
            return;
        }

        //code...

+        String lastLoginTime = player.getLastLoginTime();
+        CreatureSay lastVisit = new CreatureSay(player, ChatType.GENERAL, "System", "Last login: " + lastLoginTime);
+        player.sendPacket(lastVisit);

        //code...
    }


Player.java

public class Player extends Creature {
    //code...

+    public String getLastLoginTime() {
+        Date lastAccess = new Date(getLastAccess());
+        SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy HH:mm");
+        return dateFormat.format(lastAccess);
+   }

    //code...
}

HomeBoard.java

public class HomeBoard implements IParseBoardHandler
{
    // Existing code...

 +   public String handleHtmlPlaceholders(Player player, String html) {
 +       if (html.contains("%last_login%")) {
 +           html = html.replace("%last_login%", player.getLastLoginTime());
 +       }

        // Handle other placeholders...

        return html;
    }
 
Someone shed some light, I've already added it several times, changed several variables and this code doesn't work, can anyone help? I wanted to add LastAcess to the CommunityBoard.


Код:
EnterWorld.java

  @Override
    protected void runImpl() {
        Player player = getClient().getPlayer();
        if (player == null) {
            return;
        }

        //code...

+        String lastLoginTime = player.getLastLoginTime();
+        CreatureSay lastVisit = new CreatureSay(player, ChatType.GENERAL, "System", "Last login: " + lastLoginTime);
+        player.sendPacket(lastVisit);

        //code...
    }


Player.java

public class Player extends Creature {
    //code...

+    public String getLastLoginTime() {
+        Date lastAccess = new Date(getLastAccess());
+        SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy HH:mm");
+        return dateFormat.format(lastAccess);
+   }

    //code...
}

HomeBoard.java

public class HomeBoard implements IParseBoardHandler
{
    // Existing code...

 +   public String handleHtmlPlaceholders(Player player, String html) {
 +       if (html.contains("%last_login%")) {
 +           html = html.replace("%last_login%", player.getLastLoginTime());
 +       }

        // Handle other placeholders...

        return html;
    }


The code looks fine. I would assume the only problematic step could be the parsing of the data from your database to getLastAccess().
You haven't provided that particular method in your excerpt. Secondly, it would've helped if you had some error messages to help us narrow it down even further.
 
Are you sure that you invoking handleHtmlPlaceholders in your HomeBoard.parseCommunityBoardCommand ?
 
We r talking about mobius, am i right?
I just opened random mobius source and i see that HomeBoard.parseCommunityBoardCommand does all required bypass parsing and back html formatting

So maybe u need to call handleHtmlPlaceholders function before send html back to user, lets say somewhere here
zX5DWjXfQryI15iDwex1Jg.png
 
We r talking about mobius, am i right?
I just opened random mobius source and i see that HomeBoard.parseCommunityBoardCommand does all required bypass parsing and back html formatting

So maybe u need to call handleHtmlPlaceholders function before send html back to user, lets say somewhere here
Посмотреть вложение 75230
OK, thanks, I'll try it here ;D

We r talking about mobius, am i right?
I just opened random mobius source and i see that HomeBoard.parseCommunityBoardCommand does all required bypass parsing and back html formatting

So maybe u need to call handleHtmlPlaceholders function before send html back to user, lets say somewhere here
Посмотреть вложение 75230
unfortunately it didn't work ;s
 
Назад
Сверху Снизу