13
0
geforkt von Mirrors/Paper

Cleanups. We use Maven, not Ant.

By: Erik Broes <erikbroes@grum.nl>
Dieser Commit ist enthalten in:
Bukkit/Spigot 2011-01-03 19:17:31 +01:00
Ursprung f7ed510964
Commit 73c430492d
7 geänderte Dateien mit 15 neuen und 221 gelöschten Zeilen

10
paper-api/.gitignore vendored
Datei anzeigen

@ -6,15 +6,11 @@
# netbeans
/nbproject
# we use maven!
/build.xml
# maven
/target
# vim
.*.sw[a-p]
# test stuff (do remove me!)
/sample/test
/sample/build.xml
/sample/build
/sample/dist
/sample/nbproject

12
paper-api/README.md Normale Datei
Datei anzeigen

@ -0,0 +1,12 @@
Bukkit
======
A Minecraft Server API.
Compilation
-----------
We use maven to handle our dependencies.
* Install [.Mmaven 3](http://maven.apache.org/download.html)
* Check out this repo and: `mvn clean install`

Datei anzeigen

@ -1,39 +0,0 @@
<project name="Bukkit" default="dist" basedir=".">
<property name="minecraft" location="../../"/>
<property name="src" location="src"/>
<property name="bin" location="bin"/>
<property name="dist" location="dist"/>
<property name="lib" location="lib"/>
<target name="init">
<mkdir dir="${bin}"/>
<mkdir dir="${lib}"/>
<get src="http://repo2.maven.org/maven2/org/yaml/snakeyaml/1.7/snakeyaml-1.7.jar" dest="${lib}/snakeyaml-1.7.jar"/>
</target>
<target name="compile" depends="init">
<javac srcdir="${src}" destdir="${bin}" includeantruntime="false">
<classpath>
<fileset dir="${lib}">
<include name="snakeyaml-1.7.jar"/>
</fileset>
</classpath>
</javac>
</target>
<target name="dist" depends="compile">
<mkdir dir="${dist}"/>
<jar jarfile="${dist}/Bukkit.jar" basedir="${bin}" />
</target>
<target name="deploy" depends="dist">
<copy file="${dist}/Bukkit.jar" todir="${minecraft}"/>
</target>
<target name="clean">
<delete dir="${bin}"/>
<delete dir="${lib}"/>
<delete dir="${dist}"/>
</target>
</project>

Datei anzeigen

@ -1,42 +0,0 @@
package com.dinnerbone.bukkit.sample;
import org.bukkit.Block;
import org.bukkit.BlockFace;
import org.bukkit.Material;
import org.bukkit.event.block.BlockCanBuildEvent;
import org.bukkit.event.block.BlockListener;
import org.bukkit.event.block.BlockPhysicsEvent;
/**
* Sample block listener
* @author Dinnerbone
*/
public class SampleBlockListener extends BlockListener {
private final SamplePlugin plugin;
public SampleBlockListener(final SamplePlugin plugin) {
this.plugin = plugin;
}
@Override
public void onBlockPhysics(BlockPhysicsEvent event) {
Block block = event.getBlock();
if ((block.getType() == Material.Sand) || (block.getType() == Material.Gravel)) {
Block above = block.getFace(BlockFace.Up);
if (above.getType() == Material.IronBlock) {
event.setCancelled(true);
}
}
}
@Override
public void onBlockCanBuild(BlockCanBuildEvent event) {
Material mat = event.getMaterial();
if (mat.equals(Material.Cactus)) {
event.setBuildable(true);
}
}
}

Datei anzeigen

@ -1,73 +0,0 @@
package com.dinnerbone.bukkit.sample;
import org.bukkit.Location;
import org.bukkit.Player;
import org.bukkit.event.player.PlayerChatEvent;
import org.bukkit.event.player.PlayerEvent;
import org.bukkit.event.player.PlayerListener;
import org.bukkit.event.player.PlayerMoveEvent;
/**
* Handle events for all Player related events
* @author Dinnerbone
*/
public class SamplePlayerListener extends PlayerListener {
private final SamplePlugin plugin;
public SamplePlayerListener(SamplePlugin instance) {
plugin = instance;
}
@Override
public void onPlayerJoin(PlayerEvent event) {
System.out.println(event.getPlayer().getName() + " joined the server! :D");
}
@Override
public void onPlayerQuit(PlayerEvent event) {
System.out.println(event.getPlayer().getName() + " left the server! :'(");
}
@Override
public void onPlayerCommand(PlayerChatEvent event) {
String[] split = event.getMessage().split(" ");
Player player = event.getPlayer();
if (split[0].equalsIgnoreCase("/pos")) {
if (split.length == 1) {
Location location = player.getLocation();
player.sendMessage("You are currently at " + location.getX() +"," + location.getY() + "," + location.getZ() +
" with " + location.getYaw() + " yaw and " + location.getPitch() + " pitch");
} else if (split.length == 4) {
try {
double x = Double.parseDouble(split[1]);
double y = Double.parseDouble(split[2]);
double z = Double.parseDouble(split[3]);
player.teleportTo(new Location(player.getWorld(), x, y, z));
} catch (NumberFormatException ex) {
player.sendMessage("Given location is invalid");
}
} else {
player.sendMessage("Usage: '/pos' to get current position, or '/pos x y z' to teleport to x,y,z");
}
event.setCancelled(true);
} else if (split[0].equalsIgnoreCase("/debug")) {
plugin.setDebugging(player, !plugin.isDebugging(player));
event.setCancelled(true);
}
}
@Override
public void onPlayerMove(PlayerMoveEvent event) {
if (plugin.isDebugging(event.getPlayer())) {
Location from = event.getFrom();
Location to = event.getTo();
System.out.println(String.format("From %.2f,%.2f,%.2f to %.2f,%.2f,%.2f", from.getX(), from.getY(), from.getZ(), to.getX(), to.getY(), to.getZ()));
}
}
}

Datei anzeigen

@ -1,58 +0,0 @@
package com.dinnerbone.bukkit.sample;
import java.io.File;
import java.util.HashMap;
import org.bukkit.Player;
import org.bukkit.Server;
import org.bukkit.event.Event.Priority;
import org.bukkit.event.Event;
import org.bukkit.plugin.PluginDescriptionFile;
import org.bukkit.plugin.PluginLoader;
import org.bukkit.plugin.java.JavaPlugin;
/**
* Sample plugin for Bukkit
*
* @author Dinnerbone
*/
public class SamplePlugin extends JavaPlugin {
private final SamplePlayerListener playerListener = new SamplePlayerListener(this);
private final SampleBlockListener blockListener = new SampleBlockListener(this);
private final HashMap<Player, Boolean> debugees = new HashMap<Player, Boolean>();
public SamplePlugin(PluginLoader pluginLoader, Server instance, PluginDescriptionFile desc, File plugin, ClassLoader cLoader) {
super(pluginLoader, instance, desc, plugin, cLoader);
registerEvents();
}
public void onDisable() {
System.out.println("Goodbye world!");
}
public void onEnable() {
System.out.println("Hello world!");
}
private void registerEvents() {
getServer().getPluginManager().registerEvent(Event.Type.PLAYER_JOIN, playerListener, Priority.Normal, this);
getServer().getPluginManager().registerEvent(Event.Type.PLAYER_QUIT, playerListener, Priority.Normal, this);
getServer().getPluginManager().registerEvent(Event.Type.PLAYER_COMMAND, playerListener, Priority.Normal, this);
getServer().getPluginManager().registerEvent(Event.Type.PLAYER_MOVE, playerListener, Priority.Normal, this);
getServer().getPluginManager().registerEvent(Event.Type.BLOCK_PHYSICS, blockListener, Priority.Normal, this);
getServer().getPluginManager().registerEvent(Event.Type.BLOCK_CANBUILD, blockListener, Priority.Normal, this);
}
public boolean isDebugging(final Player player) {
if (debugees.containsKey(player)) {
return debugees.get(player);
} else {
return false;
}
}
public void setDebugging(final Player player, final boolean value) {
debugees.put(player, value);
}
}

Datei anzeigen

@ -1,2 +0,0 @@
name: Sample Plugin
main: com.dinnerbone.bukkit.sample.SamplePlugin