That works, but DAFUQ?

This commit is contained in:
Shevchik 2013-09-01 08:05:16 +04:00
parent b919975d1c
commit 5147416dc9
20 changed files with 171 additions and 1624 deletions

9
.classpath Normal file
View 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"/>
<classpathentry kind="lib" path="C:/Users/Shevchik/Documents/GitHub/Chairs/libs/ProtocolLib-2.6.1-SNAPSHOT.jar"/>
<classpathentry kind="lib" path="C:/Users/Shevchik/Documents/GitHub/Chairs/libs/bukkit-1.6.2-R0.2-20130829.060124-15.jar"/>
<classpathentry kind="lib" path="C:/Users/Shevchik/Documents/GitHub/Chairs/libs/craftbukkit-1.6.2-R0.2-20130830.024149-24.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View File

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<launchConfiguration type="org.eclipse.ant.AntBuilderLaunchConfigurationType">
<booleanAttribute key="org.eclipse.ant.ui.ATTR_TARGETS_UPDATED" value="true"/>
<booleanAttribute key="org.eclipse.ant.ui.DEFAULT_VM_INSTALL" value="false"/>
<booleanAttribute key="org.eclipse.debug.ui.ATTR_LAUNCH_IN_BACKGROUND" value="false"/>
<stringAttribute key="org.eclipse.jdt.launching.CLASSPATH_PROVIDER" value="org.eclipse.ant.ui.AntClasspathProvider"/>
<booleanAttribute key="org.eclipse.jdt.launching.DEFAULT_CLASSPATH" value="true"/>
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="Chairs"/>
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_LOCATION" value="${workspace_loc:/Chairs/build.xml}"/>
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_RUN_BUILD_KINDS" value="full,incremental,"/>
<booleanAttribute key="org.eclipse.ui.externaltools.ATTR_TRIGGERS_CONFIGURED" value="true"/>
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_WORKING_DIRECTORY" value="${workspace_loc:/Chairs}"/>
</launchConfiguration>

1
.gitignore vendored
View File

@ -1,3 +1,4 @@
/nbproject/private/
/build/
/dist/
/bin

27
.project Normal file
View File

@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>Chairs</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.ui.externaltools.ExternalToolBuilder</name>
<triggers>full,incremental,</triggers>
<arguments>
<dictionary>
<key>LaunchConfigHandle</key>
<value>&lt;project&gt;/.externalToolBuilders/New_Builder.launch</value>
</dictionary>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>

View File

@ -0,0 +1,2 @@
eclipse.preferences.version=1
encoding/<project>=UTF-8

View File

@ -0,0 +1,2 @@
eclipse.preferences.version=1
line.separator=\n

View File

@ -0,0 +1,2 @@
eclipse.preferences.version=1
org.eclipse.ltk.core.refactoring.enable.project.refactoring.history=false

View File

@ -1,83 +1,18 @@
<?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="Chairs" default="default" basedir=".">
<description>Builds, tests, and runs the project Chairs.</description>
<import file="nbproject/build-impl.xml"/>
<!--
<project name="Chairs" default="build" basedir=".">
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:
<path id="libs">
<fileset dir="libs" includes="**/*.jar" />
</path>
-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 name="build">
<mkdir dir="build/classes" />
<javac source="1.6" target="1.6" encoding="UTF-8" srcdir="src" destdir="build/classes" classpathref="libs" debug="on" />
<copy todir="build/classes">
<fileset file="src/config.yml" />
<fileset file="src/plugin.yml" />
</copy>
<jar destfile="target/Chairs.jar" basedir="build/classes" />
<delete dir="build" />
</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="Chairs-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.
-->
<!--
<target name="-post-jar">
<echo>Copying to DropBox</echo>
<copy file="${dist.jar}" tofile="C:/Users/cnaude/Dropbox/Public/${dist.jar}"/>
<exec dir="dist" executable="c:\Users\cnaude\Apps\pscp.exe">
<arg line="Chairs.jar cnaude.mdns.org:minetest/plugins/Chairs.jar"/>
</exec>
</target> -->
</project>

