Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c873bf4
commit 9e160f7
Showing
9 changed files
with
135 additions
and
22 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
40 changes: 40 additions & 0 deletions
40
paper/src/main/java/com/denizenscript/denizen/paper/utilities/PaperAdvancedTextImpl.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,40 @@ | ||
package com.denizenscript.denizen.paper.utilities; | ||
|
||
import com.denizenscript.denizen.nms.NMSHandler; | ||
import com.denizenscript.denizen.paper.PaperModule; | ||
import com.denizenscript.denizen.utilities.AdvancedTextImpl; | ||
import net.md_5.bungee.api.ChatColor; | ||
import org.bukkit.Bukkit; | ||
import org.bukkit.entity.Entity; | ||
import org.bukkit.event.inventory.InventoryType; | ||
import org.bukkit.inventory.Inventory; | ||
import org.bukkit.inventory.InventoryHolder; | ||
|
||
public class PaperAdvancedTextImpl extends AdvancedTextImpl { | ||
|
||
@Override | ||
public Inventory createInventory(InventoryHolder holder, int slots, String title) { | ||
return Bukkit.getServer().createInventory(holder, slots, PaperModule.parseFormattedText(title, ChatColor.BLACK)); | ||
} | ||
|
||
@Override | ||
public Inventory createInventory(InventoryHolder holder, InventoryType type, String title) { | ||
return Bukkit.getServer().createInventory(holder, type, PaperModule.parseFormattedText(title, ChatColor.BLACK)); | ||
} | ||
|
||
@Override | ||
public String getTitle(Inventory inventory) { | ||
// TODO: Paper lacks an inventory.getTitle? 0.o | ||
return NMSHandler.getInstance().getTitle(inventory); | ||
} | ||
|
||
@Override | ||
public void setCustomName(Entity entity, String name) { | ||
entity.customName(PaperModule.parseFormattedText(name, ChatColor.WHITE)); | ||
} | ||
|
||
@Override | ||
public String getCustomName(Entity entity) { | ||
return PaperModule.stringifyComponent(entity.customName(), ChatColor.WHITE); | ||
} | ||
} |
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
33 changes: 33 additions & 0 deletions
33
plugin/src/main/java/com/denizenscript/denizen/utilities/AdvancedTextImpl.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,33 @@ | ||
package com.denizenscript.denizen.utilities; | ||
|
||
import com.denizenscript.denizen.nms.NMSHandler; | ||
import org.bukkit.Bukkit; | ||
import org.bukkit.entity.Entity; | ||
import org.bukkit.event.inventory.InventoryType; | ||
import org.bukkit.inventory.Inventory; | ||
import org.bukkit.inventory.InventoryHolder; | ||
|
||
public class AdvancedTextImpl { | ||
|
||
public static AdvancedTextImpl instance = new AdvancedTextImpl(); | ||
|
||
public Inventory createInventory(InventoryHolder holder, int slots, String title) { | ||
return Bukkit.getServer().createInventory(holder, slots, title); | ||
} | ||
|
||
public Inventory createInventory(InventoryHolder holder, InventoryType type, String title) { | ||
return Bukkit.getServer().createInventory(holder, type, title); | ||
} | ||
|
||
public String getTitle(Inventory inventory) { | ||
return NMSHandler.getInstance().getTitle(inventory); | ||
} | ||
|
||
public void setCustomName(Entity entity, String name) { | ||
entity.setCustomName(name); | ||
} | ||
|
||
public String getCustomName(Entity entity) { | ||
return entity.getCustomName(); | ||
} | ||
} |
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