Merge branch 'master' of git://github.com/DrAgonmoray/minecraft-ancient-gates

Conflicts:
	src/org/mcteam/ancientgates/MyLocationTypeAdapter.java
	src/org/mcteam/ancientgates/Plugin.java
	src/org/mcteam/ancientgates/commands/CommandSetFrom.java
	src/org/mcteam/ancientgates/listeners/PluginBlockListener.java
	src/org/mcteam/ancientgates/listeners/PluginPlayerListener.java
	src/org/mcteam/ancientgates/util/FloodUtil.java
This commit is contained in:
Tobias Ottenweller 2012-03-10 15:38:54 +01:00
commit 7346044eea
10 changed files with 116 additions and 82 deletions

View File

@ -2,6 +2,10 @@
<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:/Users/Tim/minecraft/bukkit/1000/bukkit-0.0.1-SNAPSHOT.jar" sourcepath="/Bukkit"/>
<classpathentry kind="lib" path="/Volumes/Data HD/Users/tobi/Code/bukkit-1.1-R5-20120224.051137-12.jar" sourcepath="/Users/tobi/Desktop/Bukkit">
<attributes>
<attribute name="javadoc_location" value="http://jd.bukkit.org/apidocs/"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="bin"/>
</classpath>

74
build.xml Normal file
View File

@ -0,0 +1,74 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- You may freely edit this file. See commented blocks below for -->
<!-- some examples of how to customize the build. -->
<!-- (If you delete it and reopen the project it will be recreated.) -->
<!-- By default, only the Clean and Build commands use this build script. -->
<!-- Commands such as Run, Debug, and Test only use this build script if -->
<!-- the Compile on Save feature is turned off for the project. -->
<!-- You can turn off the Compile on Save (or Deploy on Save) setting -->
<!-- in the project's Project Properties dialog box.-->
<project name="AncientGates" default="default" basedir=".">
<description>Builds, tests, and runs the project AncientGates.</description>
<import file="nbproject/build-impl.xml"/>
<!--
There exist several targets which are by default empty and which can be
used for execution of your tasks. These targets are usually executed
before and after some main targets. They are:
-pre-init: called before initialization of project properties
-post-init: called after initialization of project properties
-pre-compile: called before javac compilation
-post-compile: called after javac compilation
-pre-compile-single: called before javac compilation of single file
-post-compile-single: called after javac compilation of single file
-pre-compile-test: called before javac compilation of JUnit tests
-post-compile-test: called after javac compilation of JUnit tests
-pre-compile-test-single: called before javac compilation of single JUnit test
-post-compile-test-single: called after javac compilation of single JUunit test
-pre-jar: called before JAR building
-post-jar: called after JAR building
-post-clean: called after cleaning build products
(Targets beginning with '-' are not intended to be called on their own.)
Example of inserting an obfuscator after compilation could look like this:
<target name="-post-compile">
<obfuscate>
<fileset dir="${build.classes.dir}"/>
</obfuscate>
</target>
For list of available properties check the imported
nbproject/build-impl.xml file.
Another way to customize the build is by overriding existing main targets.
The targets of interest are:
-init-macrodef-javac: defines macro for javac compilation
-init-macrodef-junit: defines macro for junit execution
-init-macrodef-debug: defines macro for class debugging
-init-macrodef-java: defines macro for class execution
-do-jar-with-manifest: JAR building (if you are using a manifest)
-do-jar-without-manifest: JAR building (if you are not using a manifest)
run: execution of project
-javadoc-build: Javadoc generation
test-report: JUnit report generation
An example of overriding the target for project execution could look like this:
<target name="run" depends="AncientGates-impl.jar">
<exec dir="bin" executable="launcher.exe">
<arg file="${dist.jar}"/>
</exec>
</target>
Notice that the overridden target depends on the jar target and not only on
the compile target as the regular run target does. Again, for a list of available
properties which you can use, check the target you are overriding in the
nbproject/build-impl.xml file.
-->
</project>

View File

