Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
G
Grasscutter
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
ziqian zhang
Grasscutter
Commits
dc26f9e2
Commit
dc26f9e2
authored
3 years ago
by
KingRainbow44
Browse files
Options
Downloads
Patches
Plain Diff
Add plugin data folders
parent
91a2a55e
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/java/emu/grasscutter/plugin/Plugin.java
+23
-5
23 additions, 5 deletions
src/main/java/emu/grasscutter/plugin/Plugin.java
with
23 additions
and
5 deletions
src/main/java/emu/grasscutter/plugin/Plugin.java
+
23
−
5
View file @
dc26f9e2
...
@@ -4,6 +4,7 @@ import emu.grasscutter.Grasscutter;
...
@@ -4,6 +4,7 @@ import emu.grasscutter.Grasscutter;
import
emu.grasscutter.plugin.api.ServerHook
;
import
emu.grasscutter.plugin.api.ServerHook
;
import
emu.grasscutter.server.game.GameServer
;
import
emu.grasscutter.server.game.GameServer
;
import
java.io.File
;
import
java.io.InputStream
;
import
java.io.InputStream
;
import
java.net.URLClassLoader
;
import
java.net.URLClassLoader
;
...
@@ -15,6 +16,7 @@ public abstract class Plugin {
...
@@ -15,6 +16,7 @@ public abstract class Plugin {
private
PluginIdentifier
identifier
;
private
PluginIdentifier
identifier
;
private
URLClassLoader
classLoader
;
private
URLClassLoader
classLoader
;
private
File
dataFolder
;
/**
/**
* This method is reflected into.
* This method is reflected into.
...
@@ -23,11 +25,19 @@ public abstract class Plugin {
...
@@ -23,11 +25,19 @@ public abstract class Plugin {
* @param identifier The plugin's identifier.
* @param identifier The plugin's identifier.
*/
*/
private
void
initializePlugin
(
PluginIdentifier
identifier
,
URLClassLoader
classLoader
)
{
private
void
initializePlugin
(
PluginIdentifier
identifier
,
URLClassLoader
classLoader
)
{
if
(
this
.
identifier
==
null
)
if
(
this
.
identifier
!=
null
)
{
this
.
identifier
=
identifier
;
Grasscutter
.
getLogger
().
warn
(
this
.
identifier
.
name
+
" had a reinitialization attempt."
);
if
(
this
.
classLoader
==
null
)
return
;
this
.
classLoader
=
classLoader
;
}
else
Grasscutter
.
getLogger
().
warn
(
this
.
identifier
.
name
+
" had a reinitialization attempt."
);
this
.
identifier
=
identifier
;
this
.
classLoader
=
classLoader
;
this
.
dataFolder
=
new
File
(
Grasscutter
.
getConfig
().
PLUGINS_FOLDER
,
identifier
.
name
);
if
(!
this
.
dataFolder
.
exists
()
&&
!
this
.
dataFolder
.
mkdirs
())
{
Grasscutter
.
getLogger
().
warn
(
"Failed to create plugin data folder for "
+
this
.
identifier
.
name
);
return
;
}
}
}
/**
/**
...
@@ -76,6 +86,14 @@ public abstract class Plugin {
...
@@ -76,6 +86,14 @@ public abstract class Plugin {
return
this
.
classLoader
.
getResourceAsStream
(
resourceName
);
return
this
.
classLoader
.
getResourceAsStream
(
resourceName
);
}
}
/**
* Returns a directory where plugins can store data files.
* @return A directory on the file system.
*/
public
final
File
getDataFolder
()
{
return
this
.
dataFolder
;
}
/**
/**
* Returns the server hook.
* Returns the server hook.
* @return A server hook singleton.
* @return A server hook singleton.
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment