-
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.
- Loading branch information
CoolV1994
committed
Apr 2, 2015
0 parents
commit ba1bbdb
Showing
3 changed files
with
91 additions
and
0 deletions.
There are no files selected for viewing
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,8 @@ | ||
{ | ||
"name": "Spawn", | ||
"version": "1.0", | ||
"mainClass": "tk.coolv1994.plugins.spawn.Spawn", | ||
"commands": { | ||
"spawn": "tk.coolv1994.plugins.spawn.CommandSpawn" | ||
} | ||
} |
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,14 @@ | ||
package tk.coolv1994.plugins.spawn; | ||
|
||
import tk.coolv1994.gawdserver.events.Command; | ||
import tk.coolv1994.gawdserver.launcher.Launch; | ||
|
||
/** | ||
* Created by Vinnie on 2/17/2015. | ||
*/ | ||
public class CommandSpawn implements Command { | ||
@Override | ||
public void onCommand(String player, String[] args) { | ||
Launch.sendCommand("tp " + player + " " + Spawn.coords); | ||
} | ||
} |
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,69 @@ | ||
package tk.coolv1994.plugins.spawn; | ||
|
||
import tk.coolv1994.gawdserver.plugin.Plugin; | ||
|
||
import java.io.*; | ||
|
||
/** | ||
* Created by Vinnie on 2/2/2015. | ||
*/ | ||
public class Spawn implements Plugin { | ||
public static String coords = "0 64 0"; | ||
|
||
@Override | ||
public void startup() { | ||
File configFile = new File("./plugins/Spawn/coordinates.txt"); | ||
if (!configFile.exists()) | ||
{ | ||
configFile.getParentFile().mkdirs(); | ||
try { | ||
FileWriter fw = new FileWriter(configFile); | ||
BufferedWriter bw = new BufferedWriter(fw); | ||
bw.write("# Spawn Coordinates"); | ||
bw.newLine(); | ||
bw.write("x=0"); | ||
bw.newLine(); | ||
bw.write("y=64"); | ||
bw.newLine(); | ||
bw.write("z=0"); | ||
bw.newLine(); | ||
bw.close(); | ||
} catch (IOException e) { | ||
System.out.println("Error creating default Spawn coordinates."); | ||
} | ||
} | ||
else | ||
{ | ||
BufferedReader br = null; | ||
try { | ||
int x = 0; | ||
int y = 64; | ||
int z = 0; | ||
String currentLine; | ||
br = new BufferedReader(new FileReader(configFile)); | ||
while ((currentLine = br.readLine()) != null) { | ||
if (currentLine.startsWith("x=")) | ||
x = Integer.valueOf(currentLine.substring(2)); | ||
if (currentLine.startsWith("y=")) | ||
y = Integer.valueOf(currentLine.substring(2)); | ||
if (currentLine.startsWith("z=")) | ||
z = Integer.valueOf(currentLine.substring(2)); | ||
} | ||
coords = String.format("%d %d %d", x, y, z); | ||
} catch (IOException e) { | ||
System.out.println("Error loading Spawn coordinates."); | ||
} finally { | ||
try { | ||
if (br != null) | ||
br.close(); | ||
} catch (IOException ex) { | ||
ex.printStackTrace(); | ||
} | ||
} | ||
} | ||
} | ||
|
||
@Override | ||
public void shutdown() { | ||
} | ||
} |