-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added support for RocketPlaceholders 2.0
- Loading branch information
1 parent
1efd5a4
commit e02efdf
Showing
8 changed files
with
121 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package me.lorenzo0111.multilang.hooks; | ||
|
||
import me.lorenzo0111.rocketplaceholders.api.IRocketPlaceholdersAPI; | ||
import me.lorenzo0111.rocketplaceholders.creator.Placeholder; | ||
|
||
public interface Hook { | ||
void register(IRocketPlaceholdersAPI api); | ||
void unregister(IRocketPlaceholdersAPI api); | ||
|
||
void addPlaceholder(Placeholder placeholder); | ||
} |
35 changes: 35 additions & 0 deletions
35
src/main/java/me/lorenzo0111/multilang/hooks/LegacyRocketPlaceholdersHook.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package me.lorenzo0111.multilang.hooks; | ||
|
||
import me.lorenzo0111.rocketplaceholders.api.IRocketPlaceholdersAPI; | ||
import me.lorenzo0111.rocketplaceholders.creator.Placeholder; | ||
|
||
import java.util.List; | ||
|
||
public class LegacyRocketPlaceholdersHook implements Hook { | ||
private final List<Placeholder> placeholders; | ||
|
||
public LegacyRocketPlaceholdersHook(List<Placeholder> placeholders) { | ||
this.placeholders = placeholders; | ||
} | ||
|
||
@Override | ||
public void register(IRocketPlaceholdersAPI api) { | ||
this.unregister(api); | ||
|
||
for (Placeholder placeholder : placeholders) { | ||
api.addPlaceholder(placeholder); | ||
} | ||
} | ||
|
||
@Override | ||
public void unregister(IRocketPlaceholdersAPI api) { | ||
for (Placeholder placeholder : placeholders) { | ||
api.removePlaceholder(placeholder.getIdentifier()); | ||
} | ||
} | ||
|
||
@Override | ||
public void addPlaceholder(Placeholder placeholder) { | ||
placeholders.add(placeholder); | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
src/main/java/me/lorenzo0111/multilang/hooks/RocketPlaceholdersHook.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package me.lorenzo0111.multilang.hooks; | ||
|
||
import me.clip.placeholderapi.PlaceholderAPI; | ||
import me.lorenzo0111.rocketplaceholders.RocketPlaceholders; | ||
import me.lorenzo0111.rocketplaceholders.api.IRocketPlaceholdersAPI; | ||
import me.lorenzo0111.rocketplaceholders.creator.Placeholder; | ||
import me.lorenzo0111.rocketplaceholders.exceptions.InvalidConditionException; | ||
import me.lorenzo0111.rocketplaceholders.providers.Provider; | ||
import me.lorenzo0111.rocketplaceholders.storage.StorageManager; | ||
import org.bukkit.OfflinePlayer; | ||
|
||
public class RocketPlaceholdersHook extends Provider implements Hook { | ||
|
||
public RocketPlaceholdersHook(StorageManager manager) { | ||
super(RocketPlaceholders.getInstance(), manager); | ||
} | ||
|
||
@Override | ||
public void register(IRocketPlaceholdersAPI api) { | ||
api.registerProvider(this,"multilang"); | ||
} | ||
|
||
@Override | ||
public void unregister(IRocketPlaceholdersAPI api) { | ||
this.manager.getInternalPlaceholders().clear(); | ||
this.manager.getExternalPlaceholders().clear(); | ||
} | ||
|
||
@Override | ||
public void addPlaceholder(Placeholder placeholder) { | ||
manager.getInternalPlaceholders().add(placeholder); | ||
} | ||
|
||
@Override | ||
public String parse(Placeholder placeholder, OfflinePlayer player, String text) throws InvalidConditionException { | ||
return placeholder.parseJS(PlaceholderAPI.setPlaceholders(player,text)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters