Browse Source

Initial commit

Ian Adam Naval 5 years ago
commit
ecc57f3860

+ 7
- 0
.classpath View File

@@ -0,0 +1,7 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<classpath>
3
+	<classpathentry kind="src" path="src"/>
4
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
5
+	<classpathentry kind="lib" path="/home/ian/Downloads/craftbukkit-1.2.5-R1.4-20120512.060225-7.jar"/>
6
+	<classpathentry kind="output" path="bin"/>
7
+</classpath>

+ 1
- 0
.gitignore View File

@@ -0,0 +1 @@
1
+bin/

+ 20
- 0
.jardesc View File

@@ -0,0 +1,20 @@
1
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2
+<jardesc>
3
+    <jar path="/home/ian/server/plugins/WorldHostnames.jar"/>
4
+    <options buildIfNeeded="true" compress="true" descriptionLocation="/WorldHostnames/.jardesc" exportErrors="true" exportWarnings="true" includeDirectoryEntries="false" overwrite="true" saveDescription="true" storeRefactorings="false" useSourceFolders="false"/>
5
+    <storedRefactorings deprecationInfo="true" structuralOnly="false"/>
6
+    <selectedProjects/>
7
+    <manifest generateManifest="true" manifestLocation="" manifestVersion="1.0" reuseManifest="false" saveManifest="false" usesManifest="true">
8
+        <sealing sealJar="false">
9
+            <packagesToSeal/>
10
+            <packagesToUnSeal/>
11
+        </sealing>
12
+    </manifest>
13
+    <selectedElements exportClassFiles="true" exportJavaFiles="false" exportOutputFolder="false">
14
+        <javaElement handleIdentifier="=WorldHostnames/src"/>
15
+        <file path="/WorldHostnames/config.yml"/>
16
+        <file path="/WorldHostnames/plugin.yml"/>
17
+        <file path="/WorldHostnames/.classpath"/>
18
+        <file path="/WorldHostnames/.project"/>
19
+    </selectedElements>
20
+</jardesc>

+ 17
- 0
.project View File

@@ -0,0 +1,17 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<projectDescription>
3
+	<name>WorldHostnames</name>
4
+	<comment></comment>
5
+	<projects>
6
+	</projects>
7
+	<buildSpec>
8
+		<buildCommand>
9
+			<name>org.eclipse.jdt.core.javabuilder</name>
10
+			<arguments>
11
+			</arguments>
12
+		</buildCommand>
13
+	</buildSpec>
14
+	<natures>
15
+		<nature>org.eclipse.jdt.core.javanature</nature>
16
+	</natures>
17
+</projectDescription>

+ 12
- 0
.settings/org.eclipse.jdt.core.prefs View File

@@ -0,0 +1,12 @@
1
+#Sat Jul 02 15:06:31 EDT 2011
2
+eclipse.preferences.version=1
3
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
4
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
5
+org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
6
+org.eclipse.jdt.core.compiler.compliance=1.6
7
+org.eclipse.jdt.core.compiler.debug.lineNumber=generate
8
+org.eclipse.jdt.core.compiler.debug.localVariable=generate
9
+org.eclipse.jdt.core.compiler.debug.sourceFile=generate
10
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
11
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
12
+org.eclipse.jdt.core.compiler.source=1.6

+ 8
- 0
config.yml View File

@@ -0,0 +1,8 @@
1
+enabled: true
2
+worlds:
3
+    spawn:
4
+    - spawn.localhost
5
+    - localhost
6
+    - 127.0.0.1
7
+    race:
8
+    - race.localhost

+ 6
- 0
plugin.yml View File

@@ -0,0 +1,6 @@
1
+name: WorldHostnames
2
+main: com.ianonavy.worldhostnames.WorldHostnames
3
+version: 1.0
4
+website: http://www.ianonavy.com/
5
+description: Redirects users to a specific world when logging in using a certain hostname.
6
+author: ianonavy

+ 54
- 0
src/com/ianonavy/worldhostnames/PlayerLoginListener.java View File

@@ -0,0 +1,54 @@
1
+package com.ianonavy.worldhostnames;
2
+
3
+import java.util.List;
4
+
5
+import org.bukkit.Location;
6
+import org.bukkit.World;
7
+import org.bukkit.configuration.ConfigurationSection;
8
+import org.bukkit.configuration.file.FileConfiguration;
9
+import org.bukkit.entity.Player;
10
+import org.bukkit.event.EventHandler;
11
+import org.bukkit.event.EventPriority;
12
+import org.bukkit.event.Listener;
13
+import org.bukkit.event.player.PlayerLoginEvent;
14
+
15
+public class PlayerLoginListener implements Listener {
16
+	
17
+	WorldHostnames plugin;
18
+	
19
+	public PlayerLoginListener(WorldHostnames plugin) {
20
+		this.plugin = plugin;
21
+		plugin.getServer().getPluginManager().registerEvents(this, plugin);
22
+	}
23
+	
24
+	@EventHandler(priority = EventPriority.HIGHEST)
25
+    public void onPlayerLogin(PlayerLoginEvent event) {
26
+		String hostname = event.getHostname().toString();
27
+		hostname = hostname.substring(0, hostname.indexOf('.'));
28
+        
29
+        final Player player = event.getPlayer();
30
+        final World world = getWorld(hostname);
31
+        if (world == null || world == player.getWorld()) {
32
+        	return;
33
+        }
34
+        final Location destination = getDestination(world);
35
+        
36
+        this.plugin.getServer().getScheduler().scheduleSyncDelayedTask(this.plugin,
37
+                new Runnable() {
38
+                    public void run() {
39
+                        player.teleport(destination);
40
+                    }
41
+        }, 1L);
42
+    }
43
+	
44
+	public World getWorld(String hostname) {
45
+		FileConfiguration config = this.plugin.getConfig();
46
+		List
47
+		this.plugin.getLogger().info(hostList.toString());
48
+		return null;
49
+	}
50
+	
51
+	public Location getDestination(World world) {
52
+		return world.getSpawnLocation();
53
+	}
54
+}

+ 20
- 0
src/com/ianonavy/worldhostnames/WorldHostnames.java View File

@@ -0,0 +1,20 @@
1
+package com.ianonavy.worldhostnames;
2
+
3
+import org.bukkit.plugin.java.JavaPlugin;
4
+
5
+public class WorldHostnames extends JavaPlugin {
6
+	
7
+	@Override
8
+    public void onEnable() {
9
+        this.getConfig().options().copyDefaults(true);
10
+        this.saveConfig();
11
+        
12
+        new PlayerLoginListener(this);
13
+        getLogger().info(this.toString() + " enabled.");
14
+    }
15
+ 
16
+    @Override
17
+    public void onDisable() {
18
+    	getLogger().info(this.toString() + " disabled.");
19
+    }
20
+}

Loading…
Cancel
Save