-
Notifications
You must be signed in to change notification settings - Fork 497
/
PipeManager.java
executable file
·78 lines (65 loc) · 2.61 KB
/
PipeManager.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
/**
* Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team
* http://www.mod-buildcraft.com
*
* The BuildCraft API is distributed under the terms of the MIT License.
* Please check the contents of the license, which should be located
* as "LICENSE.API" in the BuildCraft source code distribution.
*/
package buildcraft.api.transport;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import net.minecraft.world.World;
import buildcraft.api.transport.pluggable.PipePluggable;
public abstract class PipeManager {
public static List<IStripesHandler> stripesHandlers = new ArrayList<IStripesHandler>();
public static ArrayList<Class<? extends PipePluggable>> pipePluggables = new ArrayList<Class<? extends PipePluggable>>();
private static Map<String, Class<? extends PipePluggable>> pipePluggableNames =
new HashMap<String, Class<? extends PipePluggable>>();
private static Map<Class<? extends PipePluggable>, String> pipePluggableByNames =
new HashMap<Class<? extends PipePluggable>, String>();
private static Map<IStripesHandler, Integer> stripesHandlerPriorities =
new HashMap<IStripesHandler, Integer>();
@Deprecated
public static boolean canExtractItems(Object extractor, World world, int i, int j, int k) {
return true;
}
@Deprecated
public static boolean canExtractFluids(Object extractor, World world, int i, int j, int k) {
return true;
}
@Deprecated
public static void registerStripesHandler(IStripesHandler handler) {
registerStripesHandler(handler, 0);
}
/**
* Register a Stripes Pipe handler.
* @param handler The handler.
* @param priority The priority - 0 is normal, higher numbers have higher priority.
*/
public static void registerStripesHandler(IStripesHandler handler, int priority) {
stripesHandlers.add(handler);
stripesHandlerPriorities.put(handler, priority);
Collections.sort(stripesHandlers, new Comparator<IStripesHandler>() {
@Override
public int compare(IStripesHandler o1, IStripesHandler o2) {
return stripesHandlerPriorities.get(o2) - stripesHandlerPriorities.get(o1);
}
});
}
public static void registerPipePluggable(Class<? extends PipePluggable> pluggable, String name) {
pipePluggables.add(pluggable);
pipePluggableNames.put(name, pluggable);
pipePluggableByNames.put(pluggable, name);
}
public static Class<?> getPluggableByName(String pluggableName) {
return pipePluggableNames.get(pluggableName);
}
public static String getPluggableName(Class<? extends PipePluggable> aClass) {
return pipePluggableByNames.get(aClass);
}
}