forked from TownyAdvanced/Towny
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- API: Added TownyObjectFormattedNameEvent
- Thrown when a Resident, Town or Nation is returning a getFormattedName() value. - This is used to alter the prefix or postfix that flanks a TownyObject name, usually a title, surname, townlevel/nationlevel prefix/postfix. - Closes TownyAdvanced#6995.
- Loading branch information
Showing
5 changed files
with
86 additions
and
4 deletions.
There are no files selected for viewing
65 changes: 65 additions & 0 deletions
65
Towny/src/main/java/com/palmergames/bukkit/towny/event/TownyObjectFormattedNameEvent.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,65 @@ | ||
package com.palmergames.bukkit.towny.event; | ||
|
||
import org.bukkit.Bukkit; | ||
import org.bukkit.event.Event; | ||
import org.bukkit.event.HandlerList; | ||
|
||
import com.palmergames.bukkit.towny.object.Nation; | ||
import com.palmergames.bukkit.towny.object.Resident; | ||
import com.palmergames.bukkit.towny.object.Town; | ||
import com.palmergames.bukkit.towny.object.TownyObject; | ||
|
||
public class TownyObjectFormattedNameEvent extends Event { | ||
private static final HandlerList handlers = new HandlerList(); | ||
private final TownyObject object; | ||
private String prefix; | ||
private String postfix; | ||
|
||
public TownyObjectFormattedNameEvent(TownyObject object, String prefix, String postfix) { | ||
super(!Bukkit.getServer().isPrimaryThread()); | ||
this.object = object; | ||
this.prefix = prefix; | ||
this.postfix = postfix; | ||
} | ||
|
||
public String getPrefix() { | ||
return prefix; | ||
} | ||
|
||
public void setPrefix(String prefix) { | ||
this.prefix = prefix; | ||
} | ||
|
||
public String getPostfix() { | ||
return postfix; | ||
} | ||
|
||
public void setPostfix(String postfix) { | ||
this.postfix = postfix; | ||
} | ||
|
||
public TownyObject getTownyObject() { | ||
return object; | ||
} | ||
|
||
public boolean isResident() { | ||
return object instanceof Resident; | ||
} | ||
|
||
public boolean isTown() { | ||
return object instanceof Town; | ||
} | ||
|
||
public boolean isNation() { | ||
return object instanceof Nation; | ||
} | ||
|
||
public static HandlerList getHandlerList() { | ||
return handlers; | ||
} | ||
|
||
@Override | ||
public HandlerList getHandlers() { | ||
return handlers; | ||
} | ||
} |
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