我正在为一个程序编写两个插件,其中一个是“库插件”,包含许多其他插件使用的类,另一个是基于这个库的插件。除了一件事之外,所有的工作都很好。在我的库插件中,我编写了一个中文化的socket类:
public class MServerSocket {
public void initServer(int port) {
//Code to receive message from client
execute(input, clientOutput);
}
public void execute(String input, DataOutputStream clientOutput) {
System.out.println(input);
send(clientOutput, input);
}
public void send(DataOutputStream clientOutput, String output) {
//Code to send message to client
}
}在另一个插件中,我扩展了这个类并覆盖了execute方法来做一些事情,如下所示:
public class MySocketServer extends MServerSocket {
@Override
public void execute(String input, DataOutputStream clientOutput) {
//Do something
MServerSocket.send(clientOutput, input)
}
}现在我的第二个插件应该覆盖我的库插件类,但它没有。在第二个插件中,我像这样调用它:
public class Main {
public void onEnable() { //method called to load plugin
private static MServerSocket socket = new MServerSocket();
socket.initServer(12980);
}
}当我向套接字发送套接字消息时,它会被打印到控制台,如库execute方法所述。
所以我在这里,有人能给我一个答案和可能的解决方案吗?提前感谢
https://stackoverflow.com/questions/44358868
复制相似问题