MCPcopy Index your code
hub / github.com/ZetaMap/MoreCommands / initEvents

Method initEvents

src/main/java/ContentRegister.java:85–184  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

83 }
84
85 public static void initEvents() {
86 /*
87 // try to modify destroy event to prevent potential error from nucleus
88 Events.on(EventType.BlockDestroyEvent.class, e -> {
89
90 });
91 */
92
93 // clear VNW & RTV votes and disabled it on game over
94 Events.on(EventType.GameOverEvent.class, e -> {
95 PVars.canVote = false;
96 TempData.each(p -> p.votedVNW = false);
97 TempData.each(p -> p.votedRTV = false);
98 PVars.rtvSession.cancel();
99 PVars.vnwSession.cancel();
100 });
101
102 Events.on(EventType.WorldLoadEvent.class, e -> {
103 PVars.canVote = true;// re-enabled votes
104 state.set(State.playing);
105 });
106
107 Events.on(EventType.PlayerConnect.class, e ->
108 Threads.daemon("ConnectCheck_Player-" + e.player.id, () -> {
109 String name = Strings.stripGlyphs(Strings.stripColors(e.player.name)).strip();
110
111 // fix the admin bug
112 if (e.player.getInfo().admin) e.player.admin = true;
113
114 // check if the nickname is empty without colors and emojis
115 if (name.isBlank()) {
116 e.player.kick(KickReason.nameEmpty);
117 return;
118 }
119
120 // check the nickname of this player
121 if (manager.BansManager.checkName(e.player, name)) return;
122
123 // prevent to duplicate nicknames
124 if (TempData.count(d -> d.stripedName.equals(name)) != 0) e.player.kick(KickReason.nameInUse);
125
126 // check if player have a VPN
127 if (util.AntiVpn.checkIP(e.player.ip())) {
128 e.player.kick("[scarlet]VPN detected! []Please deactivate it to be able to connect to this server.");
129 ALog.write("VPN", "VPN found on player @ [@]", name, e.player.uuid());
130 return;
131 }
132 })
133 );
134
135 Events.on(EventType.PlayerJoin.class, e -> {
136 TempData data = TempData.put(e.player); // add player in TempData
137
138 // for me =)
139 if (data.isCreator) {
140 if (PVars.niceWelcome) Call.sendMessage("[scarlet]\ue80f " + data.realName + "[scarlet] has connected! \ue80f [lightgray](Everyone must say: Hello creator! XD)");
141 Call.infoMessage(e.player.con, "Welcome creator! =)");
142 }

Callers 1

moreCommandsPluginMethod · 0.95

Calls 15

eachMethod · 0.95
stripGlyphsMethod · 0.95
countMethod · 0.95
writeMethod · 0.95
putMethod · 0.95
applyTagMethod · 0.95
removeMethod · 0.95
getMethod · 0.95
cancelMethod · 0.80
setMethod · 0.80
checkNameMethod · 0.80
checkIPMethod · 0.80

Tested by

no test coverage detected