mirror of
https://github.com/taoneill/war.git
synced 2025-02-16 19:31:22 +01:00
First commit. Basic team joining functionality, that's it.
This commit is contained in:
commit
0d877390da
12
.gitignore
vendored
Normal file
12
.gitignore
vendored
Normal file
@ -0,0 +1,12 @@
|
||||
# Ignore all dotfiles...
|
||||
.*
|
||||
# except for .gitignore
|
||||
!.gitignore
|
||||
!.classpath
|
||||
!.project
|
||||
|
||||
# Ignore all classfiles
|
||||
*.class
|
||||
|
||||
# Ignore bin
|
||||
*/bin/*
|
3
README.txt
Normal file
3
README.txt
Normal file
@ -0,0 +1,3 @@
|
||||
War, a simple hmod plugin that adds team deathmatch to minecraft multiplayer.
|
||||
|
||||
All credit goes to Mojang and hey0 for being so awesome.
|
7
minecraft.hmod.war.test/.classpath
Normal file
7
minecraft.hmod.war.test/.classpath
Normal 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="C:/dev/war/minecraft.hmod.war.test/lib/mockito-all-1.8.5.jar"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
17
minecraft.hmod.war.test/.project
Normal file
17
minecraft.hmod.war.test/.project
Normal file
@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>minecraft.hmod.war.test</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>
|
12
minecraft.hmod.war.test/.settings/org.eclipse.jdt.core.prefs
Normal file
12
minecraft.hmod.war.test/.settings/org.eclipse.jdt.core.prefs
Normal file
@ -0,0 +1,12 @@
|
||||
#Thu Dec 16 22:49:21 EST 2010
|
||||
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
|
BIN
minecraft.hmod.war.test/lib/mockito-all-1.8.5.jar
Normal file
BIN
minecraft.hmod.war.test/lib/mockito-all-1.8.5.jar
Normal file
Binary file not shown.
9
minecraft.hmod.war/.classpath
Normal file
9
minecraft.hmod.war/.classpath
Normal file
@ -0,0 +1,9 @@
|
||||
<?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="C:/dev/war/minecraft.hmod.war/lib/Minecraft_Mod131.jar" sourcepath="/hmod"/>
|
||||
<classpathentry kind="lib" path="C:/dev/war/minecraft.hmod.war/lib/minecraft_server28.jar"/>
|
||||
<classpathentry kind="lib" path="C:/dev/war/minecraft.hmod.war/lib/mysql-connector-java-bin.jar"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
17
minecraft.hmod.war/.project
Normal file
17
minecraft.hmod.war/.project
Normal file
@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>minecraft.hmod.war</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>
|
12
minecraft.hmod.war/.settings/org.eclipse.jdt.core.prefs
Normal file
12
minecraft.hmod.war/.settings/org.eclipse.jdt.core.prefs
Normal file
@ -0,0 +1,12 @@
|
||||
#Sat Dec 11 12:21:43 EST 2010
|
||||
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
|
BIN
minecraft.hmod.war/lib/Minecraft_Mod131.jar
Normal file
BIN
minecraft.hmod.war/lib/Minecraft_Mod131.jar
Normal file
Binary file not shown.
BIN
minecraft.hmod.war/lib/minecraft_server28.jar
Normal file
BIN
minecraft.hmod.war/lib/minecraft_server28.jar
Normal file
Binary file not shown.
BIN
minecraft.hmod.war/lib/mysql-connector-java-bin.jar
Normal file
BIN
minecraft.hmod.war/lib/mysql-connector-java-bin.jar
Normal file
Binary file not shown.
44
minecraft.hmod.war/src/Team.java
Normal file
44
minecraft.hmod.war/src/Team.java
Normal file
@ -0,0 +1,44 @@
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class Team {
|
||||
private List<Player> players = new ArrayList<Player>();
|
||||
private Location teamSpawn = null;
|
||||
private String name;
|
||||
|
||||
public Team(String name, Location teamSpawn) {
|
||||
this.setName(name);
|
||||
this.teamSpawn = teamSpawn;
|
||||
}
|
||||
|
||||
public void setTeamSpawn(Location teamSpawn) {
|
||||
this.teamSpawn = teamSpawn;
|
||||
}
|
||||
|
||||
public Location getTeamSpawn() {
|
||||
return teamSpawn;
|
||||
}
|
||||
|
||||
public void addPlayer(Player player) {
|
||||
this.players.add(player);
|
||||
}
|
||||
|
||||
public List<Player> getPlayers() {
|
||||
return players;
|
||||
}
|
||||
|
||||
public void teamcast(String message) {
|
||||
for(Player player : players) {
|
||||
player.sendMessage(message);
|
||||
}
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
}
|
69
minecraft.hmod.war/src/War.java
Normal file
69
minecraft.hmod.war/src/War.java
Normal file
@ -0,0 +1,69 @@
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
|
||||
|
||||
public class War extends Plugin {
|
||||
|
||||
private WarListener listener = new WarListener(this);
|
||||
private Logger log;
|
||||
String name = "War";
|
||||
String version = "0.1";
|
||||
|
||||
private final List<Team> teams = new ArrayList<Team>();
|
||||
|
||||
public void initialize() {
|
||||
this.log = Logger.getLogger("Minecraft");
|
||||
getLogger().info(name + " " + version + " initialized");
|
||||
|
||||
etc.getLoader().addListener(
|
||||
PluginLoader.Hook.COMMAND,
|
||||
listener,
|
||||
this,
|
||||
PluginListener.Priority.MEDIUM);
|
||||
etc.getLoader().addListener( PluginLoader.Hook.LOGIN,
|
||||
listener,
|
||||
this,
|
||||
PluginListener.Priority.MEDIUM);
|
||||
// etc.getLoader().addListener(
|
||||
// PluginLoader.Hook.BLOCK_CREATED,
|
||||
// listener,
|
||||
// this,
|
||||
// PluginListener.Priority.MEDIUM);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disable() {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enable() {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
public List<Team> getTeams() {
|
||||
return teams;
|
||||
}
|
||||
|
||||
public Team getPlayerTeam(String playerName) {
|
||||
for(Team team : teams) {
|
||||
for(Player player : team.getPlayers()) {
|
||||
if(player.getName().equals(playerName)) {
|
||||
return team;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public Logger getLogger() {
|
||||
return log;
|
||||
}
|
||||
|
||||
}
|
85
minecraft.hmod.war/src/WarListener.java
Normal file
85
minecraft.hmod.war/src/WarListener.java
Normal file
@ -0,0 +1,85 @@
|
||||
import java.util.List;
|
||||
|
||||
public class WarListener extends PluginListener {
|
||||
|
||||
private final War war;
|
||||
|
||||
public WarListener(War war) {
|
||||
this.war = war;
|
||||
}
|
||||
|
||||
public void onLogin(Player player) {
|
||||
player.sendMessage("<war> War is on! You must pick sides (try /teams and /join).");
|
||||
}
|
||||
|
||||
public boolean onCommand(Player player, java.lang.String[] split) {
|
||||
String command = split[0];
|
||||
// /teams
|
||||
if(command.equals("/teams")){
|
||||
String teamsMessage = "<war> Teams: ";
|
||||
for(Team team : war.getTeams()) {
|
||||
teamsMessage += team.getName() + " (";
|
||||
for(Player member : team.getPlayers()) {
|
||||
teamsMessage += member.getName() + " ";
|
||||
}
|
||||
teamsMessage += ") ";
|
||||
}
|
||||
player.sendMessage(teamsMessage);
|
||||
return true;
|
||||
}
|
||||
|
||||
// /newteam <teamname>
|
||||
else if(command.equals("/newteam")) {
|
||||
if(split.length < 2) {
|
||||
player.sendMessage("<war> Usage: /newteam <teamname>");
|
||||
} else {
|
||||
String name = split[1];
|
||||
war.getTeams().add(new Team(name, player.getLocation()));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// /join <teamname>
|
||||
else if(command.equals("/join")) {
|
||||
if(split.length < 2) {
|
||||
player.sendMessage("<war> Usage: /join <teamname>");
|
||||
} else {
|
||||
String name = split[1];
|
||||
List<Team> teams = war.getTeams();
|
||||
boolean foundTeam = false;
|
||||
for(Team team : teams) {
|
||||
if(team.getName().equals(name)) {
|
||||
team.addPlayer(player);
|
||||
foundTeam = true;
|
||||
}
|
||||
}
|
||||
if(foundTeam) {
|
||||
player.sendMessage("<war> Joined " + name);
|
||||
etc.getServer().messageAll("<war> " + player.getName() + " joined " + name);
|
||||
} else {
|
||||
player.sendMessage("<war> No such team. Try /teams.");
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// /team <msg>
|
||||
else if(command.equals("/team")) {
|
||||
if(split.length < 2) {
|
||||
player.sendMessage("<war> Usage: /team <team-only message>");
|
||||
} else {
|
||||
Team playerTeam = war.getPlayerTeam(player.getName());
|
||||
String teamMessage = "<" + playerTeam.getName() + " - " + player.getName() + ":> ";
|
||||
for(int j = 1 ; j<split.length; j++) {
|
||||
String part = split[j];
|
||||
teamMessage += part + " ";
|
||||
}
|
||||
playerTeam.teamcast(teamMessage);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user