Skip to content

Commit 66e1e97

Browse files
committed
removed Center function for motd
1 parent 24c0cfd commit 66e1e97

46 files changed

Lines changed: 829 additions & 342 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

core/pom.xml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,12 @@
66
<parent>
77
<groupId>com.samvolvo</groupId>
88
<artifactId>MaintainMe</artifactId>
9-
<version>2.0</version>
9+
<version>2.1</version>
10+
<relativePath>../pom.xml</relativePath>
1011
</parent>
1112

1213
<artifactId>MaintainMe-core</artifactId>
14+
<version>${maintainme.version}</version>
1315

1416
<build>
1517
<resources>

core/src/main/java/com/samvolvo/maintainme/MaintainMe.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public void onEnable(){
5151
plugin = this;
5252
saveDefaultConfig();
5353
loadConfig();
54-
SamVolvoLogger.loading("MaintainMe 2.0 bèta");
54+
SamVolvoLogger.loading("MaintainMe " + getDescription().getVersion());
5555
nmsHandler = createNMSHandler();
5656
SamVolvoLogger.loading("Version Supported");
5757

@@ -171,9 +171,9 @@ private NMSHandler createNMSHandler() throws RuntimeException {
171171
Class<? extends NMSHandler> clazz = (Class<? extends NMSHandler>) Class.forName(clazzName);
172172
return clazz.getConstructor().newInstance();
173173
} catch (ClassNotFoundException exception) {
174-
throw new RuntimeException("Can't instantiate NMSHandlerImpl for version " + getMinecraftVersion() +
175-
" (class " + clazzName + " not found. This usually means that this Minecraft version is not " +
176-
"supported by this version of the plugin.)", exception);
174+
getSamVolvoLogger().error(getMinecraftVersion() + " is not supported by MaintainMe");
175+
onDisable();
176+
return null;
177177
} catch (InvocationTargetException exception) {
178178
throw new RuntimeException("Can't instantiate NMSHandlerImpl for version " + getMinecraftVersion() +
179179
" (constructor in class " + clazzName + " threw an exception)", exception);

core/src/main/resources/config.yml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,16 @@ prefix: "&a[Maintain&dMe]"
2626

2727
# motd supports color codes.
2828
motd:
29+
enabled: true
2930
normal:
30-
line1: "A Minecraft Server."
31-
line2: ""
31+
motd:
32+
- "&eMaintain&dMe"
33+
- "&aServer is online."
3234
centered: false
3335
maintenance:
34-
line1: "&dMaintainMe"
35-
line2: "&eWe are currently under maintenance!"
36+
motd:
37+
- "&eMaintain&dMe"
38+
- "&aCurrently in &cmaintenance."
3639
centered: true
3740

3841
settings:

dist/dependency-reduced-pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<parent>
44
<artifactId>MaintainMe</artifactId>
55
<groupId>com.samvolvo</groupId>
6-
<version>2.0</version>
6+
<version>2.1</version>
77
</parent>
88
<modelVersion>4.0.0</modelVersion>
99
<artifactId>MaintainMe-dist</artifactId>

dist/pom.xml

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
<parent>
77
<groupId>com.samvolvo</groupId>
88
<artifactId>MaintainMe</artifactId>
9-
<version>2.0</version>
9+
<version>2.1</version>
10+
<relativePath>../pom.xml</relativePath>
1011
</parent>
1112

1213
<artifactId>MaintainMe-dist</artifactId>
@@ -33,107 +34,107 @@
3334
<dependency>
3435
<groupId>com.samvolvo</groupId>
3536
<artifactId>maintainme-core</artifactId>
36-
<version>2.0</version>
37+
<version>${maintainme.version}</version>
3738
</dependency>
3839
<dependency>
3940
<groupId>com.samvolvo</groupId>
4041
<artifactId>maintainme-spigot-1.17</artifactId>
41-
<version>2.0</version>
42+
<version>${maintainme.version}</version>
4243
</dependency>
4344
<dependency>
4445
<groupId>com.samvolvo</groupId>
4546
<artifactId>maintainme-spigot-1.17.1</artifactId>
46-
<version>2.0</version>
47+
<version>${maintainme.version}</version>
4748
</dependency>
4849
<dependency>
4950
<groupId>com.samvolvo</groupId>
5051
<artifactId>maintainme-spigot-1.18</artifactId>
51-
<version>2.0</version>
52+
<version>${maintainme.version}</version>
5253
</dependency>
5354
<dependency>
5455
<groupId>com.samvolvo</groupId>
5556
<artifactId>MaintainMe-spigot-1.18.1</artifactId>
56-
<version>2.0</version>
57+
<version>${maintainme.version}</version>
5758
</dependency>
5859
<dependency>
5960
<groupId>com.samvolvo</groupId>
6061
<artifactId>MaintainMe-spigot-1.18.2</artifactId>
61-
<version>2.0</version>
62+
<version>${maintainme.version}</version>
6263
</dependency>
6364
<dependency>
6465
<groupId>com.samvolvo</groupId>
6566
<artifactId>MaintainMe-spigot-1.19</artifactId>
66-
<version>2.0</version>
67+
<version>${maintainme.version}</version>
6768
</dependency>
6869
<dependency>
6970
<groupId>com.samvolvo</groupId>
7071
<artifactId>MaintainMe-spigot-1.19.1</artifactId>
71-
<version>2.0</version>
72+
<version>${maintainme.version}</version>
7273
</dependency>
7374
<dependency>
7475
<groupId>com.samvolvo</groupId>
7576
<artifactId>MaintainMe-spigot-1.19.2</artifactId>
76-
<version>2.0</version>
77+
<version>${maintainme.version}</version>
7778
</dependency>
7879
<dependency>
7980
<groupId>com.samvolvo</groupId>
8081
<artifactId>MaintainMe-spigot-1.19.3</artifactId>
81-
<version>2.0</version>
82+
<version>${maintainme.version}</version>
8283
</dependency>
8384
<dependency>
8485
<groupId>com.samvolvo</groupId>
8586
<artifactId>MaintainMe-spigot-1.19.4</artifactId>
86-
<version>2.0</version>
87+
<version>${maintainme.version}</version>
8788
</dependency>
8889
<dependency>
8990
<groupId>com.samvolvo</groupId>
9091
<artifactId>MaintainMe-spigot-1.20</artifactId>
91-
<version>2.0</version>
92+
<version>${maintainme.version}</version>
9293
</dependency>
9394
<dependency>
9495
<groupId>com.samvolvo</groupId>
9596
<artifactId>MaintainMe-spigot-1.20.1</artifactId>
96-
<version>2.0</version>
97+
<version>${maintainme.version}</version>
9798
</dependency>
9899
<dependency>
99100
<groupId>com.samvolvo</groupId>
100101
<artifactId>MaintainMe-spigot-1.20.2</artifactId>
101-
<version>2.0</version>
102+
<version>${maintainme.version}</version>
102103
</dependency>
103104
<dependency>
104105
<groupId>com.samvolvo</groupId>
105106
<artifactId>MaintainMe-spigot-1.20.3</artifactId>
106-
<version>2.0</version>
107+
<version>${maintainme.version}</version>
107108
</dependency>
108109
<dependency>
109110
<groupId>com.samvolvo</groupId>
110111
<artifactId>MaintainMe-spigot-1.20.4</artifactId>
111-
<version>2.0</version>
112+
<version>${maintainme.version}</version>
112113
</dependency>
113114
<dependency>
114115
<groupId>com.samvolvo</groupId>
115116
<artifactId>MaintainMe-spigot-1.20.5</artifactId>
116-
<version>2.0</version>
117+
<version>${maintainme.version}</version>
117118
</dependency>
118119
<dependency>
119120
<groupId>com.samvolvo</groupId>
120121
<artifactId>MaintainMe-spigot-1.20.6</artifactId>
121-
<version>2.0</version>
122+
<version>${maintainme.version}</version>
122123
</dependency>
123124
<dependency>
124125
<groupId>com.samvolvo</groupId>
125126
<artifactId>MaintainMe-spigot-1.21</artifactId>
126-
<version>2.0</version>
127+
<version>${maintainme.version}</version>
127128
</dependency>
128129
<dependency>
129130
<groupId>com.samvolvo</groupId>
130131
<artifactId>MaintainMe-spigot-1.21.1</artifactId>
131-
<version>2.0</version>
132+
<version>${maintainme.version}</version>
132133
</dependency>
133134
<dependency>
134135
<groupId>com.samvolvo</groupId>
135136
<artifactId>MaintainMe-spigot-1.21.2</artifactId>
136-
<version>2.0</version>
137+
<version>${maintainme.version}</version>
137138
</dependency>
138139
</dependencies>
139140

pom.xml

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,16 @@
66

77
<groupId>com.samvolvo</groupId>
88
<artifactId>MaintainMe</artifactId>
9-
<version>2.0</version>
9+
<version>2.1</version>
1010
<packaging>pom</packaging>
1111

12+
<properties>
13+
<maintainme.version>2.1</maintainme.version>
14+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
15+
<maven.compiler.source>16</maven.compiler.source>
16+
<maven.compiler.target>16</maven.compiler.target>
17+
</properties>
18+
1219
<modules>
1320
<module>core</module>
1421
<module>dist</module>
@@ -34,12 +41,6 @@
3441
<module>spigot-1.21.2</module>
3542
</modules>
3643

37-
<properties>
38-
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
39-
<maven.compiler.source>16</maven.compiler.source>
40-
<maven.compiler.target>16</maven.compiler.target>
41-
</properties>
42-
4344
<repositories>
4445
<repository>
4546
<id>spigot-repo</id>

spigot-1.17.1/pom.xml

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,20 @@
1-
<?xml version="1.0" encoding="UTF-8"?>
21
<project xmlns="http://maven.apache.org/POM/4.0.0"
32
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4-
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
3+
xsi:schemaLocation="http://maven.apache.org/xsd/maven-4.0.0.xsd">
54
<modelVersion>4.0.0</modelVersion>
65
<parent>
76
<groupId>com.samvolvo</groupId>
87
<artifactId>MaintainMe</artifactId>
9-
<version>2.0</version>
8+
<version>2.1</version>
9+
<relativePath>../pom.xml</relativePath>
1010
</parent>
11-
1211
<artifactId>MaintainMe-spigot-1.17.1</artifactId>
1312

14-
1513
<dependencies>
1614
<dependency>
1715
<groupId>com.samvolvo</groupId>
18-
<artifactId>maintainme-core</artifactId>
19-
<version>2.0</version>
16+
<artifactId>MaintainMe-core</artifactId>
17+
<version>${maintainme.version}</version>
2018
</dependency>
2119
<dependency>
2220
<groupId>org.spigotmc</groupId>
@@ -25,5 +23,4 @@
2523
<scope>provided</scope>
2624
</dependency>
2725
</dependencies>
28-
29-
</project>
26+
</project>

spigot-1.17.1/src/main/java/com/samvolvo/maintainme/nms_1_17_1/ServerListPingListener.java

Lines changed: 36 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,12 @@
33
import com.samvolvo.maintainme.MaintainMe;
44
import com.samvolvo.maintainme.listeners.AbstractServerListPingListener;
55
import org.bukkit.ChatColor;
6+
import org.bukkit.configuration.file.FileConfiguration;
67
import org.bukkit.event.EventHandler;
78
import org.bukkit.event.server.ServerListPingEvent;
89

10+
import java.util.List;
11+
912
public class ServerListPingListener extends AbstractServerListPingListener {
1013
private final MaintainMe plugin;
1114

@@ -15,28 +18,41 @@ public ServerListPingListener(MaintainMe plugin){
1518

1619
@EventHandler
1720
public void onServerListPing(ServerListPingEvent event){
18-
boolean maintenanceMode = plugin.isMaintenanceMode();
19-
if (maintenanceMode){
20-
if (plugin.getConfig().getBoolean("motd.maintenance.centered")){
21-
event.setMotd(plugin.getMotdUtil().getMOTD(plugin.getConfig().getString("motd.maintenanceMode.line1"), plugin.getConfig().getString("motd.maintenanceMode.line2")));
22-
}else{
23-
event.setMotd(ChatColor.translateAlternateColorCodes('&', plugin.getConfig().getString("motd.maintenance.line1")+ "\n" + plugin.getConfig().getString("motd.maintenance.line2")));
24-
}
21+
if (!plugin.getConfig().getBoolean("motd.enabled")){
22+
return;
23+
}
24+
25+
if (getMotd(plugin.getConfig()) == null){
26+
plugin.getSamVolvoLogger().error("No motd found!");
27+
return;
28+
}
29+
30+
List<String> motd = getMotd(plugin.getConfig());
31+
32+
String message = "";
33+
34+
for (String line : motd){
35+
message += ChatColor.translateAlternateColorCodes('&', line + "\n");
36+
}
37+
38+
event.setMotd(message);
39+
setMaxPlayers(event);
40+
}
41+
42+
private List<String> getMotd(FileConfiguration config){
43+
List<String> motd = null;
44+
if (plugin.isMaintenanceMode()){
45+
motd = config.getStringList("motd.maintenance.motd");
46+
}else{
47+
motd = config.getStringList("motd.normal.motd");
48+
}
49+
return motd;
50+
}
51+
52+
private void setMaxPlayers(ServerListPingEvent event){
53+
if (plugin.isMaintenanceMode()){
2554
event.setMaxPlayers(0);
2655
}else{
27-
if (plugin.getConfig().getBoolean("motd.normal.centered")){
28-
if (plugin.getConfig().getString("motd.normal.line1").isEmpty() && plugin.getConfig().getString("motd.normal.line2").isEmpty()){
29-
event.setMotd(plugin.getServer().getMotd());
30-
}else{
31-
event.setMotd(plugin.getMotdUtil().getMOTD(plugin.getConfig().getString("motd.normal.line1"), plugin.getConfig().getString("motd.normal.line2")));
32-
}
33-
}else{
34-
if (plugin.getConfig().getString("motd.normal.line1").isEmpty() && plugin.getConfig().getString("motd.normal.line2").isEmpty()){
35-
event.setMotd(plugin.getServer().getMotd());
36-
}else{
37-
event.setMotd(ChatColor.translateAlternateColorCodes('&', plugin.getConfig().getString("motd.normal.line1") + "\n" + plugin.getConfig().getString("motd.normal.line2")));
38-
}
39-
}
4056
event.setMaxPlayers(plugin.getServer().getMaxPlayers());
4157
}
4258
}

spigot-1.17/pom.xml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
<parent>
77
<groupId>com.samvolvo</groupId>
88
<artifactId>MaintainMe</artifactId>
9-
<version>2.0</version>
9+
<version>2.1</version>
10+
<relativePath>../pom.xml</relativePath>
1011
</parent>
1112

1213
<artifactId>MaintainMe-spigot-1.17</artifactId>
@@ -60,7 +61,7 @@
6061
<dependency>
6162
<groupId>com.samvolvo</groupId>
6263
<artifactId>MaintainMe-core</artifactId>
63-
<version>2.0</version>
64+
<version>${maintainme.version}</version>
6465
</dependency>
6566
</dependencies>
6667

0 commit comments

Comments
 (0)