Binary file not shown.

Binary file not shown.

Binary file not shown.

File diff suppressed because it is too large Load Diff

View File

@ -1,8 +0,0 @@
build.xml.data.CRC32=c7d31434
build.xml.script.CRC32=eeae364c
build.xml.stylesheet.CRC32=28e38971@1.53.1.46
# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
nbproject/build-impl.xml.data.CRC32=c7d31434
nbproject/build-impl.xml.script.CRC32=03b57061
nbproject/build-impl.xml.stylesheet.CRC32=c6d2a60f@1.54.1.46

View File

@ -1,90 +0,0 @@
annotation.processing.enabled=true
annotation.processing.enabled.in.editor=false
annotation.processing.processors.list=
annotation.processing.run.all.processors=true
annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output
application.title=Chairs
application.vendor=cnaude
build.classes.dir=${build.dir}/classes
build.classes.excludes=**/*.java,**/*.form
# This directory is removed when the project is cleaned:
build.dir=build
build.generated.dir=${build.dir}/generated
build.generated.sources.dir=${build.dir}/generated-sources
# Only compile against the classpath explicitly listed here:
build.sysclasspath=ignore
build.test.classes.dir=${build.dir}/test/classes
build.test.results.dir=${build.dir}/test/results
# Uncomment to specify the preferred debugger connection transport:
#debug.transport=dt_socket
debug.classpath=\
${run.classpath}
debug.test.classpath=\
${run.test.classpath}
# This directory is removed when the project is cleaned:
dist.dir=dist
dist.jar=${dist.dir}/Chairs.jar
dist.javadoc.dir=${dist.dir}/javadoc
endorsed.classpath=
excludes=
file.reference.craftbukkit-1.5.2.jar=C:\\Users\\cnaude\\Dropbox\\Development\\Libraries\\craftbukkit-1.5.2.jar
file.reference.craftbukkit-1.5.2.jar-1=/home/naudec/Libraries/craftbukkit-1.5.2.jar
file.reference.ProtocolLib-2.4.1.jar=C:\\Users\\cnaude\\Dropbox\\Development\\Libraries\\ProtocolLib-2.4.1.jar
file.reference.ProtocolLib-2.4.1.jar-1=/home/naudec/Libraries/ProtocolLib-2.4.1.jar
includes=**
jar.archive.disabled=${jnlp.enabled}
jar.compress=false
jar.index=${jnlp.enabled}
javac.classpath=\
${file.reference.craftbukkit-1.5.2.jar}:\
${file.reference.ProtocolLib-2.4.1.jar}:\
${file.reference.craftbukkit-1.5.2.jar-1}:\
${file.reference.ProtocolLib-2.4.1.jar-1}
# Space-separated list of extra javac options
javac.compilerargs=
javac.deprecation=false
javac.processorpath=\
${javac.classpath}
javac.source=1.6
javac.target=1.6
javac.test.classpath=\
${javac.classpath}:\
${build.classes.dir}
javac.test.processorpath=\
${javac.test.classpath}
javadoc.additionalparam=
javadoc.author=false
javadoc.encoding=${source.encoding}
javadoc.noindex=false
javadoc.nonavbar=false
javadoc.notree=false
javadoc.private=false
javadoc.splitindex=true
javadoc.use=true
javadoc.version=false
javadoc.windowtitle=
jnlp.codebase.type=no.codebase
jnlp.descriptor=application
jnlp.enabled=false
jnlp.mixed.code=default
jnlp.offline-allowed=false
jnlp.signed=false
jnlp.signing=
jnlp.signing.alias=
jnlp.signing.keystore=
meta.inf.dir=${src.dir}/META-INF
mkdist.disabled=true
platform.active=default_platform
run.classpath=\
${javac.classpath}:\
${build.classes.dir}
# Space-separated list of JVM arguments used when running the project.
# You may also define separate properties like run-sys-prop.name=value instead of -Dname=value.
# To set system properties for unit tests define test-sys-prop.name=value:
run.jvmargs=
run.test.classpath=\
${javac.test.classpath}:\
${build.test.classes.dir}
source.encoding=UTF-8
src.dir=src
test.src.dir=test

