-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHookManager.java
More file actions
98 lines (83 loc) · 3.44 KB
/
HookManager.java
File metadata and controls
98 lines (83 loc) · 3.44 KB
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
package fr.sandro642.github.hook;
import fr.sandro642.github.ConnectLib;
import fr.sandro642.github.enums.ResourceType;
import fr.sandro642.github.enums.lang.CategoriesType;
/**
* HookManager is a class that manages hooks for different resource types.
* It allows for the initialization and management of hooks based on the specified resource type.
*
* @author Sandro642
* @version 1.0
* @see HookManager#BASE_PATH()
* @see HookManager#FILE_LOCATION_KEY()
*/
public class HookManager {
/**
* Singleton instance of HookManager.
* This instance is used to manage hooks for different resource types.
*/
private static HookManager instance;
/**
* connectLib is an instance of ConnectLib that provides access to the library's configuration and utilities.
* It is used throughout the HookManager class to log messages and access other functionalities.
*/
private final ConnectLib connectLib = new ConnectLib();
/**
* Initializes the HookManager with the specified resource type.
*
* @param resourceType the type of resource to initialize the hook for
*/
private static ResourceType resourceType;
/**
* Initializes the hook for the specified resource type.
* * This method sets the resource type for the hook manager and returns the initialized resource type.
*
* @param resourceType
* @return the initialized resource type
*/
public ResourceType initHook(ResourceType resourceType) {
HookManager.resourceType = resourceType;
return HookManager.resourceType;
}
/**
* Sets the file location key based on the resource type.
* This method updates the store with the file location key based on the resource type.
* It handles different resource types such as MC_RESOURCES, MAIN_RESOURCES, and TEST_RESOURCES.
*/
public void FILE_LOCATION_KEY() {
switch (resourceType) {
case MC_RESOURCES:
connectLib.StoreAndRetrieve().store.put(connectLib.StoreAndRetrieve().FILE_LOCATION_KEY, connectLib.MCSupport().getPluginPath());
break;
case MAIN_RESOURCES, TEST_RESOURCES:
connectLib.StoreAndRetrieve().store.put(connectLib.StoreAndRetrieve().FILE_LOCATION_KEY, resourceType.getPath());
break;
default:
connectLib.Logger().CRITICAL(connectLib.LangManager().getMessage(CategoriesType.HOOKMANAGER_CLASS, "general.unsupportedtype", "type", resourceType.toString()));
}
}
public String BASE_PATH() {
switch (resourceType) {
case MC_RESOURCES:
return connectLib.MCSupport().getPluginPath();
case MAIN_RESOURCES, TEST_RESOURCES:
return resourceType.getPath();
default:
String message = connectLib.LangManager().getMessage(CategoriesType.HOOKMANAGER_CLASS, "general.unsupportedtype", "type", resourceType.toString());
connectLib.Logger().CRITICAL(message);
throw new IllegalArgumentException(message);
}
}
/**
* Returns the singleton instance of HookManager.
* This method ensures that only one instance of HookManager is created and returned.
*
* @return the singleton instance of HookManager
*/
public static HookManager getInstance() {
if (instance == null) {
instance = new HookManager();
}
return instance;
}
}