This repository has been archived by the owner on Apr 18, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
/
RewiMod.java
189 lines (162 loc) · 5.61 KB
/
RewiMod.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
/*
* RewiMod, a Minecraft Client Enhancement
* Copyright (C) rewinside.tv <https://rewinside.tv/>
* Copyright (C) RewiMod team and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package tv.rewinside.rewimod.core;
import java.awt.Color;
import java.awt.Desktop;
import java.io.IOException;
import java.net.URI;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import lombok.Getter;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import tv.rewinside.rewimod.core.gui.ButtonFactory;
import tv.rewinside.rewimod.core.handlers.IFontRendererObjHandler;
import tv.rewinside.rewimod.core.handlers.IGlStateManagerHandler;
import tv.rewinside.rewimod.core.handlers.IGuiHandler;
import tv.rewinside.rewimod.core.handlers.IMessageHandler;
import tv.rewinside.rewimod.core.handlers.ITextureHandler;
import tv.rewinside.rewimod.core.util.Chatlog;
public abstract class RewiMod {
public static final String FINGERPRINT = "7caf764152a9e91657dbbceb44630e90774fa1fd";
public static final boolean DEACTIVATEABLE = true;
public static final Logger LOGGER = LogManager.getLogger("RewiMod");
@Getter private static RewiMod instance;
@Getter private final ScheduledExecutorService executorService = Executors.newScheduledThreadPool(1);
@Getter private final int confirmDisconnectButtonColor = new Color(252, 53, 57).getRGB();
@Getter private String uuid;
@Getter private String username;
@Getter private String minecraftVersion;
@Getter private final List<String> blacklistedWords = new ArrayList<>();
@Getter private final List<Chatlog> chatlogs = new ArrayList<>();
/**
* Initializes the Mod
*
* @param language the selected Game Language
* @param mcVersion the current Minecraft Version
* @param uuid the UUID of the user
* @param username the username of the user
*/
protected void initialize(String language, String mcVersion, String uuid, String username) {
instance = this;
this.minecraftVersion = mcVersion;
this.uuid = uuid;
this.username = username;
this.registerEvents();
this.setDisplayTitle("Minecraft " + this.getMinecraftVersion() + " - " + this.getName() + " " + this.getVersion() + " - " + this.getUsername());
LOGGER.info("Successfully initialized " + this.getModId() + " " + this.getVersion());
}
/**
* Logs a warning, that the Fingerprint is invalid
*/
protected void onFingerprintViolation() {
LOGGER.warn("!!! NO ORIGINAL REWIMOD VERSION !!!");
}
/**
* Registers all Event listeners
*/
protected abstract void registerEvents();
/**
* Connects directly to a multiplayer server
*
* @param name the name of the server (accepts <i>null</i>)
* @param host the serverip
* @param port the port
* @param isLan wether the server is on the lan or not
*/
public abstract void connectToServer(String name, String host, int port, boolean isLan);
/**
*
* Opens the Browser for the Player with the Parameter url
*
* @param url The URL
*/
public void openUrl(String url) {
Desktop desktop = Desktop.isDesktopSupported() ? Desktop.getDesktop() : null;
if (desktop != null && desktop.isSupported(Desktop.Action.BROWSE)) {
try {
desktop.browse(URI.create(url));
} catch (IOException ex) {
RewiMod.LOGGER.error("An error occurred while opening an URL!", ex);
}
}
}
/**
* Gets the mod-unique identificator
*
* @return the identificator as String
*/
public abstract String getModId();
/**
* Gets the name of the mod
*
* @return the name as String
*/
public abstract String getName();
/**
* Gets the version of the mod
*
* @return the version as String
*/
public abstract String getVersion();
/**
* Gets the default ButtonFactory
*
* @return the default {@link tv.rewinside.rewimod.core.gui.ButtonFactory}
*/
public abstract ButtonFactory getDefaultButtonFactory();
/**
* Sets the title of the LWJGL Minecraft window
*
* @param displayTitle the title as String
*/
public abstract void setDisplayTitle(String displayTitle);
/**
* Gets the font render obj
*
* @return an implementation of {@link IFontRendererObjHandler}
*/
public abstract IFontRendererObjHandler getFontRendererObjHandler();
/**
* Gets the handler for handling textures
*
* @return an implementation of {@link tv.rewinside.rewimod.core.handlers.ITextureHandler}
*/
public abstract ITextureHandler getTextureHandler();
/**
* Gets the handler for handling gui
*
* @return an implementation of {@link tv.rewinside.rewimod.core.handlers.IGuiHandler}
*/
public abstract IGuiHandler getGuiHandler();
/**
* Gets the handler for handling the GlStateManager
*
* @return an implementation of {@link tv.rewinside.rewimod.core.handlers.IGlStateManagerHandler}
*/
public abstract IGlStateManagerHandler getGlStateManagerHandler();
/**
* Gets the handler for handling the Messages
*
* @return an implementation of {@link tv.rewinside.rewimod.core.handlers.IMessageHandler}
*/
public abstract IMessageHandler getMessageHandler();
}