[Guide][JAVA]How to make gn_add message display a full screen message

Paulus

Administrator
Staff member
Admin
Content Creator
Guide Author
  • First we have to decompile clientCmds.cmds.admin.globalNotice.CmdAddGlobalNotice.class
  • In the decompiled code find the run method which actually run the command in the server:
Java:
    public void run(@NotNull Abonent var1) {       
        String var2 = var1 instanceof Avatar ? ((AvatarReplica)var1).getName() : "";
        Address var3 = c.a(var1.getGlobalContext());
        CmdAddGlobalNotice.b_ var4 = new CmdAddGlobalNotice.b_(var1.getAddress(), var3, var2, StringUtils.join(this.msg, " "), a.Chat, this.repetitionPeriodImMinutes);
        ContextId.b(var1.getGlobalContext()).a(var4);
    }
  • We can see that by default gn_add is broadcasting its messages towards the channel a.Chat
  • If we look at clientCmds.cmds.admin.globalNotice.a.class we can see that we have 3 channels options in the enumerator:
Code:
package clientCmds.cmds.admin.globalNotice;

import replicationAnnotations.eb;

@eb
public enum a {
    Chat,
    Screen,
    Both;

    private a() {
    }
}
  • The options are quite explicit: Chat means that your message is only displayed in chat, Screen that is displayed only on screen and Both means screen and chat. Typically we want the Both option so we replace it in the code:
Code:
    public void run(@NotNull Abonent var1) {
        String var2 = var1 instanceof Avatar ? ((AvatarReplica)var1).getName() : "";
        Address var3 = c.a(var1.getGlobalContext());
        CmdAddGlobalNotice.b_ var4 = new CmdAddGlobalNotice.b_(var1.getAddress(), var3, var2, StringUtils.join(this.msg, " "), a.Both, this.repetitionPeriodImMinutes);
        ContextId.b(var1.getGlobalContext()).a(var4);
    }
  • Now we just need to recompile with jdk 1.7 and replace CmdAddGlobalNotice.class with the newly compiled file in the corresponding jar file.
 
  • Now we just need to recompile with jdk 1.7 and replace CmdAddGlobalNotice.class with the newly compiled file in the corresponding jar file.

Hi!
Show with an example how to properly decompile and recompile a modified class file.
Thank!
 
OP
Paulus

Paulus

Administrator
Staff member
Admin
Content Creator
Guide Author
I recommend you to use Intellij IDEA, there is a free community version that can decompile .class. Just install and open .class file with it. To compile is just how Java does. You have to add all jars file to library to make it resolve modules names and compile with jdk 1.7.

Capture.PNG
Here I've just put all the jar in external library section of IntelliJ IDEA to import the dependancies
 
Last edited:
Это тестовый файл
 

Attachments

  • clientCmds.zip
    1.1 MB · Views: 46
I recommend you to use Intellij IDEA, there is a free community version that can decompile .class. Just install and open .class file with it. To compile is just how Java does. You have to add all jars file to library to make it resolve modules names and compile with jdk 1.7.

View attachment 2364
Here I've just put all the jar in external library section of IntelliJ IDEA to import the dependancies

OK. I did everything according to the instructions. Used the development environment IntelliJ IDEA
connected to your project - JDK and external libraries - jars
C: \ Program Files \ Java \ jdk1.7.0_03
C: \ server \ server_bin \ jars
Decompiled DeathManager.class in src DeathManager.java (Strl+C | Strl+V)
Made code changes according to the manual:
You do not have permission to view link Log in or register now.

At compile time, it produces the following errors:
0007.PNG
0008.PNG
I understand that during the decompilation class of the file there is a loss of some part of the code or decompilation done with not 100% quality code.
Apparently on this when compiling the code and there are this kind of error.

Question: how to fix these errors?

My English translation is Bad :/

============ оригинал ==============

ОК. Сделал всё по инструкции. Использовал среду разработки IntelliJ IDEA
подключил к своему проекту - JDK и внешние библиотеки - jars
C:\Program Files\Java\jdk1.7.0_03
C:\server\server_bin\jars
Декомпилиловал DeathManager.class в src DeathManager.java (Ctrl+С | Ctrl+V)
Произвёл правки кода согласно мануала:
You do not have permission to view link Log in or register now.

Во время компиляции выдаёт вот такие ошибки:
0007.PNG
0008.PNG
Я понимаю что во время декомпиляции класс файла происходит потеря какой то части кода или декомпиляция производится с не 100% качеством кода.
Видимо по этому при компиляции кода и возникают данного рода ошибки.

Вопрос: как исправить эти ошибки?
 
Last edited:

Top Bottom