Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added private messaging #3

Open
wants to merge 16 commits into
base: master
Choose a base branch
from
Prev Previous commit
Next Next commit
fix plugin crash when players chatting locally in separate worlds
violanes committed Dec 1, 2022
commit 164a91b3857fac2a9fe4a6850225bd4454313fbc
15 changes: 11 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
# VioChat
##### VioChat - simple minecraft plugin for chatting in 3 different channels: local ( 100 blocks ), global and admin ( special permission required ). Displays prefixes, suffixes and whatever you want.
VioChat - simple minecraft plugin for chatting in 3 different channels: local ( 100 blocks ), global and admin ( special permission required ). Displays prefixes, suffixes and whatever you want.

##### features
- local chat (defaults to 100 blocks radius)
- roleplay chat
- admin chat
- global chat
- private chat

[DOWNLOAD](https://github.com/violanes/VioChat/blob/master/VioChat.jar?raw=true)

> #### Required:
> * Vault ( latest build )
> * Spigot / bukkit ( 1.8 + )
> * Vault (latest build)
> * Spigot / bukkit (1.8+)

Big coder: [violanes](https://github.com/violanes)
developer: [violanes](https://github.com/violanes)
Binary file modified VioChat.jar
Binary file not shown.
25 changes: 14 additions & 11 deletions src/space/deniska/VioChat.java
Original file line number Diff line number Diff line change
@@ -58,7 +58,7 @@ public void onEnable( )
@EventHandler
public void onChatEvent( AsyncPlayerChatEvent e )
{
int m_iChatType = 0;
int iChatType = 0;

Player m_Recipient = e.getPlayer( );

@@ -78,20 +78,20 @@ public void onChatEvent( AsyncPlayerChatEvent e )
template = "Chats.Global.Template";
m_szColor = SettingsManager.getInstance( ).getConfig( ).getString( "Chats.Global.Color" );
raw = raw.substring( GlobalSymbol.length( ) );
m_iChatType = 1;
iChatType = 1;
}
else if ( raw.startsWith( AdminSymbol ) && e.getPlayer().hasPermission( "viochat.admin" ) )
{
template = "Chats.Admin.Template";
m_szColor = SettingsManager.getInstance( ).getConfig( ).getString( "Chats.Admin.Color" );
raw = raw.substring( AdminSymbol.length( ) );
m_iChatType = 2;
iChatType = 2;
}
else if ( raw.startsWith( RPSymbol ) )
{
template = "Chats.Roleplay.Template";
m_szColor = SettingsManager.getInstance( ).getConfig( ).getString( "Chats.Roleplay.Color" );
m_iChatType = 4;
iChatType = 4;
raw = raw.substring( RPSymbol.length( ) );
}
else
@@ -107,13 +107,13 @@ else if ( raw.startsWith( RPSymbol ) )

for ( Player tempPlayer : e.getRecipients( ) )
{
if ( raw.startsWith( tempPlayer.getDisplayName( ) + SettingsManager.getInstance( ).getConfig( ).getString( "Chats.Private.Symbol" ) ) && m_iChatType == 0 )
if ( raw.startsWith( tempPlayer.getDisplayName( ) + SettingsManager.getInstance( ).getConfig( ).getString( "Chats.Private.Symbol" ) ) && iChatType == 0 )
{
if ( tempPlayer == e.getPlayer( ) )
continue;

m_Recipient = tempPlayer;
m_iChatType = 3;
iChatType = 3;

msg = SettingsManager.getInstance( ).getConfig( ).getString( "Chats.Private.Template" );
m_szColor = SettingsManager.getInstance( ).getConfig( ).getString( "Chats.Private.Color" ).replace( "&", "§" );
@@ -142,14 +142,17 @@ else if ( raw.startsWith( RPSymbol ) )

Location pLoc = e.getPlayer( ).getLocation( );

int m_iDistance = SettingsManager.getInstance( ).getConfig( ).getInt( "Chats." + ( ( m_iChatType == 4 ) ? "Roleplay" : "Local" ) + ".Distance" );
int m_iDistance = SettingsManager.getInstance( ).getConfig( ).getInt( "Chats." + ( ( iChatType == 4 ) ? "Roleplay" : "Local" ) + ".Distance" );

for ( Player pl : e.getRecipients( ) )
{
if ( ( pl.getLocation( ).distance( pLoc ) <= m_iDistance && ( m_iChatType == 0 || m_iChatType == 4 ) )
|| ( m_iChatType == 1 )
|| ( m_iChatType == 2 && pl.hasPermission( "viochat.admin" ) )
|| ( m_iChatType == 3 && ( pl == m_Recipient || pl == e.getPlayer( ) ) ) )
if ( pl.getLocation( ).getWorld( ) != pLoc.getWorld( ) && ( iChatType == 0 || iChatType == 4 ) )
continue;

if ( ( pl.getLocation( ).distance( pLoc ) <= m_iDistance && ( iChatType == 0 || iChatType == 4 ) )
|| ( iChatType == 1 )
|| ( iChatType == 2 && pl.hasPermission( "viochat.admin" ) )
|| ( iChatType == 3 && ( pl == m_Recipient || pl == e.getPlayer( ) ) ) )
{
pl.sendMessage( msg );
}