Skip to content

Commit 6d4b306

Browse files
committed
Move changes to module fabric-dev-debug-api-v1
1 parent fd8f86e commit 6d4b306

File tree

19 files changed

+186
-73
lines changed

19 files changed

+186
-73
lines changed

build.gradle

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -617,7 +617,8 @@ void setupRepositories(RepositoryHandler repositories) {
617617
// These modules are not included in the fat jar, maven will resolve them via the pom.
618618
def devOnlyModules = [
619619
"fabric-client-gametest-api-v1",
620-
"fabric-gametest-api-v1"
620+
"fabric-gametest-api-v1",
621+
"fabric-dev-debug-api-v1"
621622
]
622623

623624
dependencies {

fabric-api-base/src/main/java/net/fabricmc/fabric/impl/base/event/EventFactoryImpl.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
import net.minecraft.resources.Identifier;
3434

3535
import net.fabricmc.fabric.api.event.Event;
36-
import net.fabricmc.fabric.impl.test.TestableEventFactoryImpl;
3736

3837
public class EventFactoryImpl {
3938
public static final EventFactoryImpl INSTANCE = ServiceLoader.load(EventFactoryImpl.class).findFirst().orElseGet(EventFactoryImpl::new);
@@ -43,9 +42,7 @@ public class EventFactoryImpl {
4342
protected EventFactoryImpl() {
4443
Class<?> thisClass = getClass();
4544

46-
String validInheritor = TestableEventFactoryImpl.class.getName();
47-
48-
if (thisClass != EventFactoryImpl.class && !thisClass.getName().equals(validInheritor)) {
45+
if (thisClass != EventFactoryImpl.class && !thisClass.getName().equals("net.fabricmc.fabric.impl.test.TestableEventFactoryImpl")) {
4946
throw new IllegalStateException("You are not allowed to create a custom EventFactoryImpl!");
5047
}
5148
}

fabric-debug-api-v1/src/main/java/net/fabricmc/fabric/impl/test/EventScopeImpl.java

Lines changed: 0 additions & 22 deletions
This file was deleted.

fabric-debug-api-v1/src/main/java/net/fabricmc/fabric/impl/test/TestableArrayBackedEvent.java

Lines changed: 0 additions & 25 deletions
This file was deleted.

fabric-debug-api-v1/src/main/java/net/fabricmc/fabric/impl/test/TestableEventFactoryImpl.java

Lines changed: 0 additions & 13 deletions
This file was deleted.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
version = getSubprojectVersion(project)
2+
3+
moduleDependencies(project, [
4+
'fabric-api-base'
5+
])
6+
7+
testDependencies(project, [
8+
])

fabric-debug-api-v1/src/main/java/net/fabricmc/fabric/api/test/EventScope.java renamed to fabric-dev-debug-api-v1/src/main/java/net/fabricmc/fabric/api/devdebug/v1/EventScope.java

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,27 @@
1-
package net.fabricmc.fabric.api.test;
1+
/*
2+
* Copyright (c) 2016, 2017, 2018, 2019 FabricMC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package net.fabricmc.fabric.api.devdebug.v1;
218

319
import org.jetbrains.annotations.ApiStatus;
420

521
import net.minecraft.resources.Identifier;
622

723
import net.fabricmc.fabric.api.event.Event;
8-
import net.fabricmc.fabric.impl.test.EventTestingImpl;
24+
import net.fabricmc.fabric.impl.devdebug.v1.EventTestingImpl;
925

1026
/**
1127
* Represents a wrapper around a short-lived {@link Event}.
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/*
2+
* Copyright (c) 2016, 2017, 2018, 2019 FabricMC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package net.fabricmc.fabric.impl.devdebug.v1;
18+
19+
import net.minecraft.resources.Identifier;
20+
21+
import net.fabricmc.fabric.api.devdebug.v1.EventScope;
22+
23+
public class EventScopeImpl<T> implements EventScope {
24+
private final TestableArrayBackedEvent<T> event;
25+
private final Identifier phase;
26+
private final T listener;
27+
28+
public EventScopeImpl(TestableArrayBackedEvent<T> event, Identifier phase, T listener) {
29+
this.event = event;
30+
this.phase = phase;
31+
this.listener = listener;
32+
}
33+
34+
@Override
35+
public void close() {
36+
event.unregister(phase, listener);
37+
}
38+
}

fabric-debug-api-v1/src/main/java/net/fabricmc/fabric/impl/test/EventTestingImpl.java renamed to fabric-dev-debug-api-v1/src/main/java/net/fabricmc/fabric/impl/devdebug/v1/EventTestingImpl.java

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,25 @@
1-
package net.fabricmc.fabric.impl.test;
1+
/*
2+
* Copyright (c) 2016, 2017, 2018, 2019 FabricMC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package net.fabricmc.fabric.impl.devdebug.v1;
218

319
import net.minecraft.resources.Identifier;
420

21+
import net.fabricmc.fabric.api.devdebug.v1.EventScope;
522
import net.fabricmc.fabric.api.event.Event;
6-
import net.fabricmc.fabric.api.test.EventScope;
723
import net.fabricmc.loader.api.FabricLoader;
824

925
public final class EventTestingImpl {
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/*
2+
* Copyright (c) 2016, 2017, 2018, 2019 FabricMC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package net.fabricmc.fabric.impl.devdebug.v1;
18+
19+
import java.util.Objects;
20+
import java.util.function.Function;
21+
22+
import net.minecraft.resources.Identifier;
23+
24+
import net.fabricmc.fabric.impl.base.event.ArrayBackedEvent;
25+
26+
public class TestableArrayBackedEvent<T> extends ArrayBackedEvent<T> {
27+
TestableArrayBackedEvent(Class<? super T> type, Function<T[], T> invokerFactory) {
28+
super(type, invokerFactory);
29+
}
30+
31+
public void unregister(Identifier phaseIdentifier, T listener) {
32+
Objects.requireNonNull(phaseIdentifier, "Tried to unregister a listener for a null phase!");
33+
Objects.requireNonNull(listener, "Tried to unregister a null listener!");
34+
35+
synchronized (lock) {
36+
if (getOrCreatePhase(phaseIdentifier, false).removeListener(listener)) {
37+
rebuildInvoker(handlers.length - 1);
38+
}
39+
}
40+
}
41+
}

0 commit comments

Comments
 (0)