@ -1,21 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<jardesc>
<jar path="C:/Users/Olof Larsson/Desktop/devserver/plugins/AncientGates.jar"/>
<options buildIfNeeded="true" compress="true" descriptionLocation="/AncientGates/localexport.jardesc" exportErrors="false" exportWarnings="true" includeDirectoryEntries="false" overwrite="true" saveDescription="true" storeRefactorings="false" useSourceFolders="false"/>
<storedRefactorings deprecationInfo="true" structuralOnly="false"/>
<selectedProjects/>
<manifest generateManifest="true" manifestLocation="/Vampire/MANIFEST.MF" manifestVersion="1.0" reuseManifest="false" saveManifest="false" usesManifest="true">
<sealing sealJar="false">
<packagesToSeal/>
<packagesToUnSeal/>
</sealing>
</manifest>
<selectedElements exportClassFiles="true" exportJavaFiles="false" exportOutputFolder="false">
<file path="/AncientGates/README.md"/>
<file path="/AncientGates/plugin.yml"/>
<javaElement handleIdentifier="=AncientGates/src"/>
<file path="/AncientGates/LGPL.txt"/>
<file path="/AncientGates/gson-license.txt"/>
<file path="/AncientGates/LICENCE.txt"/>
</selectedElements>
</jardesc>

View File

@ -1,5 +1,5 @@
name: AncientGates
version: 1.0.1
version: 1.1
main: org.mcteam.ancientgates.Plugin
commands:
gate:

View File

@ -4,8 +4,8 @@ import java.lang.reflect.Type;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.World.Environment;
import org.bukkit.WorldCreator;
import org.mcteam.ancientgates.gson.JsonDeserializationContext;
import org.mcteam.ancientgates.gson.JsonDeserializer;
import org.mcteam.ancientgates.gson.JsonElement;
@ -63,10 +63,9 @@ public class MyLocationTypeAdapter implements JsonDeserializer<Location>, JsonSe
private World getWorld(String name) {
World world = Plugin.instance.getServer().getWorld(name);
if (world == null)
world = Plugin.instance.getServer().createWorld(new WorldCreator(name));
if (world == null) {
world = Plugin.instance.getServer().createWorld(new WorldCreator(name).environment(Environment.NORMAL));
}
return world;
}
}

View File

