Added a way to customize the sound on name mentioning

You can create a file named "notificationsound.txt" and put a sound name
in the correct format which /playsound uses and the pitch after that.

For example:
mob.pig.say 1.0
This commit is contained in:
Norbi Peti 2015-08-14 12:51:51 +02:00
parent 90e142ae3e
commit 94886af615
15 changed files with 100 additions and 8 deletions

View file

@ -880,3 +880,78 @@ user global configuration and to define the default location to store repositori
not correct please set the HOME environment variable and restart Eclipse. Otherwise Git for Windows and not correct please set the HOME environment variable and restart Eclipse. Otherwise Git for Windows and
EGit might behave differently since they see different configuration options. EGit might behave differently since they see different configuration options.
This warning can be switched off on the Team > Git > Confirmations and Warnings preference page. This warning can be switched off on the Team > Git > Confirmations and Warnings preference page.
!SESSION 2015-08-14 12:09:07.199 -----------------------------------------------
eclipse.buildId=M20130204-1200
java.version=1.8.0_45
java.vendor=Oracle Corporation
BootLoader constants: OS=win32, ARCH=x86_64, WS=win32, NL=hu_HU
Framework arguments: -product org.eclipse.epp.package.jee.product
Command-line arguments: -os win32 -ws win32 -arch x86_64 -product org.eclipse.epp.package.jee.product
!ENTRY org.eclipse.core.resources 2 10035 2015-08-14 12:09:27.930
!MESSAGE The workspace exited with unsaved changes in the previous session; refreshing workspace to recover changes.
!ENTRY org.eclipse.osgi 4 0 2015-08-14 12:10:15.826
!MESSAGE Application error
!STACK 1
org.eclipse.swt.SWTError: No more handles
at org.eclipse.swt.SWT.error(SWT.java:4387)
at org.eclipse.swt.SWT.error(SWT.java:4276)
at org.eclipse.swt.SWT.error(SWT.java:4247)
at org.eclipse.swt.widgets.Widget.error(Widget.java:468)
at org.eclipse.swt.widgets.Control.createHandle(Control.java:704)
at org.eclipse.swt.widgets.Composite.createHandle(Composite.java:305)
at org.eclipse.swt.widgets.Control.createWidget(Control.java:744)
at org.eclipse.swt.widgets.Scrollable.createWidget(Scrollable.java:134)
at org.eclipse.swt.widgets.Control.<init>(Control.java:112)
at org.eclipse.swt.widgets.Scrollable.<init>(Scrollable.java:75)
at org.eclipse.swt.widgets.Composite.<init>(Composite.java:95)
at org.eclipse.ui.splash.BasicSplashHandler.getBundleProgressMonitor(BasicSplashHandler.java:159)
at org.eclipse.ui.splash.BasicSplashHandler.getContent(BasicSplashHandler.java:265)
at org.eclipse.ui.internal.splash.EclipseSplashHandler.init(EclipseSplashHandler.java:91)
at org.eclipse.ui.internal.Workbench$6.run(Workbench.java:751)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
at org.eclipse.ui.internal.Workbench.createSplashWrapper(Workbench.java:772)
at org.eclipse.ui.internal.Workbench.access$5(Workbench.java:690)
at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:568)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:543)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:124)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:353)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:180)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:629)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:584)
at org.eclipse.equinox.launcher.Main.run(Main.java:1438)
!SESSION 2015-08-14 12:09:07.186 -----------------------------------------------
eclipse.buildId=M20130204-1200
java.version=1.8.0_45
java.vendor=Oracle Corporation
BootLoader constants: OS=win32, ARCH=x86_64, WS=win32, NL=hu_HU
Framework arguments: -product org.eclipse.epp.package.jee.product
Command-line arguments: -os win32 -ws win32 -arch x86_64 -product org.eclipse.epp.package.jee.product
!ENTRY org.eclipse.core.resources 2 10035 2015-08-14 12:15:27.853
!MESSAGE The workspace exited with unsaved changes in the previous session; refreshing workspace to recover changes.
!ENTRY org.eclipse.egit.ui 2 0 2015-08-14 12:16:14.774
!MESSAGE Warning: EGit couldn't detect the installation path "gitPrefix" of native Git. Hence EGit can't respect system level
Git settings which might be configured in ${gitPrefix}/etc/gitconfig under the native Git installation directory.
The most important of these settings is core.autocrlf. Git for Windows by default sets this parameter to true in
this system level configuration. The Git installation location can be configured on the
Team > Git > Configuration preference page's 'System Settings' tab.
This warning can be switched off on the Team > Git > Confirmations and Warnings preference page.
!ENTRY org.eclipse.egit.ui 2 0 2015-08-14 12:16:14.774
!MESSAGE Warning: The environment variable HOME is not set. The following directory will be used to store the Git
user global configuration and to define the default location to store repositories: 'C:\Users\Norbi'. If this is
not correct please set the HOME environment variable and restart Eclipse. Otherwise Git for Windows and
EGit might behave differently since they see different configuration options.
This warning can be switched off on the Team > Git > Confirmations and Warnings preference page.

Binary file not shown.

Binary file not shown.

View file

