Initial commit

This commit is contained in:
Ian Adam Naval 2014-05-22 04:19:28 -07:00
commit ecc57f3860
9 changed files with 145 additions and 0 deletions

7
.classpath Normal file
View File

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

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
bin/

20
.jardesc Normal file
View File

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

17
.project Normal file
View File

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>WorldHostnames</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>

View File

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

8
config.yml Normal file
View File

@ -0,0 +1,8 @@
enabled: true
worlds:
spawn:
- spawn.localhost
- localhost
- 127.0.0.1
race:
- race.localhost

6
plugin.yml Normal file
View File

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

View File

@ -0,0 +1,54 @@
package com.ianonavy.worldhostnames;
import java.util.List;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerLoginEvent;
public class PlayerLoginListener implements Listener {
WorldHostnames plugin;
public PlayerLoginListener(WorldHostnames plugin) {
this.plugin = plugin;
plugin.getServer().getPluginManager().registerEvents(this, plugin);
}
@EventHandler(priority = EventPriority.HIGHEST)
public void onPlayerLogin(PlayerLoginEvent event) {
String hostname = event.getHostname().toString();
hostname = hostname.substring(0, hostname.indexOf('.'));
final Player player = event.getPlayer();
final World world = getWorld(hostname);
if (world == null || world == player.getWorld()) {
return;
}
final Location destination = getDestination(world);
this.plugin.getServer().getScheduler().scheduleSyncDelayedTask(this.plugin,
new Runnable() {
public void run() {
player.teleport(destination);
}
}, 1L);
}
public World getWorld(String hostname) {
FileConfiguration config = this.plugin.getConfig();
List
this.plugin.getLogger().info(hostList.toString());
return null;
}
public Location getDestination(World world) {
return world.getSpawnLocation();
}
}

View File

@ -0,0 +1,20 @@
package com.ianonavy.worldhostnames;
import org.bukkit.plugin.java.JavaPlugin;
public class WorldHostnames extends JavaPlugin {
@Override
public void onEnable() {
this.getConfig().options().copyDefaults(true);
this.saveConfig();
new PlayerLoginListener(this);
getLogger().info(this.toString() + " enabled.");
}
@Override
public void onDisable() {
getLogger().info(this.toString() + " disabled.");
}
}