@ -7,27 +7,12 @@ import java.util.List;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.bukkit.Location;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.plugin.java.JavaPlugin;
import org.mcteam.ancientgates.commands.BaseCommand;
import org.mcteam.ancientgates.commands.CommandClose;
import org.mcteam.ancientgates.commands.CommandCreate;
import org.mcteam.ancientgates.commands.CommandCreateSetFrom;
import org.mcteam.ancientgates.commands.CommandDelete;
import org.mcteam.ancientgates.commands.CommandHelp;
import org.mcteam.ancientgates.commands.CommandInfo;
import org.mcteam.ancientgates.commands.CommandList;
import org.mcteam.ancientgates.commands.CommandOpen;
import org.mcteam.ancientgates.commands.CommandRename;
import org.mcteam.ancientgates.commands.CommandSetFrom;
import org.mcteam.ancientgates.commands.CommandSetTo;
import org.mcteam.ancientgates.commands.*;
import org.mcteam.ancientgates.gson.Gson;
import org.mcteam.ancientgates.gson.GsonBuilder;
@ -35,7 +20,8 @@ import org.mcteam.ancientgates.listeners.PluginBlockListener;
import org.mcteam.ancientgates.listeners.PluginPlayerListener;
public class Plugin extends JavaPlugin {
public class Plugin extends JavaPlugin
{
public static Plugin instance;
public PluginPlayerListener playerListener = new PluginPlayerListener();
@ -52,7 +38,8 @@ public class Plugin extends JavaPlugin {
// Commands
public List<BaseCommand> commands = new ArrayList<BaseCommand>();
public Plugin() {
public Plugin()
{
instance = this;
}
@ -87,7 +74,7 @@ public class Plugin extends JavaPlugin {
// Register events
getServer().getPluginManager().registerEvents(this.playerListener, this);
getServer().getPluginManager().registerEvents(this.blockListener, this);
log("Enabled");
}
@ -108,8 +95,7 @@ public class Plugin extends JavaPlugin {
if (this.baseCommand != null) {
return this.baseCommand;
}
Map<String, Object> Commands = (Map<String, Object>)this.getDescription().getCommands();
Map<String, Map<String, Object>> Commands = (Map<String, Map<String, Object>>) this.getDescription().getCommands();
this.baseCommand = Commands.keySet().iterator().next();
return this.baseCommand;
}

View File

@ -31,7 +31,7 @@ public class CommandSetFrom extends BaseCommand {
player.getLocation().getZ(),
player.getLocation().getYaw(),
player.getLocation().getPitch());
Set<Block> gateBlocks = FloodUtil.getGateFrameBlocks(player.getLocation().getBlock());
if (gateBlocks == null) {
sendMessage("There is no portal here, or your portal is too large.\nMax size is: " + Conf.getGateMaxArea() + " Blocks.");
@ -48,12 +48,12 @@ public class CommandSetFrom extends BaseCommand {
sendMessage("There is not enough room for a gate to open here");
return;
}
sendMessage("From location for gate \""+gate.getId()+"\" is now where you stand.");
sendMessage("Your gate includes " + gateBlocks.size() + " Blocks.");
Gate.save();
}

View File

@ -1,54 +1,47 @@
package org.mcteam.ancientgates.listeners;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockPhysicsEvent;
import org.bukkit.event.EventHandler;
public class PluginBlockListener implements Listener
{
@EventHandler
@EventHandler(priority = EventPriority.NORMAL)
public void onBlockPhysics(BlockPhysicsEvent event)
{
if (event.isCancelled())
return;
if (event.getBlock().getType() != Material.PORTAL)
if (event.getBlock().getType() != Material.PORTAL) {
return;
}
if (isBlockInPortal(event.getBlock()))
if (isBlockInPortal(event.getBlock())) {
event.setCancelled(true);
}
}
public boolean isBlockInPortal(Block block)
{
if (block.getRelative(BlockFace.UP).getType() == Material.AIR)
return false;
if (block.getRelative(BlockFace.DOWN).getType() == Material.AIR)
return false;
if ( block.getRelative(BlockFace.NORTH).getType() != Material.AIR && block.getRelative(BlockFace.SOUTH).getType() != Material.AIR )
return true;
if ( block.getRelative(BlockFace.WEST).getType() != Material.AIR && block.getRelative(BlockFace.EAST).getType() != Material.AIR )
return true;
return false;
}
}

View File

@ -9,8 +9,8 @@ import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerMoveEvent;
@ -20,12 +20,13 @@ import org.mcteam.ancientgates.Plugin;
import org.mcteam.ancientgates.util.GeometryUtil;
public class PluginPlayerListener implements Listener
{
@EventHandler
public class PluginPlayerListener implements Listener
{
@EventHandler(priority = EventPriority.NORMAL)
public void onPlayerMove(PlayerMoveEvent event)
{
if (event.isCancelled())
if (event.isCancelled())
return;
Block blockTo = event.getTo().getBlock();
@ -33,11 +34,9 @@ public class PluginPlayerListener implements Listener
// Check if player is standing inside a portal
if (blockTo.getType() != Material.PORTAL && blockToUp.getType() != Material.PORTAL)
{
if (blockTo.getType() != Material.PORTAL && blockToUp.getType() != Material.PORTAL)
return;
}
// Ok so a player walks into a portal block
// Find the nearest gate!
@ -71,14 +70,14 @@ public class PluginPlayerListener implements Listener
{
nearestGate = gate;
break;
}
}
}
/*if (shortestDistance == -1 || shortestDistance > distance) {
nearestGate = gate;
shortestDistance = distance;
}*/
}
}
if (nearestGate != null)
{

View File

@ -47,7 +47,7 @@ public class FloodUtil {
if (blocks1.size() > blocks2.size()) {
return blocks2;
}
return blocks1;
}
@ -55,11 +55,11 @@ public class FloodUtil {
{
if (foundBlocks == null)
return null;
if (foundBlocks.size() > limit)
{
Plugin.log(Level.ALL, "exceeding gate size limit.");
return null;
return null;
}
if (foundBlocks.contains(startBlock))
@ -77,7 +77,7 @@ public class FloodUtil {
foundBlocks = getAirFloodBlocks(potentialBlock, foundBlocks, expandFaces, limit);
}
}
return foundBlocks;
}