16
16
import carpet .commands .ProfileCommand ;
17
17
import carpet .fakes .MinecraftServerInterface ;
18
18
import carpet .helpers .ServerTickRateManager ;
19
- import carpet .script .ScriptCommand ;
20
19
import carpet .commands .SpawnCommand ;
21
20
import carpet .commands .TestCommand ;
22
21
import carpet .commands .TickCommand ;
23
22
import carpet .network .ServerNetworkHandler ;
24
23
import carpet .helpers .HopperCounter ;
25
24
import carpet .logging .LoggerRegistry ;
26
- import carpet .script .CarpetScriptServer ;
27
25
import carpet .api .settings .CarpetRule ;
28
26
import carpet .api .settings .InvalidRuleValueException ;
29
27
import carpet .api .settings .SettingsManager ;
30
28
import carpet .logging .HUDController ;
31
- import carpet .script .external .Carpet ;
32
29
import carpet .script .external .Vanilla ;
33
30
import carpet .script .utils .ParticleParser ;
34
31
import carpet .utils .MobAI ;
47
44
public class CarpetServer // static for now - easier to handle all around the code, its one anyways
48
45
{
49
46
public static MinecraftServer minecraft_server ;
50
- public static CarpetScriptServer scriptServer ;
51
47
public static carpet .settings .SettingsManager settingsManager ; // to change type to api type, can't change right now because of binary and source compat
52
48
public static final List <CarpetExtension > extensions = new ArrayList <>();
53
49
@@ -79,7 +75,6 @@ public static void onGameStarted()
79
75
settingsManager .parseSettingsClass (CarpetSettings .class );
80
76
extensions .forEach (CarpetExtension ::onGameStarted );
81
77
//FabricAPIHooks.initialize();
82
- CarpetScriptServer .parseFunctionClasses ();
83
78
}
84
79
85
80
public static void onServerLoaded (MinecraftServer server )
@@ -94,8 +89,6 @@ public static void onServerLoaded(MinecraftServer server)
94
89
if (sm != null ) sm .attachServer (server );
95
90
e .onServerLoaded (server );
96
91
});
97
- scriptServer = new CarpetScriptServer (server );
98
- Carpet .MinecraftServer_addScriptServer (server , scriptServer );
99
92
MobAI .resetTrackers ();
100
93
LoggerRegistry .initLoggers ();
101
94
//TickSpeed.reset();
@@ -106,7 +99,6 @@ public static void onServerLoadedWorlds(MinecraftServer minecraftServer)
106
99
HopperCounter .resetAll (minecraftServer , true );
107
100
extensions .forEach (e -> e .onServerLoadedWorlds (minecraftServer ));
108
101
// initialize scarpet rules after all extensions are loaded
109
- settingsManager .initializeScarpetRules ();
110
102
// run fillLimit rule migration now that gamerules are available
111
103
@ SuppressWarnings ("unchecked" )
112
104
CarpetRule <Integer > fillLimit = (CarpetRule <Integer >) settingsManager .getCarpetRule ("fillLimit" );
@@ -117,21 +109,13 @@ public static void onServerLoadedWorlds(MinecraftServer minecraftServer)
117
109
{
118
110
throw new AssertionError ();
119
111
}
120
- extensions .forEach (e -> {
121
- if (e .extensionSettingsManager () != null )
122
- {
123
- e .extensionSettingsManager ().initializeScarpetRules ();
124
- }
125
- });
126
- scriptServer .initializeForWorld ();
127
112
}
128
113
129
114
public static void tick (MinecraftServer server )
130
115
{
131
116
ServerTickRateManager trm = ((MinecraftServerInterface )server ).getTickRateManager ();
132
117
trm .tick ();
133
118
HUDController .update_hud (server , null );
134
- if (scriptServer != null ) scriptServer .tick ();
135
119
136
120
//in case something happens
137
121
CarpetSettings .impendingFillSkipUpdates .set (false );
@@ -160,7 +144,6 @@ public static void registerCarpetCommands(CommandDispatcher<CommandSourceStack>
160
144
DistanceCommand .register (dispatcher , commandBuildContext );
161
145
PerimeterInfoCommand .register (dispatcher , commandBuildContext );
162
146
DrawCommand .register (dispatcher , commandBuildContext );
163
- ScriptCommand .register (dispatcher , commandBuildContext );
164
147
MobAICommand .register (dispatcher , commandBuildContext );
165
148
// registering command of extensions that has registered before either server is created
166
149
// for all other, they will have them registered when they add themselves
@@ -181,7 +164,6 @@ public static void onPlayerLoggedIn(ServerPlayer player)
181
164
ServerNetworkHandler .onPlayerJoin (player );
182
165
LoggerRegistry .playerConnected (player );
183
166
extensions .forEach (e -> e .onPlayerLoggedIn (player ));
184
- scriptServer .onPlayerJoin (player );
185
167
}
186
168
187
169
@ Deprecated (forRemoval = true )
@@ -194,17 +176,10 @@ public static void onPlayerLoggedOut(ServerPlayer player, Component reason)
194
176
ServerNetworkHandler .onPlayerLoggedOut (player );
195
177
LoggerRegistry .playerDisconnected (player );
196
178
extensions .forEach (e -> e .onPlayerLoggedOut (player ));
197
- // first case client, second case server
198
- CarpetScriptServer runningScriptServer = (player .getServer () == null ) ? scriptServer : Vanilla .MinecraftServer_getScriptServer (player .getServer ());
199
- if (runningScriptServer != null && !runningScriptServer .stopAll ) {
200
- runningScriptServer .onPlayerLoggedOut (player , reason );
201
- }
202
179
}
203
180
204
181
public static void clientPreClosing ()
205
182
{
206
- if (scriptServer != null ) scriptServer .onClose ();
207
- scriptServer = null ;
208
183
}
209
184
210
185
public static void onServerClosed (MinecraftServer server )
@@ -213,13 +188,6 @@ public static void onServerClosed(MinecraftServer server)
213
188
// so we allow to pass multiple times gating it only on existing server ref
214
189
if (minecraft_server != null )
215
190
{
216
- if (scriptServer != null ) scriptServer .onClose ();
217
- // this is a mess, will cleanip onlly when global reference is gone
218
- if (!Vanilla .MinecraftServer_getScriptServer (server ).stopAll ) {
219
- Vanilla .MinecraftServer_getScriptServer (server ).onClose ();
220
- }
221
-
222
- scriptServer = null ;
223
191
ServerNetworkHandler .close ();
224
192
225
193
LoggerRegistry .stopLoggers ();
@@ -245,7 +213,6 @@ public static void registerExtensionLoggers()
245
213
246
214
public static void onReload (MinecraftServer server )
247
215
{
248
- scriptServer .reload (server );
249
216
extensions .forEach (e -> e .onReload (server ));
250
217
}
251
218
0 commit comments