View File

@ -1,15 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://www.netbeans.org/ns/project/1">
<type>org.netbeans.modules.java.j2seproject</type>
<configuration>
<data xmlns="http://www.netbeans.org/ns/j2se-project/3">
<name>Chairs</name>
<source-roots>
<root id="src.dir"/>
</source-roots>
<test-roots>
<root id="test.src.dir"/>
</test-roots>
</data>
</configuration>
</project>

View File

@ -6,17 +6,22 @@ import java.util.HashMap;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.event.HandlerList;
import org.bukkit.event.player.PlayerTeleportEvent;
import org.bukkit.permissions.Permission;
import org.bukkit.permissions.PermissionDefault;
import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.java.JavaPlugin;
import com.comphenix.protocol.ProtocolLibrary;
import com.comphenix.protocol.ProtocolManager;
public class Chairs extends JavaPlugin {
private static Chairs instance = null;
public static ChairEffects chairEffects;
@ -32,7 +37,6 @@ public class Chairs extends JavaPlugin {
public int sitEffectInterval;
private File pluginFolder;
private File configFile;
public byte sitByte;
public HashMap<String, Entity> sit = new HashMap<String, Entity>();
public static final String PLUGIN_NAME = "Chairs";
public static final String LOG_HEADER = "[" + PLUGIN_NAME + "]";
@ -40,6 +44,7 @@ public class Chairs extends JavaPlugin {
public PluginManager pm;
public static ChairsIgnoreList ignoreList;
public String msgSitting, msgStanding, msgOccupied, msgNoPerm, msgReloaded, msgDisabled, msgEnabled;
private ProtocolManager protocolManager;
@Override
public void onEnable() {
@ -59,16 +64,19 @@ public class Chairs extends JavaPlugin {
logInfo("Enabling sitting effects.");
chairEffects = new ChairEffects(this);
}
protocolManager = ProtocolLibrary.getProtocolManager();
new PacketListener(protocolManager, this);
}
@Override
public void onDisable() {
protocolManager.removePacketListeners(this);
protocolManager = null;
for (String pName : sit.keySet()) {
Player player = getServer().getPlayer(pName);
Location loc = player.getLocation().clone();
loc.setY(loc.getY() + 1);
player.teleport(loc, PlayerTeleportEvent.TeleportCause.PLUGIN);
}
if (ignoreList != null) {
ignoreList.save();
@ -76,6 +84,8 @@ public class Chairs extends JavaPlugin {
if (chairEffects != null) {
chairEffects.cancel();
}
HandlerList.unregisterAll(this);
instance = null;
}
public void restartEffectsTask() {
@ -107,8 +117,6 @@ public class Chairs extends JavaPlugin {
}
public void loadConfig() {
sitByte = Byte.parseByte(getConfig().getString("packet"));
logInfo("Sitting packet byte: " + sitByte);
autoRotate = getConfig().getBoolean("auto-rotate");
sneaking = getConfig().getBoolean("sneaking");
signCheck = getConfig().getBoolean("sign-check");

View File

@ -4,6 +4,7 @@ import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.craftbukkit.v1_6_R2.entity.CraftArrow;
import org.bukkit.entity.Entity;
import org.bukkit.entity.ItemFrame;
import org.bukkit.entity.Player;
@ -134,8 +135,6 @@ public class EventListener implements Listener {
}
for (ChairBlock cb : plugin.allowedBlocks) {
//plugin.logInfo("Comparing: (" + cb.getMat().name() + " ? " + block.getType().name() + ") ("
// + cb.getDamage() + " ? " + block.getData() + ")");
if (cb.getMat().toString().contains("STAIRS")) {
if (cb.getMat().equals(block.getType())) {
blockOkay = true;
@ -157,16 +156,12 @@ public class EventListener implements Listener {
if (block.getState().getData() instanceof Stairs) {
stairs = (Stairs) block.getState().getData();
//plugin.logInfo("STAIR");
} else if (block.getState().getData() instanceof Step) {
step = (Step) block.getState().getData();
//plugin.logInfo("STEP");
} else if (block.getState().getData() instanceof WoodenStep) {
wStep = (WoodenStep) block.getState().getData();
//plugin.logInfo("WOODEN_STEP");
} else {
sh += plugin.sittingHeightAdj;
//plugin.logInfo("OTHER");
}
int chairwidth = 1;
@ -237,7 +232,6 @@ public class EventListener implements Listener {
}
// Sit-down process.
if (!plugin.sneaking || (plugin.sneaking && event.getPlayer().isSneaking())) {
if (plugin.seatOccupiedCheck) {
if (!plugin.sit.isEmpty()) {
for (String s : plugin.sit.keySet()) {
@ -268,6 +262,8 @@ public class EventListener implements Listener {
break;
case WEST:
plocation.setYaw(90);
default:
;
}
player.teleport(plocation);
} else {
@ -280,7 +276,6 @@ public class EventListener implements Listener {
player.getPlayer().teleport(plocation);
Entity arrow = block.getWorld().spawnArrow(getBlockCentre(block).subtract(0, 0.5, 0), new Vector(0, 0, 0), 0, 0);
arrow.setPassenger(player);
player.setSneaking(false);
arrow.setTicksLived(1);
@ -289,7 +284,6 @@ public class EventListener implements Listener {
}
}
}
}
// https://github.com/sk89q/craftbook/blob/master/src/main/java/com/sk89q/craftbook/util/BlockUtil.java
public static Location getBlockCentre(Block block) {

View File

@ -0,0 +1,77 @@
package com.cnaude.chairs;
import java.util.HashSet;
import org.bukkit.Bukkit;
import org.bukkit.craftbukkit.v1_6_R2.entity.CraftArrow;
import org.bukkit.entity.Entity;
import com.comphenix.protocol.Packets;
import com.comphenix.protocol.ProtocolManager;
import com.comphenix.protocol.events.ListenerPriority;
import com.comphenix.protocol.events.PacketAdapter;
import com.comphenix.protocol.events.PacketEvent;
public class PacketListener {
private ProtocolManager pm;
private Chairs pluginInstance;
public PacketListener(ProtocolManager pm, Chairs plugin)
{
this.pm = pm;
this.pluginInstance = plugin;
playerDismountListener();
}
private void playerDismountListener()
{
pm.getAsynchronousManager().registerAsyncHandler(
new PacketAdapter(PacketAdapter
.params(pluginInstance, Packets.Client.PLAYER_INPUT)
.clientSide()
.listenerPriority(ListenerPriority.HIGHEST)
.optionIntercept()
)
{
@Override
public void onPacketReceiving(final PacketEvent e)
{
System.out.println("Checking packet");
if (!e.isCancelled())
{
System.out.println(e.getPacket().getBooleans().getValues().get(1));
final String playername = e.getPlayer().getName();
if (e.getPacket().getBooleans().getValues().get(1))
{
Bukkit.getScheduler().scheduleSyncDelayedTask(pluginInstance, new Runnable()
{
public void run()
{
System.out.println("Doing magic");
Entity arrow = pluginInstance.sit.get(playername);
if (arrow != null)
{
net.minecraft.server.v1_6_R2.EntityArrow nmsarrow = ((CraftArrow) arrow).getHandle();
nmsarrow.motX = 0;
nmsarrow.motY = 0;
nmsarrow.motZ = 0;
nmsarrow.boundingBox.b = 0.1;
}
}
});
e.getAsyncMarker().incrementProcessingDelay();
Bukkit.getScheduler().scheduleSyncDelayedTask(pluginInstance, new Runnable()
{
public void run() {
pm.getAsynchronousManager().signalPacketTransmission(e);
}
}, 2);
}
}
}
}).start();
}
}

View File

@ -5,6 +5,7 @@ website: http://dev.bukkit.org/bukkit-plugins/chairsreloaded/
authors:
- spoothie
- cnaude
depend: [ProtocolLib]
main: com.cnaude.chairs.Chairs
commands:
chairs:

BIN
target/Chairs.jar Normal file

Binary file not shown.