@ -1,18 +1,18 @@
INDEX VERSION 1.126+D:\Z - Norbi cucca\0 Projektek\TheButtonMCAutoFlairProto\Spigot plugin\.metadata\.plugins\org.eclipse.jdt.core INDEX VERSION 1.126+D:\Z - Norbi cucca\0 Projektek\TheButtonMCAutoFlairProto\Spigot plugin\.metadata\.plugins\org.eclipse.jdt.core
3656756579.index 1508644233.index
3089967703.index 3089967703.index
2674037006.index 2674037006.index
323251068.index 323251068.index
355369697.index 355369697.index
1934142626.index
3716007315.index 3716007315.index
1934142626.index
1045485630.index 1045485630.index
605290374.index 605290374.index
533208796.index 533208796.index
1337478678.index 1337478678.index
1528680760.index 1528680760.index
1467104569.index
1737447423.index 1737447423.index
1467104569.index
4187470955.index 4187470955.index
2535676096.index 2535676096.index
1787405673.index 1787405673.index
@ -23,4 +23,4 @@ INDEX VERSION 1.126+D:\Z - Norbi cucca\0 Projektek\TheButtonMCAutoFlairProto\Spi
994834796.index 994834796.index
3604769962.index 3604769962.index
3045053200.index 3045053200.index
1508644233.index 3656756579.index

View file

@ -14,4 +14,5 @@
<workingSet aggregate="true" factoryID="org.eclipse.ui.internal.WorkingSetFactory" id="1439229760994_11" label="Window Working Set" name="Aggregate for window 1439229760993"/> <workingSet aggregate="true" factoryID="org.eclipse.ui.internal.WorkingSetFactory" id="1439229760994_11" label="Window Working Set" name="Aggregate for window 1439229760993"/>
<workingSet aggregate="true" factoryID="org.eclipse.ui.internal.WorkingSetFactory" id="1439240033242_12" label="Window Working Set" name="Aggregate for window 1439240033242"/> <workingSet aggregate="true" factoryID="org.eclipse.ui.internal.WorkingSetFactory" id="1439240033242_12" label="Window Working Set" name="Aggregate for window 1439240033242"/>
<workingSet aggregate="true" factoryID="org.eclipse.ui.internal.WorkingSetFactory" id="1439375909808_13" label="Window Working Set" name="Aggregate for window 1439375909807"/> <workingSet aggregate="true" factoryID="org.eclipse.ui.internal.WorkingSetFactory" id="1439375909808_13" label="Window Working Set" name="Aggregate for window 1439375909807"/>
<workingSet aggregate="true" factoryID="org.eclipse.ui.internal.WorkingSetFactory" id="1439547362478_14" label="Window Working Set" name="Aggregate for window 1439547362478"/>
</workingSetManager> </workingSetManager>

Binary file not shown.

View file

@ -32,6 +32,8 @@ public class PlayerListener implements Listener
{ {
} }
public static String NotificationSound; //2015.08.14.
public static float NotificationPitch; //2015.08.14.
@EventHandler @EventHandler
public void onPlayerChat(AsyncPlayerChatEvent event) public void onPlayerChat(AsyncPlayerChatEvent event)
{ {
@ -43,7 +45,12 @@ public class PlayerListener implements Listener
for(Player p : PluginMain.GetPlayers()) for(Player p : PluginMain.GetPlayers())
{ //2015.08.12. { //2015.08.12.
if(message.contains(p.getName())) if(message.contains(p.getName()))
{
if(NotificationSound==null)
p.playSound(p.getLocation(), Sound.ORB_PICKUP, 1.0f, 0.5f); //2015.08.12. p.playSound(p.getLocation(), Sound.ORB_PICKUP, 1.0f, 0.5f); //2015.08.12.
else
p.playSound(p.getLocation(), NotificationSound, 1.0f, NotificationPitch); //2015.08.14.
}
message = message.replaceAll(p.getName(), "§6"+p.getName()+"§r"); message = message.replaceAll(p.getName(), "§6"+p.getName()+"§r");
} }
event.setFormat(event.getFormat().substring(0, event.getFormat().indexOf(">"))+flair+"> "+message); //2015.08.08. event.setFormat(event.getFormat().substring(0, event.getFormat().indexOf(">"))+flair+"> "+message); //2015.08.08.

View file

@ -10,7 +10,6 @@ import java.io.InputStream;
import java.net.MalformedURLException; import java.net.MalformedURLException;
import java.net.URL; import java.net.URL;
import java.net.URLConnection; import java.net.URLConnection;
import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
@ -367,6 +366,16 @@ public class PluginMain extends JavaPlugin
} }
br.close(); br.close();
} }
file=new File("notificationsound.txt"); //2015.08.09.
if(file.exists())
{
BufferedReader br=new BufferedReader(new FileReader(file));
String line=br.readLine();
String[] split=line.split(" ");
PlayerListener.NotificationSound=split[0];
PlayerListener.NotificationPitch=Float.parseFloat(split[1]);
br.close();
}
//throw new IOException("Test"); //2015.08.09. //throw new IOException("Test"); //2015.08.09.
System.out.println("Auto-flair plugin loaded files!"); System.out.println("Auto-flair plugin loaded files!");
} catch (IOException e) { } catch (IOException e) {