Add missing GPLv3 headers + accidentally add useless javadoc comments.

This commit is contained in:
asofold 2016-06-18 17:57:16 +02:00
parent 9c9210e411
commit bb8c8f4156
74 changed files with 3211 additions and 548 deletions

View File

@ -1,3 +1,17 @@
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package fr.neatmonster.nocheatplus.logging.details;
import fr.neatmonster.nocheatplus.logging.StreamID;

View File

@ -1,3 +1,17 @@
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package fr.neatmonster.nocheatplus.logging.details;
import java.util.logging.Level;

View File

@ -1,3 +1,17 @@
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package fr.neatmonster.nocheatplus.logging.details;
import java.util.logging.Level;

View File

@ -1,3 +1,17 @@
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package fr.neatmonster.nocheatplus.compat.cbreflect.reflect;
/**

View File

@ -1,3 +1,17 @@
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package fr.neatmonster.nocheatplus.compat.cbreflect.reflect;
import java.lang.reflect.Field;

View File

@ -1,3 +1,17 @@
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package fr.neatmonster.nocheatplus.compat.cbreflect.reflect;
import java.lang.reflect.Field;

View File

@ -1,3 +1,17 @@
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package fr.neatmonster.nocheatplus.compat.cbreflect.reflect;
import java.lang.reflect.InvocationTargetException;

View File

@ -1,3 +1,17 @@
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package fr.neatmonster.nocheatplus.compat.cbreflect.reflect;
public class ReflectIBlockAccess {

View File

@ -1,3 +1,17 @@
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package fr.neatmonster.nocheatplus.compat.cbreflect.reflect;
import java.lang.reflect.InvocationTargetException;

View File

@ -1,3 +1,17 @@
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package fr.neatmonster.nocheatplus.compat.cb2794;
import org.bukkit.craftbukkit.v1_6_R1.entity.CraftLivingEntity;

View File

@ -1,3 +1,17 @@
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package fr.neatmonster.nocheatplus.compat.cb2808;
import org.bukkit.craftbukkit.v1_6_R2.entity.CraftLivingEntity;

View File

@ -1,3 +1,17 @@
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package fr.neatmonster.nocheatplus.compat.cb2882;
import org.bukkit.craftbukkit.v1_6_R3.entity.CraftLivingEntity;

View File

@ -1,3 +1,17 @@
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package fr.neatmonster.nocheatplus.compat.cb2922;
import org.bukkit.craftbukkit.v1_7_R1.entity.CraftLivingEntity;

View File

@ -1,3 +1,17 @@
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package fr.neatmonster.nocheatplus.compat.cb3026;
import org.bukkit.craftbukkit.v1_7_R2.entity.CraftLivingEntity;

View File

@ -1,3 +1,17 @@
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package fr.neatmonster.nocheatplus.compat.cb3043;
import org.bukkit.craftbukkit.v1_7_R3.entity.CraftLivingEntity;

View File

@ -1,3 +1,17 @@
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package fr.neatmonster.nocheatplus.compat.cb3100;
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftLivingEntity;

View File

@ -1,3 +1,17 @@
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package fr.neatmonster.nocheatplus.compat.cbdev;
import org.bukkit.craftbukkit.v1_10_R1.entity.CraftLivingEntity;

View File

@ -1,3 +1,17 @@
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package fr.neatmonster.nocheatplus.compat.spigotcb1_8_R1;
import org.bukkit.craftbukkit.v1_8_R1.entity.CraftLivingEntity;

View File

@ -1,3 +1,17 @@
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package fr.neatmonster.nocheatplus.compat.spigotcb1_8_R2;
import org.bukkit.craftbukkit.v1_8_R2.entity.CraftLivingEntity;

View File

@ -1,3 +1,17 @@
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package fr.neatmonster.nocheatplus.compat.spigotcb1_8_R3;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftLivingEntity;

View File

@ -1,3 +1,17 @@
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package fr.neatmonster.nocheatplus.compat.spigotcb1_9_R1;
import org.bukkit.craftbukkit.v1_9_R1.entity.CraftLivingEntity;

View File

@ -1,3 +1,17 @@
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package fr.neatmonster.nocheatplus.compat.spigotcb1_9_R2;
import org.bukkit.craftbukkit.v1_9_R2.entity.CraftLivingEntity;

View File

@ -1,3 +1,17 @@
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package fr.neatmonster.nocheatplus.compat;
import org.bukkit.entity.Entity;

View File

@ -1,3 +1,17 @@
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package fr.neatmonster.nocheatplus.compat.blocks.init.vanilla;
import org.bukkit.Material;

View File

@ -1,3 +1,17 @@
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package fr.neatmonster.nocheatplus.compat.blocks.init.vanilla;
import org.bukkit.Material;

View File

@ -1,3 +1,17 @@
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package fr.neatmonster.nocheatplus.compat.blocks.init.vanilla;
import org.bukkit.Material;

View File

@ -1,3 +1,17 @@
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package fr.neatmonster.nocheatplus.compat.blocks.init.vanilla;
import org.bukkit.Material;

View File

@ -1,3 +1,17 @@
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package fr.neatmonster.nocheatplus.compat.blocks.init.vanilla;
import org.bukkit.Material;

View File

@ -1,3 +1,17 @@
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package fr.neatmonster.nocheatplus.compat.blocks.init.vanilla;
import org.bukkit.Material;

View File

@ -1,3 +1,17 @@
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package fr.neatmonster.nocheatplus.compat.blocks.init.vanilla;
import java.util.Collection;

View File

@ -1,3 +1,17 @@
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package fr.neatmonster.nocheatplus.compat.versions;
import java.util.LinkedList;

View File

@ -1,3 +1,17 @@
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package fr.neatmonster.nocheatplus.components;
/**

View File

@ -1,3 +1,17 @@
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package fr.neatmonster.nocheatplus.components;
/**

View File

@ -1,3 +1,17 @@
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package fr.neatmonster.nocheatplus.components;
/**

View File

@ -1,3 +1,17 @@
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package fr.neatmonster.nocheatplus.components.location;
import fr.neatmonster.nocheatplus.utilities.ds.map.CoordHash;

View File

@ -1,3 +1,17 @@
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package fr.neatmonster.nocheatplus.components.location;
/**

View File

@ -1,3 +1,17 @@
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package fr.neatmonster.nocheatplus.components.location;
/**

View File

@ -1,3 +1,17 @@
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package fr.neatmonster.nocheatplus.components.modifier;
import org.bukkit.entity.Player;

View File

@ -1,3 +1,17 @@
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package fr.neatmonster.nocheatplus.components.modifier;
import org.bukkit.entity.Player;

View File

@ -1,3 +1,17 @@
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package fr.neatmonster.nocheatplus.components.registry.activation;
/**

View File

@ -1,3 +1,17 @@
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package fr.neatmonster.nocheatplus.components.registry.activation;
/**

View File

@ -1,3 +1,17 @@
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package fr.neatmonster.nocheatplus.components.registry.event;
/**

View File

@ -1,3 +1,17 @@
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package fr.neatmonster.nocheatplus.components.registry.event;
/**

View File

@ -1,3 +1,17 @@
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package fr.neatmonster.nocheatplus.components.registry.event;
/**

View File

@ -1,3 +1,17 @@
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package fr.neatmonster.nocheatplus.components.registry.feature;
/**

View File

@ -16,15 +16,26 @@ package fr.neatmonster.nocheatplus.utilities;
import java.util.UUID;
// TODO: Auto-generated Javadoc
/**
* The Class AttribUtil.
*/
public class AttribUtil {
/** The Constant ID_SPRINT_BOOST. */
public static final UUID ID_SPRINT_BOOST = IdUtil.UUIDFromString("662A6B8D-DA3E-4C1C-8813-96EA6097278D");
/**
* Get a multiplier for an AttributeModifier.
* @param operator Exclusively allows operator 2. Otherwise will throw an IllegalArgumentException.
* @param value The modifier value (AttributeModifier).
* @throws IllegalArgumentException if the modifier is not 2.
*
* @param operator
* Exclusively allows operator 2. Otherwise will throw an
* IllegalArgumentException.
* @param value
* The modifier value (AttributeModifier).
* @return A multiplier for direct use.
* @throws IllegalArgumentException
* if the modifier is not 2.
*/
public static double getMultiplier(final int operator, final double value) {
// TODO: Might allow 1 too, as it should "work", despite less accurate.

View File

@ -24,6 +24,7 @@ import fr.neatmonster.nocheatplus.logging.Streams;
import fr.neatmonster.nocheatplus.utilities.ds.map.CoordHashMap;
import fr.neatmonster.nocheatplus.utilities.ds.map.CoordMap;
// TODO: Auto-generated Javadoc
/**
* Access to type-ids and data using caching techniques.
* @author mc_dev
@ -33,12 +34,16 @@ public abstract class BlockCache {
// TODO: New concepts (Might switch to material, inspect MC+CB code for reliability and performance of block-ids during runtime).
/** The Constant ID_AIR. */
private static final int ID_AIR = 0;
/**
* Convenience method to check if the bounds as returned by getBounds cover a whole block.
* @param bounds Can be null, must have 6 fields.
* @return
* Convenience method to check if the bounds as returned by getBounds cover
* a whole block.
*
* @param bounds
* Can be null, must have 6 fields.
* @return true, if is full bounds
*/
public static final boolean isFullBounds(final double[] bounds) {
if (bounds == null) return false;
@ -50,12 +55,18 @@ public abstract class BlockCache {
}
/**
* Check if chunks are loaded and load all not yet loaded chunks, using normal world coordinates.<br>
* Check if chunks are loaded and load all not yet loaded chunks, using
* normal world coordinates.<br>
* NOTE: Not sure where to put this. Method does not use any caching.
*
* @param world
* the world
* @param x
* the x
* @param z
* the z
* @param xzMargin
* the xz margin
* @return Number of loaded chunks.
*/
public static int ensureChunksLoaded(final World world, final double x, final double z, final double xzMargin) {
@ -90,60 +101,93 @@ public abstract class BlockCache {
/** Cached shape values. */
private final CoordMap<double[]> boundsMap = new CoordHashMap<double[]>(23);
/** The max block y. */
protected int maxBlockY = 255;
// TODO: Switch to nodes with all details on?
/**
* Instantiates a new block cache.
*/
public BlockCache() {
}
/**
* Instantiates a new block cache.
*
* @param world
* the world
*/
public BlockCache(final World world) {
setAccess(world);
}
/**
* Does not do cleanup.
*
* @param world
* the new access
*/
public abstract void setAccess(final World world);
/**
* Fetch the type id from the underlying world.
*
* @param x
* the x
* @param y
* the y
* @param z
* @return
* the z
* @return the int
*/
public abstract int fetchTypeId(int x, int y, int z);
/**
* Fetch the data from the underlying world.
*
* @param x
* the x
* @param y
* the y
* @param z
* @return
* the z
* @return the int
*/
public abstract int fetchData(int x, int y, int z);
/**
* Find out bounds for the block, this should not return null for performance reasons.
* Find out bounds for the block, this should not return null for
* performance reasons.
*
* @param x
* the x
* @param y
* the y
* @param z
* @return
* the z
* @return the double[]
*/
public abstract double[] fetchBounds(int x, int y, int z);
/**
* This is a on-ground type check just for standing on minecarts / boats.
*
* @param entity
* the entity
* @param minX
* the min x
* @param minY
* the min y
* @param minZ
* the min z
* @param maxX
* the max x
* @param maxY
* the max y
* @param maxZ
* @return
* the max z
* @return true, if successful
*/
public abstract boolean standsOnEntity(Entity entity, final double minX, final double minY, final double minZ, final double maxX, final double maxY, final double maxZ);
@ -160,10 +204,14 @@ public abstract class BlockCache {
/**
* (convenience method, uses cache).
* @param eX
* @param eY
* @param eZ
* @return
*
* @param x
* the x
* @param y
* the y
* @param z
* the z
* @return the type id
*/
public int getTypeId(double x, double y, double z) {
return getTypeId(Location.locToBlock(x), Location.locToBlock(y), Location.locToBlock(z));
@ -171,8 +219,10 @@ public abstract class BlockCache {
/**
* (convenience method, uses cache).
*
* @param block
* @return
* the block
* @return the type id
*/
public int getTypeId(final Block block) {
return getTypeId(block.getX(), block.getY(), block.getZ());
@ -180,10 +230,14 @@ public abstract class BlockCache {
/**
* Get type id with cache access.
*
* @param x
* the x
* @param y
* the y
* @param z
* @return
* the z
* @return the type id
*/
public int getTypeId(final int x, final int y, final int z) {
final Integer pId = idMap.get(x, y, z);
@ -197,10 +251,14 @@ public abstract class BlockCache {
/**
* Get data value with cache access.
*
* @param x
* the x
* @param y
* the y
* @param z
* @return
* the z
* @return the data
*/
public int getData(final int x, final int y, final int z) {
final Integer pData = dataMap.get(x, y, z);
@ -213,11 +271,18 @@ public abstract class BlockCache {
}
/**
* Get block bounds - <b>Do not change these in-place, because the returned array is cached internally.</b>
* Get block bounds - <b>Do not change these in-place, because the returned
* array is cached internally.</b>
*
* @param x
* the x
* @param y
* the y
* @param z
* @return Array of floats (minX, minY, minZ, maxX, maxY, maxZ), may be null theoretically. Do not change these in place, because they might get cached.
* the z
* @return Array of floats (minX, minY, minZ, maxX, maxY, maxZ), may be null
* theoretically. Do not change these in place, because they might
* get cached.
*/
public double[] getBounds(final int x, final int y, final int z) {
final double[] pBounds = boundsMap.get(x, y, z);
@ -231,11 +296,16 @@ public abstract class BlockCache {
}
/**
* Convenience method to check if the bounds for a block cover the full block.
* Convenience method to check if the bounds for a block cover the full
* block.
*
* @param x
* the x
* @param y
* the y
* @param z
* @return
* the z
* @return true, if is full bounds
*/
public boolean isFullBounds(final int x, final int y, final int z) {
return isFullBounds(getBounds(x, y, z));
@ -243,7 +313,8 @@ public abstract class BlockCache {
/**
* Get the maximal y coordinate a block can be at (non air).
* @return
*
* @return the max block y
*/
public int getMaxBlockY() {
return maxBlockY;

View File

@ -16,6 +16,7 @@ package fr.neatmonster.nocheatplus.utilities;
import org.bukkit.Material;
// TODO: Auto-generated Javadoc
/**
* Utilities for block-flags.<br>
* Later the flag constant definitions and parsing might be moved here.
@ -25,37 +26,51 @@ import org.bukkit.Material;
public class BlockFlags {
/**
* Set flags of id same as already set with flags for the given material. (Uses BlockProperties.)
* @param id
* @param mat
*/
* Set flags of id same as already set with flags for the given material.
* (Uses BlockProperties.)
*
* @param id
* the id
* @param mat
* the mat
*/
public static void setFlagsAs(int id, Material mat) {
BlockProperties.setBlockFlags(id, BlockProperties.getBlockFlags(mat));
}
/**
* Set flags of id same as already set with flags for the given material. (Uses BlockProperties.)
* @param id
* @param mat
*/
* Set flags of id same as already set with flags for the given material.
* (Uses BlockProperties.)
*
* @param id
* the id
* @param otherId
* the other id
*/
public static void setFlagsAs(int id, int otherId) {
BlockProperties.setBlockFlags(id, BlockProperties.getBlockFlags(otherId));
}
/**
* Add flags to existent flags. (Uses BlockProperties.)
* @param id
* @param flags
*/
* Add flags to existent flags. (Uses BlockProperties.)
*
* @param id
* the id
* @param flags
* the flags
*/
public static void addFlags(int id, long flags) {
BlockProperties.setBlockFlags(id, BlockProperties.getBlockFlags(id) | flags);
}
/**
* Remove the given flags from existent flags. (Uses BlockProperties.)
* @param id
* @param flags
*/
* Remove the given flags from existent flags. (Uses BlockProperties.)
*
* @param id
* the id
* @param flags
* the flags
*/
public static void removeFlags(int id, long flags) {
BlockProperties.setBlockFlags(id, BlockProperties.getBlockFlags(id) & ~flags);
}

View File

@ -41,17 +41,23 @@ import fr.neatmonster.nocheatplus.hooks.NCPExemptionManager;
import fr.neatmonster.nocheatplus.logging.StaticLog;
import fr.neatmonster.nocheatplus.logging.Streams;
// TODO: Auto-generated Javadoc
/**
* Random auxiliary gear, some might have general quality. Contents are likely to get moved to other classes.
*/
public class CheckUtils {
/** The Constant logOnce. */
// TODO: Quick and dirty -> other methods elsewhere.
private static final Set<Integer> logOnce = Collections.synchronizedSet(new HashSet<Integer>());
/**
* Kick and log.
*
* @param player
* the player
* @param cc
* the cc
*/
public static void kickIllegalMove(final Player player, final MovingConfig cc){
player.kickPlayer(cc.msgKickIllegalMove);
@ -59,11 +65,17 @@ public class CheckUtils {
}
/**
* Guess some last-action time, likely to be replaced with centralized PlayerData use.
* Guess some last-action time, likely to be replaced with centralized
* PlayerData use.
*
* @param player
* @param Timestamp of the moment of calling this.
* @param maxAge Maximum age in milliseconds.
* @return Return timestamp or Long.MIN_VALUE if not possible or beyond maxAge.
* the player
* @param now
* the now
* @param maxAge
* Maximum age in milliseconds.
* @return Return timestamp or Long.MIN_VALUE if not possible or beyond
* maxAge.
*/
public static final long guessKeepAliveTime(final Player player, final long now, final long maxAge){
final int tick = TickTask.getTick();
@ -92,9 +104,12 @@ public class CheckUtils {
}
/**
* Check getPassenger recursively until a player is found, return that one or null.
* Check getPassenger recursively until a player is found, return that one
* or null.
*
* @param entity
* @return
* the entity
* @return the first player passenger
*/
public static Player getFirstPlayerPassenger(final Entity entity) {
Entity passenger = entity.getPassenger();
@ -110,10 +125,10 @@ public class CheckUtils {
/**
* Check recursively for vehicles, returns null if players are vehicles,
* otherwise the lowest vehicle (that has no vehicle).
*
*
* @param passenger
* The passenger of vehicles. Typically the player.
* @return
* @return the last non player vehicle
*/
public static Entity getLastNonPlayerVehicle(final Entity passenger) {
Entity vehicle = passenger.getVehicle();
@ -133,8 +148,10 @@ public class CheckUtils {
/**
* Check for NaN, infinity.
*
* @param floats
* @return
* the floats
* @return true, if is bad coordinate
*/
public static boolean isBadCoordinate(float ... floats) {
for (int i = 0; i < floats.length; i++) {
@ -147,8 +164,10 @@ public class CheckUtils {
/**
* Check for NaN, infinity.
*
* @param doubles
* @return
* the doubles
* @return true, if is bad coordinate
*/
public static boolean isBadCoordinate(double ... doubles) {
for (int i = 0; i < doubles.length; i++) {
@ -162,16 +181,18 @@ public class CheckUtils {
/**
* Check for config flag and exemption (hasBypass). Meant thread-safe.
*
*
* @param checkType
* the check type
* @param player
* the player
* @param data
* If data is null, the data factory will be used for the given
* check type.
* @param cc
* If config is null, the config factory will be used for the
* given check type.
* @return
* @return true, if is enabled
*/
public static boolean isEnabled(final CheckType checkType, final Player player, final ICheckData data, final ICheckConfig cc) {
if (cc == null) {
@ -188,13 +209,15 @@ public class CheckUtils {
/**
* Check for exemption by permissions, API access, possibly other. Meant
* thread-safe.
*
* @param player
*
* @param checkType
* the check type
* @param player
* the player
* @param data
* If data is null, the data factory will be used for the given
* check type.
* @return
* @return true, if successful
*/
public static boolean hasBypass(final CheckType checkType, final Player player, final ICheckData data) {
// TODO: Checking for the thread might be a temporary measure.
@ -222,6 +245,12 @@ public class CheckUtils {
return NCPExemptionManager.isExempted(player, checkType);
}
/**
* Improper api access.
*
* @param checkType
* the check type
*/
private static void improperAPIAccess(final CheckType checkType) {
// TODO: Log once + examine stack (which plugins/things are involved).
final String trace = Arrays.toString(Thread.currentThread().getStackTrace());
@ -247,11 +276,13 @@ public class CheckUtils {
/**
* Static relay for the check-specific convenience methods, logging with
* standard format ([check_type] [player_name] ...).
*
*
* @param player
* May be null.
* @param checkType
* the check type
* @param message
* the message
*/
public static void debug(final Player player, final CheckType checkType, final String message) {
NCPAPIProvider.getNoCheatPlusAPI().getLogManager().debug(Streams.TRACE_FILE, getLogMessagePrefix(player, checkType) + message);
@ -259,11 +290,12 @@ public class CheckUtils {
/**
* Get the standard log message prefix with a trailing space.
*
*
* @param player
* May be null.
* @param checkType
* @return
* the check type
* @return the log message prefix
*/
public static String getLogMessagePrefix(final Player player, final CheckType checkType) {
String base = "[" + checkType + "] ";
@ -276,8 +308,8 @@ public class CheckUtils {
/**
* Convenience method to get a Random instance from the generic registry
* (NoCheatPlusAPI).
*
* @return
*
* @return the random
*/
public static Random getRandom() {
return NCPAPIProvider.getNoCheatPlusAPI().getGenericInstance(Random.class);
@ -285,10 +317,10 @@ public class CheckUtils {
/**
* Test if the item is consumable, like food, potions, milk bucket.
*
*
* @param stack
* May be null.
* @return
* @return true, if is consumable
*/
public static boolean isConsumable(final ItemStack stack) {
return stack == null ? false : isConsumable(stack.getType());
@ -296,10 +328,10 @@ public class CheckUtils {
/**
* Test if the item is consumable, like food, potions, milk bucket.
*
*
* @param type
* May be null.
* @return
* @return true, if is consumable
*/
public static boolean isConsumable(final Material type) {
return type != null &&
@ -309,8 +341,9 @@ public class CheckUtils {
/**
* Return the first consumable item found, checking main hand first and then
* off hand, if available. Concerns food/edible, potions, milk bucket.
*
*
* @param player
* the player
* @return null in case no item is consumable.
*/
public static ItemStack getFirstConsumableItemInHand(final Player player) {

View File

@ -16,6 +16,7 @@ package fr.neatmonster.nocheatplus.utilities;
import org.bukkit.ChatColor;
// TODO: Auto-generated Javadoc
/**
* More and less color. Methods couls also in StringUtil, but that is in NCPCommons without Bukkit dependency.
* @author mc_dev
@ -23,7 +24,7 @@ import org.bukkit.ChatColor;
*/
public class ColorUtil {
/** Needs updating from Bukkit implementation (ChatColor) */
/** Needs updating from Bukkit implementation (ChatColor). */
private static final String allColorChars = "0123456789AaBbCcDdEeFfKkLlMmNnOoRr";
/**

View File

@ -26,6 +26,7 @@ import fr.neatmonster.nocheatplus.utilities.ds.map.CoordHashMap;
import fr.neatmonster.nocheatplus.utilities.ds.map.CoordMap;
import fr.neatmonster.nocheatplus.utilities.ds.map.CoordMap.Entry;
// TODO: Auto-generated Javadoc
/**
* Stand-alone BlockCache for setting data by access methods, for testing purposes.
* @author dev1mc
@ -43,15 +44,25 @@ public class FakeBlockCache extends BlockCache {
private final CoordMap<double[]> boundsMapStored = new CoordHashMap<double[]>(23);
/**
* Convenience method to copy a cuboid region given by two endpoints without any order specified.
* Convenience method to copy a cuboid region given by two endpoints without
* any order specified.
*
* @param other
* the other
* @param x0
* the x0
* @param y0
* the y0
* @param z0
* the z0
* @param x1
* the x1
* @param y1
* the y1
* @param z1
* the z1
* @param margin
* the margin
*/
public void set(BlockCache other, double x0, double y0, double z0, double x1, double y1, double z1, double margin) {
set(other, Location.locToBlock(Math.min(x0, x1) - margin), Location.locToBlock(Math.min(y0, y1) - margin), Location.locToBlock(Math.min(z0, z1) - margin),
@ -60,13 +71,21 @@ public class FakeBlockCache extends BlockCache {
/**
* Copy a cuboid region from the other BlockCache instance.
*
* @param other
* the other
* @param minX
* the min x
* @param minY
* the min y
* @param minZ
* the min z
* @param maxX
* the max x
* @param maxY
* the max y
* @param maxZ
* the max z
*/
public void set(BlockCache other, int minX, int minY, int minZ, int maxX, int maxY, int maxZ) {
for (int x = minX; x <= maxX; x++) {
@ -80,22 +99,33 @@ public class FakeBlockCache extends BlockCache {
/**
* Set with data=0 and bounds=full.
*
* @param x
* the x
* @param y
* the y
* @param z
* the z
* @param type
* the type
*/
public void set(int x, int y, int z, Material type) {
set(x, y, z, BlockProperties.getId(type));
}
/**
* Set with data=0-
* Set with data=0-.
*
* @param x
* the x
* @param y
* the y
* @param z
* the z
* @param type
* the type
* @param bounds
* the bounds
*/
public void set(int x, int y, int z, Material type, double[] bounds) {
set(x, y, z, BlockProperties.getId(type), 0, bounds);
@ -103,10 +133,15 @@ public class FakeBlockCache extends BlockCache {
/**
* Set with data=0 and bounds=full.
*
* @param x
* the x
* @param y
* the y
* @param z
* the z
* @param typeId
* the type id
*/
public void set(int x, int y, int z, int typeId) {
set(x, y, z, typeId, 0);
@ -114,11 +149,17 @@ public class FakeBlockCache extends BlockCache {
/**
* Set with bounds=full.
*
* @param x
* the x
* @param y
* the y
* @param z
* the z
* @param typeId
* the type id
* @param data
* the data
*/
public void set(int x, int y, int z, int typeId, int data) {
set(x, y, z, typeId, data, new double[]{0.0, 0.0, 0.0, 1.0, 1.0, 1.0});
@ -126,12 +167,19 @@ public class FakeBlockCache extends BlockCache {
/**
* Set custom properties.
*
* @param x
* the x
* @param y
* the y
* @param z
* the z
* @param typeId
* the type id
* @param data
* @param bounds Stores the given bounds directly.
* the data
* @param bounds
* Stores the given bounds directly.
*/
public void set(int x, int y, int z, int typeId, int data, double[] bounds) {
idMapStored.put(x, y, z, typeId);
@ -146,13 +194,21 @@ public class FakeBlockCache extends BlockCache {
/**
* Fill the entire cuboid.
*
* @param x1
* the x1
* @param y1
* the y1
* @param z1
* the z1
* @param x2
* the x2
* @param y2
* the y2
* @param z2
* the z2
* @param type
* the type
*/
public void fill(int x1, int y1, int z1, int x2, int y2, int z2, Material type) {
fill(x1, y1, z1, x2, y2, z2, BlockProperties.getId(type), 0, new double[]{0.0, 0.0, 0.0, 1.0, 1.0, 1.0});
@ -160,15 +216,25 @@ public class FakeBlockCache extends BlockCache {
/**
* Fill the entire cuboid.
*
* @param x1
* the x1
* @param y1
* the y1
* @param z1
* the z1
* @param x2
* the x2
* @param y2
* the y2
* @param z2
* the z2
* @param typeId
* the type id
* @param data
* the data
* @param bounds
* the bounds
*/
public void fill(int x1, int y1, int z1, int x2, int y2, int z2, int typeId, int data, double[] bounds) {
for (int x = x1; x <= x2; x++) {
@ -182,13 +248,21 @@ public class FakeBlockCache extends BlockCache {
/**
* Horizontal walls.
*
* @param x1
* the x1
* @param y1
* the y1
* @param z1
* the z1
* @param x2
* the x2
* @param y2
* the y2
* @param z2
* the z2
* @param type
* the type
*/
public void walls(int x1, int y1, int z1, int x2, int y2, int z2, Material type) {
walls(x1, y1, z1, x2, y2, z2, BlockProperties.getId(type), 0, new double[]{0.0, 0.0, 0.0, 1.0, 1.0, 1.0});
@ -196,15 +270,25 @@ public class FakeBlockCache extends BlockCache {
/**
* Horizontal walls.
*
* @param x1
* the x1
* @param y1
* the y1
* @param z1
* the z1
* @param x2
* the x2
* @param y2
* the y2
* @param z2
* the z2
* @param typeId
* the type id
* @param data
* the data
* @param bounds
* the bounds
*/
public void walls(int x1, int y1, int z1, int x2, int y2, int z2, int typeId, int data, double[] bounds) {
for (int x = x1; x <= x2; x++) {
@ -220,13 +304,21 @@ public class FakeBlockCache extends BlockCache {
/**
* Walls, floor, ceiling.
*
* @param x1
* the x1
* @param y1
* the y1
* @param z1
* the z1
* @param x2
* the x2
* @param y2
* the y2
* @param z2
* the z2
* @param type
* the type
*/
public void room(int x1, int y1, int z1, int x2, int y2, int z2, Material type) {
room(x1, y1, z1, x2, y2, z2, BlockProperties.getId(type), 0, new double[]{0.0, 0.0, 0.0, 1.0, 1.0, 1.0});
@ -234,15 +326,25 @@ public class FakeBlockCache extends BlockCache {
/**
* Walls, floor, ceiling.
*
* @param x1
* the x1
* @param y1
* the y1
* @param z1
* the z1
* @param x2
* the x2
* @param y2
* the y2
* @param z2
* the z2
* @param typeId
* the type id
* @param data
* the data
* @param bounds
* the bounds
*/
public void room(int x1, int y1, int z1, int x2, int y2, int z2, int typeId, int data, double[] bounds) {
for (int x = x1; x <= x2; x++) {
@ -258,20 +360,30 @@ public class FakeBlockCache extends BlockCache {
/**
* Test if any an id is set for this block position.
*
* @param x
* the x
* @param y
* the y
* @param z
* @return
* the z
* @return true, if successful
*/
public boolean hasIdEntry(int x, int y, int z) {
return idMapStored.contains(x, y, z);
}
/**
* Return a line of java code to construct a new FakeBlockCache with the same content (no newlines).
* Return a line of java code to construct a new FakeBlockCache with the
* same content (no newlines).
*
* @param builder
* @param fbcName Variable name of the FakeBlockCache instance.
* @param boundsPrefix A prefix for bounds variables for the case of repeated content. If set to null, no optimization will be performed.
* the builder
* @param fbcName
* Variable name of the FakeBlockCache instance.
* @param boundsPrefix
* A prefix for bounds variables for the case of repeated
* content. If set to null, no optimization will be performed.
*/
public void toJava(final StringBuilder builder, final String fbcName, final String boundsPrefix) {
builder.append("FakeBlockCache " + fbcName + " = new FakeBlockCache();");
@ -317,11 +429,17 @@ public class FakeBlockCache extends BlockCache {
}
}
/* (non-Javadoc)
* @see fr.neatmonster.nocheatplus.utilities.BlockCache#setAccess(org.bukkit.World)
*/
@Override
public void setAccess(World world) {
// Ignore.
}
/* (non-Javadoc)
* @see fr.neatmonster.nocheatplus.utilities.BlockCache#fetchTypeId(int, int, int)
*/
@Override
public int fetchTypeId(int x, int y, int z) {
final Integer id = idMapStored.get(x, y, z);
@ -332,6 +450,9 @@ public class FakeBlockCache extends BlockCache {
}
}
/* (non-Javadoc)
* @see fr.neatmonster.nocheatplus.utilities.BlockCache#fetchData(int, int, int)
*/
@Override
public int fetchData(int x, int y, int z) {
final Integer data = dataMapStored.get(x, y, z);
@ -342,6 +463,9 @@ public class FakeBlockCache extends BlockCache {
}
}
/* (non-Javadoc)
* @see fr.neatmonster.nocheatplus.utilities.BlockCache#fetchBounds(int, int, int)
*/
@Override
public double[] fetchBounds(int x, int y, int z) {
final double[] bounds = boundsMapStored.get(x, y, z);
@ -349,6 +473,9 @@ public class FakeBlockCache extends BlockCache {
return bounds;
}
/* (non-Javadoc)
* @see fr.neatmonster.nocheatplus.utilities.BlockCache#standsOnEntity(org.bukkit.entity.Entity, double, double, double, double, double, double)
*/
@Override
public boolean standsOnEntity(Entity entity, double minX, double minY,
double minZ, double maxX, double maxY, double maxZ) {
@ -356,6 +483,9 @@ public class FakeBlockCache extends BlockCache {
return false;
}
/* (non-Javadoc)
* @see fr.neatmonster.nocheatplus.utilities.BlockCache#cleanup()
*/
@Override
public void cleanup() {
super.cleanup();

View File

@ -16,6 +16,7 @@ package fr.neatmonster.nocheatplus.utilities;
import java.util.UUID;
// TODO: Auto-generated Javadoc
/**
* Utility for UUIDs, player names.
* @author mc_dev
@ -24,20 +25,24 @@ import java.util.UUID;
public class IdUtil {
/**
* Valid user name check (Minecraft).<br>
* (Taken from TrustCore.)
* @param name Allows null input.
* @return
*/
* Valid user name check (Minecraft).<br>
* (Taken from TrustCore.)
*
* @param name
* Allows null input.
* @return true, if is valid minecraft user name
*/
public static boolean isValidMinecraftUserName(final String name) {
return name != null && name.matches("[\\w]{2,16}");
}
/**
* Safe method to parse a UUID, using UUIDFromString internally.
* @param input
* @return
*/
* Safe method to parse a UUID, using UUIDFromString internally.
*
* @param input
* the input
* @return the uuid
*/
public static UUID UUIDFromStringSafe(final String input) {
if (input == null) {
return null;
@ -50,11 +55,13 @@ public class IdUtil {
}
/**
* More flexible UUID parsing.<br>
* (Taken from TrustCore.)
* @param input
* @return
*/
* More flexible UUID parsing.<br>
* (Taken from TrustCore.)
*
* @param input
* the input
* @return the uuid
*/
public static UUID UUIDFromString(final String input) {
// TODO: Add unit tests.
final int len = input.length();

View File

@ -22,6 +22,7 @@ import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.InventoryView;
import org.bukkit.inventory.ItemStack;
// TODO: Auto-generated Javadoc
/**
* Auxiliary/convenience methods for inventories.
* @author mc_dev
@ -30,10 +31,12 @@ import org.bukkit.inventory.ItemStack;
public class InventoryUtil {
/**
* Does not account for special slots like armor.
* @param inventory
* @return
*/
* Does not account for special slots like armor.
*
* @param inventory
* the inventory
* @return the free slots
*/
public static int getFreeSlots(final Inventory inventory) {
final ItemStack[] contents = inventory.getContents();
int count = 0;
@ -46,11 +49,15 @@ public class InventoryUtil {
}
/**
* Count slots with type-id and data (enchantments and other meta data are ignored at present).
* @param inventory
* @param reference
* @return
*/
* Count slots with type-id and data (enchantments and other meta data are
* ignored at present).
*
* @param inventory
* the inventory
* @param reference
* the reference
* @return the stack count
*/
public static int getStackCount(final Inventory inventory, final ItemStack reference) {
if (inventory == null) return 0;
if (reference == null) return getFreeSlots(inventory);
@ -71,19 +78,27 @@ public class InventoryUtil {
}
/**
* Sum of bottom + top inventory slots with item type / data, see: getStackCount(Inventory, reference).
* @param view
* @param reference
* @return
*/
* Sum of bottom + top inventory slots with item type / data, see:
* getStackCount(Inventory, reference).
*
* @param view
* the view
* @param reference
* the reference
* @return the stack count
*/
public static int getStackCount(final InventoryView view, final ItemStack reference) {
return getStackCount(view.getBottomInventory(), reference) + getStackCount(view.getTopInventory(), reference);
}
/**
* Search for players / passengers (broken by name: closes the inventory of first player found including entity and passengers recursively).
* @param entity
*/
* Search for players / passengers (broken by name: closes the inventory of
* first player found including entity and passengers recursively).
*
* @param entity
* the entity
* @return true, if successful
*/
public static boolean closePlayerInventoryRecursively(Entity entity) {
// Find a player.
final Player player = getPlayerPassengerRecursively(entity);
@ -95,10 +110,13 @@ public class InventoryUtil {
}
/**
* Get a player from an entity. This will return the first player found amongst the entity itself and passengers checked recursively.
* @param entity
* @return
*/
* Get a player from an entity. This will return the first player found
* amongst the entity itself and passengers checked recursively.
*
* @param entity
* the entity
* @return the player passenger recursively
*/
public static Player getPlayerPassengerRecursively(Entity entity) {
while (entity != null) {
if (entity instanceof Player) {
@ -118,10 +136,13 @@ public class InventoryUtil {
}
/**
* Close one players inventory, if open. This might ignore InventoryType.CRAFTING (see: hasInventoryOpen).
* @param player
* @return If closed.
*/
* Close one players inventory, if open. This might ignore
* InventoryType.CRAFTING (see: hasInventoryOpen).
*
* @param player
* the player
* @return If closed.
*/
public static boolean closeOpenInventory(final Player player) {
if (hasInventoryOpen(player)) {
player.closeInventory();
@ -132,10 +153,13 @@ public class InventoryUtil {
}
/**
* Check if the players inventory is open. This might ignore InventoryType.CRAFTING.
* @param player
* @return
*/
* Check if the players inventory is open. This might ignore
* InventoryType.CRAFTING.
*
* @param player
* the player
* @return true, if successful
*/
public static boolean hasInventoryOpen(final Player player) {
final InventoryView view = player.getOpenInventory();
return view != null && view.getType() != InventoryType.CRAFTING;

View File

@ -16,6 +16,7 @@ package fr.neatmonster.nocheatplus.utilities;
import fr.neatmonster.nocheatplus.components.registry.feature.TickListener;
// TODO: Auto-generated Javadoc
/**
* Auxiliary class for easier short term adding of TickListener. Override delegateTick.<br>
* NOTES:
@ -25,88 +26,101 @@ import fr.neatmonster.nocheatplus.components.registry.feature.TickListener;
*
*/
public abstract class OnDemandTickListener implements TickListener{
protected boolean isRegistered = false;
/**
* Override this to get called on a tick.
* @param tick See: TickListener.onTick
* @param timeLast See: TickListener.onTick
* @return true to stay registered, false to unregister.
*/
public abstract boolean delegateTick(final int tick, final long timeLast);
@Override
public void onTick(final int tick, final long timeLast) {
if (!isRegistered){
// Could happen due to concurrency.
// (No extra unregister, to preserve order).
return;
}
else if (!delegateTick(tick, timeLast)){
// Remove from TickListenerS.
unRegister();
}
}
/**
* Register with TickTask, does check the isRegistered flag.
* @return This instance for chaining.
*/
public OnDemandTickListener register(){
return register(false);
}
/**
* Register with the TickTask if force is true or if isRegistered is false.
* @param force Set to true to call TickTask.addTickListener.
* @return
*/
public OnDemandTickListener register(final boolean force){
if (force || !isRegistered){
// Flag is set in the TickTask.
TickTask.addTickListener(this);
}
return this;
}
/**
* Unregister from TickTask, does check the isRegistered flag.
* @return This instance for chaining.
*/
public OnDemandTickListener unRegister(){
return unRegister(false);
}
/**
* Unregister from TickTask, if force is true or isRegistered is true.
* @param force
* @return This instance for chaining.
*/
public OnDemandTickListener unRegister(final boolean force){
if (force || isRegistered){
// Flag is set in the TickTask.
TickTask.removeTickListener(this);
}
return this;
}
/**
* A way to set isRegistered without causing any further calls to TickTask (for call from TickTask itself).<br>
* This must not cause any calls that use the TickListener registry of the TickTask (deadlocks / concurrent modification etc.).<br>
* Used by the TickTask, called under lock of TickListenerS.
* @param registered
*/
public void setRegistered(final boolean registered){
isRegistered = registered;
}
/**
* Test if this instance has been registered with the TickTask.
* @return
*/
public boolean isRegistered(){
return isRegistered;
}
/** The is registered. */
protected boolean isRegistered = false;
/**
* Override this to get called on a tick.
* @param tick See: TickListener.onTick
* @param timeLast See: TickListener.onTick
* @return true to stay registered, false to unregister.
*/
public abstract boolean delegateTick(final int tick, final long timeLast);
/* (non-Javadoc)
* @see fr.neatmonster.nocheatplus.components.registry.feature.TickListener#onTick(int, long)
*/
@Override
public void onTick(final int tick, final long timeLast) {
if (!isRegistered){
// Could happen due to concurrency.
// (No extra unregister, to preserve order).
return;
}
else if (!delegateTick(tick, timeLast)){
// Remove from TickListenerS.
unRegister();
}
}
/**
* Register with TickTask, does check the isRegistered flag.
* @return This instance for chaining.
*/
public OnDemandTickListener register(){
return register(false);
}
/**
* Register with the TickTask if force is true or if isRegistered is false.
*
* @param force
* Set to true to call TickTask.addTickListener.
* @return the on demand tick listener
*/
public OnDemandTickListener register(final boolean force){
if (force || !isRegistered){
// Flag is set in the TickTask.
TickTask.addTickListener(this);
}
return this;
}
/**
* Unregister from TickTask, does check the isRegistered flag.
* @return This instance for chaining.
*/
public OnDemandTickListener unRegister(){
return unRegister(false);
}
/**
* Unregister from TickTask, if force is true or isRegistered is true.
*
* @param force
* the force
* @return This instance for chaining.
*/
public OnDemandTickListener unRegister(final boolean force){
if (force || isRegistered){
// Flag is set in the TickTask.
TickTask.removeTickListener(this);
}
return this;
}
/**
* A way to set isRegistered without causing any further calls to TickTask
* (for call from TickTask itself).<br>
* This must not cause any calls that use the TickListener registry of the
* TickTask (deadlocks / concurrent modification etc.).<br>
* Used by the TickTask, called under lock of TickListenerS.
*
* @param registered
* the new registered
*/
public void setRegistered(final boolean registered){
isRegistered = registered;
}
/**
* Test if this instance has been registered with the TickTask.
*
* @return true, if is registered
*/
public boolean isRegistered(){
return isRegistered;
}
}

View File

@ -20,6 +20,7 @@ import org.bukkit.entity.Player;
import fr.neatmonster.nocheatplus.compat.MCAccess;
// TODO: Auto-generated Javadoc
/**
* Lots of content for a location a player is supposed to be at. Constructors
* for convenient use.
@ -30,13 +31,27 @@ public class PlayerLocation extends RichEntityLocation {
// "Heavy" object members that need to be set to null on cleanup. //
/** The player. */
private Player player = null;
/**
* Instantiates a new player location.
*
* @param mcAccess
* the mc access
* @param blockCache
* the block cache
*/
public PlayerLocation(final MCAccess mcAccess, final BlockCache blockCache) {
super(mcAccess, blockCache);
}
/**
* Gets the player.
*
* @return the player
*/
public Player getPlayer() {
return player;
}
@ -71,12 +86,11 @@ public class PlayerLocation extends RichEntityLocation {
/**
* Sets the player location object.
*
*
* @param location
* the location
* @param player
* the player
* @throws NullPointerException, if player.getLocation.getWorld() returns null.
*/
public void set(final Location location, final Player player) {
set(location, player, 0.001);
@ -84,12 +98,13 @@ public class PlayerLocation extends RichEntityLocation {
/**
* Sets the player location object. Does not set or reset blockCache.
*
*
* @param location
* the location
* @param player
* the player
* @throws NullPointerException, if Location.getWorld() returns null.
* @param yOnGround
* the y on ground
*/
public void set(final Location location, final Player player, final double yOnGround)
{
@ -100,6 +115,13 @@ public class PlayerLocation extends RichEntityLocation {
/**
* Not supported.
*
* @param location
* the location
* @param entity
* the entity
* @param yOnGround
* the y on ground
*/
@Override
public void set(Location location, Entity entity, double yOnGround) {
@ -108,6 +130,15 @@ public class PlayerLocation extends RichEntityLocation {
/**
* Not supported.
*
* @param location
* the location
* @param entity
* the entity
* @param fullHeight
* the full height
* @param yOnGround
* the y on ground
*/
@Override
public void set(Location location, Entity entity, double fullHeight, double yOnGround) {
@ -116,6 +147,17 @@ public class PlayerLocation extends RichEntityLocation {
/**
* Not supported.
*
* @param location
* the location
* @param entity
* the entity
* @param fullWidth
* the full width
* @param fullHeight
* the full height
* @param yOnGround
* the y on ground
*/
@Override
public void set(Location location, Entity entity, double fullWidth, double fullHeight, double yOnGround) {
@ -124,8 +166,11 @@ public class PlayerLocation extends RichEntityLocation {
/**
* Set cached info according to other.<br>
* Minimal optimizations: take block flags directly, on-ground max/min bounds, only set stairs if not on ground and not reset-condition.
* Minimal optimizations: take block flags directly, on-ground max/min
* bounds, only set stairs if not on ground and not reset-condition.
*
* @param other
* the other
*/
public void prepare(final PlayerLocation other) {
super.prepare(other);
@ -141,9 +186,10 @@ public class PlayerLocation extends RichEntityLocation {
/**
* Check absolute coordinates and stance for (typical) exploits.
*
* @return
* @deprecated Not used anymore (hasIllegalCoords and hasIllegalStance are used individually instead).
*
* @return true, if is illegal
* @deprecated Not used anymore (hasIllegalCoords and hasIllegalStance are
* used individually instead).
*/
public boolean isIllegal() {
if (hasIllegalCoords()) {
@ -154,14 +200,19 @@ public class PlayerLocation extends RichEntityLocation {
}
/**
* Check for bounding box properties that might crash the server (if available, not the absolute coordinates).
* @return
* Check for bounding box properties that might crash the server (if
* available, not the absolute coordinates).
*
* @return true, if successful
*/
public boolean hasIllegalStance() {
// TODO: This doesn't check this location, but the player.
return getMCAccess().isIllegalBounds(player).decide(); // MAYBE = NO
}
/* (non-Javadoc)
* @see fr.neatmonster.nocheatplus.utilities.RichEntityLocation#toString()
*/
@Override
public String toString() {
final StringBuilder builder = new StringBuilder(128);

View File

@ -20,6 +20,7 @@ import org.bukkit.entity.Player;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
// TODO: Auto-generated Javadoc
/**
* Could not help it.
* @author mc_dev
@ -28,11 +29,15 @@ import org.bukkit.potion.PotionEffectType;
public class PotionUtil {
/**
* Get amplifier for a potion effect.
* @param player
* @param type
* @return Double.NEGATIVE_INFINITY if not present, otherwise the maximal amplifier.
*/
* Get amplifier for a potion effect.
*
* @param player
* the player
* @param type
* the type
* @return Double.NEGATIVE_INFINITY if not present, otherwise the maximal
* amplifier.
*/
public static final double getPotionEffectAmplifier(final Player player, final PotionEffectType type) {
if (!player.hasPotionEffect(type)) return Double.NEGATIVE_INFINITY; // TODO: Might not win anything.
final Collection<PotionEffect> effects = player.getActivePotionEffects();

View File

@ -30,6 +30,7 @@ import fr.neatmonster.nocheatplus.components.location.IGetBlockPosition;
import fr.neatmonster.nocheatplus.components.location.IGetBukkitLocation;
import fr.neatmonster.nocheatplus.components.location.IGetPosition;
// TODO: Auto-generated Javadoc
/**
* A location with bounds with a lot of extra stuff.
*
@ -51,6 +52,7 @@ public class RichBoundsLocation implements IGetBukkitLocation, IGetBlockPosition
/** The exact coordinates. */
double x, y, z;
/** The pitch. */
float yaw, pitch; // TODO: -> entity ?
/** Bounding box. */
@ -58,7 +60,8 @@ public class RichBoundsLocation implements IGetBukkitLocation, IGetBlockPosition
/** Horizontal margin for the bounding box (center towards edge). */
double boxMarginHorizontal;
/** Vertical margin for the bounding box (y towards top)*/
/** Vertical margin for the bounding box (y towards top). */
double boxMarginVertical;
// TODO: Check if onGround can be completely replaced by onGroundMinY and notOnGroundMaxY.
@ -85,7 +88,7 @@ public class RichBoundsLocation implements IGetBukkitLocation, IGetBlockPosition
/** All block flags collected for maximum used bounds. */
Long blockFlags = null;
/** Is the player on ladder? */
/** Is the player on ladder?. */
Boolean onClimbable = null;
/** Simple test if the exact position is passable. */
@ -94,22 +97,22 @@ public class RichBoundsLocation implements IGetBukkitLocation, IGetBlockPosition
/** Bounding box collides with blocks. */
Boolean passableBox = null;
/** Is the player above stairs? */
/** Is the player above stairs?. */
Boolean aboveStairs = null;
/** Is the player in lava? */
/** Is the player in lava?. */
Boolean inLava = null;
/** Is the player in water? */
/** Is the player in water?. */
Boolean inWater = null;
/** Is the player is web? */
/** Is the player is web?. */
Boolean inWeb = null;
/** Is the player on ice? */
/** Is the player on ice?. */
Boolean onIce = null;
/** Is the player on the ground? */
/** Is the player on the ground?. */
Boolean onGround = null;
@ -122,54 +125,85 @@ public class RichBoundsLocation implements IGetBukkitLocation, IGetBlockPosition
World world = null;
/**
* Instantiates a new rich bounds location.
*
* @param blockCache
* the block cache
*/
public RichBoundsLocation(final BlockCache blockCache) {
this.blockCache = blockCache;
}
/* (non-Javadoc)
* @see fr.neatmonster.nocheatplus.components.location.IGetBukkitLocation#getWorld()
*/
@Override
public World getWorld() {
return world;
}
/* (non-Javadoc)
* @see fr.neatmonster.nocheatplus.components.location.IGetLocation#getWorldName()
*/
@Override
public String getWorldName() {
return world.getName();
}
/* (non-Javadoc)
* @see fr.neatmonster.nocheatplus.components.location.IGetPosition#getX()
*/
@Override
public double getX() {
return x;
}
/* (non-Javadoc)
* @see fr.neatmonster.nocheatplus.components.location.IGetPosition#getY()
*/
@Override
public double getY() {
return y;
}
/* (non-Javadoc)
* @see fr.neatmonster.nocheatplus.components.location.IGetPosition#getZ()
*/
@Override
public double getZ() {
return z;
}
/* (non-Javadoc)
* @see fr.neatmonster.nocheatplus.components.location.IGetLook#getYaw()
*/
@Override
public float getYaw() {
return yaw;
}
/* (non-Javadoc)
* @see fr.neatmonster.nocheatplus.components.location.IGetLook#getPitch()
*/
@Override
public float getPitch() {
return pitch;
}
/**
* Gets the vector.
*
* @return the vector
*/
public Vector getVector() {
return new Vector(x, y, z);
}
/**
* Gets a new Location instance representing this position.
*
*
* @return the location
* @throws NullPointerException, if the world stored internally is null.
*/
public Location getLocation() {
if (this.world == null) {
@ -178,16 +212,25 @@ public class RichBoundsLocation implements IGetBukkitLocation, IGetBlockPosition
return new Location(world, x, y, z, yaw, pitch);
}
/* (non-Javadoc)
* @see fr.neatmonster.nocheatplus.components.location.IGetBlockPosition#getBlockX()
*/
@Override
public int getBlockX() {
return blockX;
}
/* (non-Javadoc)
* @see fr.neatmonster.nocheatplus.components.location.IGetBlockPosition#getBlockY()
*/
@Override
public int getBlockY() {
return blockY;
}
/* (non-Javadoc)
* @see fr.neatmonster.nocheatplus.components.location.IGetBlockPosition#getBlockZ()
*/
@Override
public int getBlockZ() {
return blockZ;
@ -196,8 +239,8 @@ public class RichBoundsLocation implements IGetBukkitLocation, IGetBlockPosition
/**
* Return the bounding box as a new double array (minX, minY, minZ, maxX,
* maxY, maxZ).
*
* @return
*
* @return the bounds as doubles
*/
public double[] getBoundsAsDoubles() {
return new double[] {minX, minY, minZ, maxX, maxY, maxZ};
@ -207,8 +250,8 @@ public class RichBoundsLocation implements IGetBukkitLocation, IGetBlockPosition
* Get the bounding box margin from the center (x ,z) to the edge of the
* box. This value may be adapted from entity width or other input, and it
* might be cut down to a certain resolution (e.g. 1/1000).
*
* @return
*
* @return the box margin horizontal
*/
public double getBoxMarginHorizontal() {
return boxMarginHorizontal;
@ -217,8 +260,8 @@ public class RichBoundsLocation implements IGetBukkitLocation, IGetBlockPosition
/**
* Get the bounding box margin from the y coordinate (feet for entities) to
* the top.
*
* @return
*
* @return the box margin vertical
*/
public double getBoxMarginVertical() {
return boxMarginVertical;
@ -226,9 +269,10 @@ public class RichBoundsLocation implements IGetBukkitLocation, IGetBlockPosition
/**
* Compares block coordinates (not the world).
*
*
* @param other
* @return
* the other
* @return true, if is same block
*/
public final boolean isSameBlock(final IGetBlockPosition other) {
return blockX == other.getBlockX() && blockZ == other.getBlockZ() && blockY == other.getBlockY();
@ -236,10 +280,14 @@ public class RichBoundsLocation implements IGetBukkitLocation, IGetBlockPosition
/**
* Block coordinate comparison.
*
* @param x
* the x
* @param y
* the y
* @param z
* @return
* the z
* @return true, if is same block
*/
public final boolean isSameBlock(final int x, final int y, final int z) {
return blockX == x && blockZ == z && blockY == y;
@ -247,8 +295,10 @@ public class RichBoundsLocation implements IGetBukkitLocation, IGetBlockPosition
/**
* Compares block coordinates (not the world).
*
* @param loc
* @return
* the loc
* @return true, if is same block
*/
public final boolean isSameBlock(final Location loc) {
return blockX == loc.getBlockX() && blockZ == loc.getBlockZ() && blockY == loc.getBlockY();
@ -256,8 +306,10 @@ public class RichBoundsLocation implements IGetBukkitLocation, IGetBlockPosition
/**
* Check if this location is above the given one (blockY + 1).
*
* @param loc
* @return
* the loc
* @return true, if is block above
*/
public boolean isBlockAbove(final IGetBlockPosition loc) {
return blockY == loc.getBlockY() + 1 && blockX == loc.getBlockX() && blockZ == loc.getBlockZ();
@ -265,8 +317,10 @@ public class RichBoundsLocation implements IGetBukkitLocation, IGetBlockPosition
/**
* Check if this location is above the given one (blockY + 1).
*
* @param loc
* @return
* the loc
* @return true, if is block above
*/
public boolean isBlockAbove(final Location loc) {
return blockY == loc.getBlockY() + 1 && blockX == loc.getBlockX() && blockZ == loc.getBlockZ();
@ -274,9 +328,10 @@ public class RichBoundsLocation implements IGetBukkitLocation, IGetBlockPosition
/**
* Compares exact coordinates (not the world).
*
*
* @param loc
* @return
* the loc
* @return true, if is same pos
*/
public boolean isSamePos(final IGetPosition loc) {
return x == loc.getX() && z == loc.getZ() && y == loc.getY();
@ -284,9 +339,10 @@ public class RichBoundsLocation implements IGetBukkitLocation, IGetBlockPosition
/**
* Compares exact coordinates (not the world).
*
*
* @param loc
* @return
* the loc
* @return true, if is same pos
*/
public boolean isSamePos(final Location loc) {
return x == loc.getX() && z == loc.getZ() && y == loc.getY();
@ -294,8 +350,10 @@ public class RichBoundsLocation implements IGetBukkitLocation, IGetBlockPosition
/**
* Manhattan distance, see Trigutil.
*
* @param other
* @return
* the other
* @return the int
*/
public int manhattan(final IGetBlockPosition other) {
// TODO: Consider using direct field access from other methods as well.
@ -304,8 +362,10 @@ public class RichBoundsLocation implements IGetBukkitLocation, IGetBlockPosition
/**
* Maximum block distance comparing dx, dy, dz.
*
* @param other
* @return
* the other
* @return the int
*/
public int maxBlockDist(final IGetBlockPosition other) {
// TODO: Consider using direct field access from other methods as well.
@ -313,24 +373,31 @@ public class RichBoundsLocation implements IGetBukkitLocation, IGetBlockPosition
}
/**
* Quick check for really bad coordinates (actual problem, if true is returned.).
* @return
* Quick check for really bad coordinates (actual problem, if true is
* returned.).
*
* @return true, if successful
*/
public boolean hasIllegalCoords() {
return CheckUtils.isBadCoordinate(minX, maxX, minY, maxY, minZ, maxZ);
}
/**
* Get the collected block-flags. This will return null if collectBlockFlags has not been called.
* @return
* Get the collected block-flags. This will return null if collectBlockFlags
* has not been called.
*
* @return the block flags
*/
public Long getBlockFlags() {
return blockFlags;
}
/**
* Set the block flags which are usually collected on base of bounding box, yOnGround and other considerations, such as 1.5 high blocks.
* Set the block flags which are usually collected on base of bounding box,
* yOnGround and other considerations, such as 1.5 high blocks.
*
* @param blockFlags
* the new block flags
*/
public void setBlockFlags(Long blockFlags) {
this.blockFlags = blockFlags;
@ -338,7 +405,8 @@ public class RichBoundsLocation implements IGetBukkitLocation, IGetBlockPosition
/**
* Not cached.
* @return
*
* @return the type id above
*/
public int getTypeIdAbove() {
return blockCache.getTypeId(blockX, blockY + 1, blockZ);
@ -346,26 +414,43 @@ public class RichBoundsLocation implements IGetBukkitLocation, IGetBlockPosition
/**
* Convenience method: delegate to BlockProperties.isDoppwnStream .
*
*
* @param xDistance
* the x distance
* @param zDistance
* @return
* the z distance
* @return true, if is down stream
*/
public boolean isDownStream(final double xDistance, final double zDistance)
{
return BlockProperties.isDownStream(blockCache, blockX, blockY, blockZ, getData(), xDistance, zDistance);
}
/**
* Gets the type id.
*
* @return the type id
*/
public Integer getTypeId() {
if (typeId == null) typeId = getTypeId(blockX, blockY, blockZ);
return typeId;
}
/**
* Gets the type id below.
*
* @return the type id below
*/
public Integer getTypeIdBelow() {
if (typeIdBelow == null) typeIdBelow = getTypeId(blockX, blockY - 1, blockZ);
return typeIdBelow;
}
/**
* Gets the data.
*
* @return the data
*/
public Integer getData() {
if (data == null) data = getData(blockX, blockY, blockZ);
return data;
@ -373,11 +458,14 @@ public class RichBoundsLocation implements IGetBukkitLocation, IGetBlockPosition
/**
* Uses id cache if present.
*
*
* @param x
* the x
* @param y
* the y
* @param z
* @return
* the z
* @return the type id
*/
public final int getTypeId(final int x, final int y, final int z) {
return blockCache.getTypeId(x, y, z);
@ -385,11 +473,14 @@ public class RichBoundsLocation implements IGetBukkitLocation, IGetBlockPosition
/**
* Uses id cache if present.
*
*
* @param x
* the x
* @param y
* the y
* @param z
* @return
* the z
* @return the data
*/
public final int getData(final int x, final int y, final int z) {
return blockCache.getData(x, y, z);
@ -397,8 +488,9 @@ public class RichBoundsLocation implements IGetBukkitLocation, IGetBlockPosition
/**
* Set the id cache for faster id getting.
*
*
* @param cache
* the new block cache
*/
public void setBlockCache(final BlockCache cache) {
this.blockCache = cache;
@ -406,7 +498,8 @@ public class RichBoundsLocation implements IGetBukkitLocation, IGetBlockPosition
/**
* Get the underlying BLockCache.
* @return
*
* @return the block cache
*/
public final BlockCache getBlockCache() {
return blockCache;
@ -523,9 +616,12 @@ public class RichBoundsLocation implements IGetBukkitLocation, IGetBlockPosition
/**
* Check if solid blocks hit the box.
*
* @param xzMargin
* the xz margin
* @param yMargin
* @return
* the y margin
* @return true, if is next to ground
*/
public boolean isNextToGround(final double xzMargin, final double yMargin) {
// TODO: Adjust to check block flags ?
@ -533,8 +629,10 @@ public class RichBoundsLocation implements IGetBukkitLocation, IGetBlockPosition
}
/**
* Reset condition for flying checks (sf + nofall): liquids, web, ladder (not on-ground, though).
* @return
* Reset condition for flying checks (sf + nofall): liquids, web, ladder
* (not on-ground, though).
*
* @return true, if is reset cond
*/
public boolean isResetCond() {
// NOTE: if optimizing, setYOnGround has to be kept in mind.
@ -545,9 +643,10 @@ public class RichBoundsLocation implements IGetBukkitLocation, IGetBlockPosition
* Check if the location is on ground and if it is hitting the bounding box
* of a block with the given id. Currently this is coarse (not checking if
* it is really possible to stand on such a block).
*
*
* @param id
* @return
* the id
* @return true, if successful
*/
public boolean standsOnBlock(final int id) {
if (!isOnGround()) {
@ -585,8 +684,8 @@ public class RichBoundsLocation implements IGetBukkitLocation, IGetBlockPosition
/**
* Check the location is on ice, only regarding the center. Currently
* demands to be on ground as well.
*
* @return
*
* @return true, if is on ice
*/
public boolean isOnIce() {
if (onIce == null) {
@ -606,8 +705,8 @@ public class RichBoundsLocation implements IGetBukkitLocation, IGetBlockPosition
/**
* Test if the location is on rails (assuming minecarts with some magic
* bounds/behavior).
*
* @return
*
* @return true, if is on rails
*/
public boolean isOnRails() {
return BlockProperties.isRails(getTypeId())
@ -673,9 +772,12 @@ public class RichBoundsLocation implements IGetBukkitLocation, IGetBlockPosition
}
/**
* Simple block-on-ground check for given margin (no entities). Meant for checking bigger margin than the normal yOnGround.
* @param yOnGround Margin below the player.
* @return
* Simple block-on-ground check for given margin (no entities). Meant for
* checking bigger margin than the normal yOnGround.
*
* @param yOnGround
* Margin below the player.
* @return true, if is on ground
*/
public boolean isOnGround(final double yOnGround) {
if (notOnGroundMaxY >= yOnGround) return false;
@ -684,10 +786,14 @@ public class RichBoundsLocation implements IGetBukkitLocation, IGetBlockPosition
}
/**
* SSimple block-on-ground check for given margin (no entities). Meant for checking bigger margin than the normal yOnGround.
* SSimple block-on-ground check for given margin (no entities). Meant for
* checking bigger margin than the normal yOnGround.
*
* @param yOnGround
* @param ignoreFlags Flags to not regard as ground.
* @return
* the y on ground
* @param ignoreFlags
* Flags to not regard as ground.
* @return true, if is on ground
*/
public boolean isOnGround(final double yOnGround, final long ignoreFlags) {
if (ignoreFlags == 0) {
@ -699,11 +805,16 @@ public class RichBoundsLocation implements IGetBukkitLocation, IGetBlockPosition
/**
* Simple block-on-ground check for given margin (no entities). Meant for checking bigger margin than the normal yOnGround.
* @param yOnGround Margin below the player.
* Simple block-on-ground check for given margin (no entities). Meant for
* checking bigger margin than the normal yOnGround.
*
* @param yOnGround
* Margin below the player.
* @param xzMargin
* @param yMargin Extra margin added below and above.
* @return
* the xz margin
* @param yMargin
* Extra margin added below and above.
* @return true, if is on ground
*/
public boolean isOnGround(final double yOnGround, final double xzMargin, final double yMargin) {
if (xzMargin >= 0 && onGroundMinY <= yOnGround) return true;
@ -714,12 +825,18 @@ public class RichBoundsLocation implements IGetBukkitLocation, IGetBlockPosition
}
/**
* Simple block-on-ground check for given margin (no entities). Meant for checking bigger margin than the normal yOnGround.
* @param yOnGround Margin below the player.
* Simple block-on-ground check for given margin (no entities). Meant for
* checking bigger margin than the normal yOnGround.
*
* @param yOnGround
* Margin below the player.
* @param xzMargin
* @param yMargin Extra margin added below and above.
* @param ignoreFlags Flags to not regard as ground.
* @return
* the xz margin
* @param yMargin
* Extra margin added below and above.
* @param ignoreFlags
* Flags to not regard as ground.
* @return true, if is on ground
*/
public boolean isOnGround(final double yOnGround, final double xzMargin, final double yMargin, final long ignoreFlags) {
if (ignoreFlags == 0) {
@ -747,9 +864,12 @@ public class RichBoundsLocation implements IGetBukkitLocation, IGetBlockPosition
/**
* Check if solid blocks hit the box.
*
* @param xzMargin
* the xz margin
* @param yMargin
* @return
* the y margin
* @return true, if is next to solid
*/
public boolean isNextToSolid(final double xzMargin, final double yMargin) {
// TODO: Adjust to check block flags ?
@ -758,19 +878,27 @@ public class RichBoundsLocation implements IGetBukkitLocation, IGetBlockPosition
/**
* Convenience method for testing for either.
* @return
*
* @return true, if is on ground or reset cond
*/
public boolean isOnGroundOrResetCond() {
return isOnGround() || isResetCond();
}
/**
* Gets the y on ground.
*
* @return the y on ground
*/
public double getyOnGround() {
return yOnGround;
}
/**
* This resets onGround and blockFlags.
*
* @param yOnGround
* the new y on ground
*/
public void setyOnGround(final double yOnGround) {
this.yOnGround = yOnGround;
@ -779,9 +907,10 @@ public class RichBoundsLocation implements IGetBukkitLocation, IGetBlockPosition
}
/**
* Test if the foot location is passable (not the bounding box).
* <br>The result is cached.
* @return
* Test if the foot location is passable (not the bounding box). <br>
* The result is cached.
*
* @return true, if is passable
*/
public boolean isPassable() {
if (passable == null) {
@ -799,8 +928,8 @@ public class RichBoundsLocation implements IGetBukkitLocation, IGetBlockPosition
/**
* Test if the bounding box is colliding (passable check with accounting for
* workarounds).
*
* @return
*
* @return true, if is passable box
*/
public boolean isPassableBox() {
// TODO: Might need a variation with margins as parameters.
@ -819,6 +948,11 @@ public class RichBoundsLocation implements IGetBukkitLocation, IGetBlockPosition
return passableBox;
}
/**
* Checks if is block flags passable.
*
* @return true, if is block flags passable
*/
private boolean isBlockFlagsPassable() {
return blockFlags != null && (blockFlags & (BlockProperties.F_SOLID | BlockProperties.F_GROUND)) == 0;
}
@ -827,8 +961,6 @@ public class RichBoundsLocation implements IGetBukkitLocation, IGetBlockPosition
* Set block flags using yOnGround, unless already set. Check the maximally
* used bounds for the block checking, to have flags ready for faster
* denial.
*
* @param maxYonGround
*/
public void collectBlockFlags() {
if (blockFlags == null) {
@ -837,9 +969,11 @@ public class RichBoundsLocation implements IGetBukkitLocation, IGetBlockPosition
}
/**
* Check the maximally used bounds for the block checking,
* to have flags ready for faster denial.
* Check the maximally used bounds for the block checking, to have flags
* ready for faster denial.
*
* @param maxYonGround
* the max yon ground
*/
public void collectBlockFlags(double maxYonGround) {
maxYonGround = Math.max(yOnGround, maxYonGround);
@ -860,8 +994,11 @@ public class RichBoundsLocation implements IGetBukkitLocation, IGetBlockPosition
}
/**
* Check chunks within xzMargin radius for if they are loaded and load unloaded chunks.
* Check chunks within xzMargin radius for if they are loaded and load
* unloaded chunks.
*
* @param xzMargin
* the xz margin
* @return Number of chunks loaded.
*/
public int ensureChunksLoaded(final double xzMargin) {
@ -871,10 +1008,13 @@ public class RichBoundsLocation implements IGetBukkitLocation, IGetBlockPosition
/**
* Check for push using the full bounding box (pistons). The given
* BlockChangeReference is not changed, it has to be updated externally.
*
*
* @param blockChangeTracker
* @param oldChangeId
* the block change tracker
* @param ref
* the ref
* @param direction
* the direction
* @param coverDistance
* The (always positive) distance to cover.
* @return A matching BlockChangeEntry with the minimal id. If no entry was
@ -908,11 +1048,14 @@ public class RichBoundsLocation implements IGetBukkitLocation, IGetBlockPosition
/**
* Test, if the block intersects the bounding box, if assuming full bounds.
*
*
* @param x
* the x
* @param y
* the y
* @param z
* @return
* the z
* @return true, if is block intersecting
*/
public boolean isBlockIntersecting(final int x, final int y, final int z) {
return TrigUtil.intersectsBlock(minX, maxX, x)
@ -921,14 +1064,20 @@ public class RichBoundsLocation implements IGetBukkitLocation, IGetBlockPosition
}
/**
* Test if a block fully pushed into that direction can push the player by coverDistance.
*
* @param x Block coordinates.
* Test if a block fully pushed into that direction can push the player by
* coverDistance.
*
* @param x
* Block coordinates.
* @param y
* the y
* @param z
* the z
* @param direction
* the direction
* @param coverDistance
* @return
* the cover distance
* @return true, if successful
*/
private boolean coversDistance(final int x, final int y, final int z, final Direction direction, final double coverDistance) {
switch (direction) {
@ -959,8 +1108,11 @@ public class RichBoundsLocation implements IGetBukkitLocation, IGetBlockPosition
/**
* Set cached info according to other.<br>
* Minimal optimizations: take block flags directly, on-ground max/min bounds, only set stairs if not on ground and not reset-condition.
* Minimal optimizations: take block flags directly, on-ground max/min
* bounds, only set stairs if not on ground and not reset-condition.
*
* @param other
* the other
*/
public void prepare(final RichBoundsLocation other) {
// Simple first.
@ -985,10 +1137,34 @@ public class RichBoundsLocation implements IGetBukkitLocation, IGetBlockPosition
}
}
/**
* Sets the.
*
* @param location
* the location
* @param fullWidth
* the full width
* @param fullHeight
* the full height
* @param yOnGround
* the y on ground
*/
public void set(final Location location, final double fullWidth, final double fullHeight, final double yOnGround) {
doSet(location, fullWidth, fullHeight, yOnGround);
}
/**
* Do set.
*
* @param location
* the location
* @param fullWidth
* the full width
* @param fullHeight
* the full height
* @param yOnGround
* the y on ground
*/
protected void doSet(final Location location, final double fullWidth, final double fullHeight, final double yOnGround) {
// Set coordinates.
blockX = location.getBlockX();
@ -1037,11 +1213,17 @@ public class RichBoundsLocation implements IGetBukkitLocation, IGetBlockPosition
blockCache = null; // No reset here.
}
/* (non-Javadoc)
* @see java.lang.Object#hashCode()
*/
@Override
public int hashCode() {
return LocUtil.hashCode(this);
}
/* (non-Javadoc)
* @see java.lang.Object#toString()
*/
@Override
public String toString() {
final StringBuilder builder = new StringBuilder(128);

View File

@ -20,6 +20,7 @@ import org.bukkit.entity.LivingEntity;
import fr.neatmonster.nocheatplus.compat.MCAccess;
// TODO: Auto-generated Javadoc
/**
* A location with an entity with a lot of extra stuff.
*
@ -28,6 +29,7 @@ import fr.neatmonster.nocheatplus.compat.MCAccess;
*/
public class RichEntityLocation extends RichBoundsLocation {
/** The mc access. */
// Final members //
private final MCAccess mcAccess;
@ -55,34 +57,63 @@ public class RichEntityLocation extends RichBoundsLocation {
// "Heavy" object members that need to be set to null on cleanup. //
/** The entity. */
private Entity entity = null;
/**
* Instantiates a new rich entity location.
*
* @param mcAccess
* the mc access
* @param blockCache
* the block cache
*/
public RichEntityLocation(final MCAccess mcAccess, final BlockCache blockCache) {
super(blockCache);
this.mcAccess = mcAccess;
}
/**
* Gets the width.
*
* @return the width
*/
public double getWidth() {
return width;
}
/**
* Gets the height.
*
* @return the height
*/
public double getHeight() {
return height;
}
/**
* Gets the eye height.
*
* @return the eye height
*/
public double getEyeHeight() {
return eyeHeight;
}
/**
* Gets the entity.
*
* @return the entity
*/
public Entity getEntity() {
return entity;
}
/**
* Test if this is a LivingEntity instance.
*
* @return
*
* @return true, if is living
*/
public boolean isLiving() {
return isLiving;
@ -90,7 +121,8 @@ public class RichEntityLocation extends RichBoundsLocation {
/**
* Retrieve the internally stored MCAccess instance.
* @return
*
* @return the MC access
*/
public MCAccess getMCAccess() {
return mcAccess;
@ -99,13 +131,14 @@ public class RichEntityLocation extends RichBoundsLocation {
/**
* Simple check with custom margins (Boat, Minecart). Does not update the
* internally stored standsOnEntity field.
*
*
* @param yOnGround
* Margin below the player.
* @param xzMargin
* the xz margin
* @param yMargin
* Extra margin added below and above.
* @return
* @return true, if successful
*/
public boolean standsOnEntity(final double yOnGround, final double xzMargin, final double yMargin) {
return blockCache.standsOnEntity(entity, minX - xzMargin, minY - yOnGround - yMargin, minZ - xzMargin, maxX + xzMargin, minY + yMargin, maxZ + xzMargin);
@ -142,10 +175,13 @@ public class RichEntityLocation extends RichBoundsLocation {
}
/**
* Check if a player may climb upwards (isOnClimbable returned true, player does not move from/to ground).<br>
* Check if a player may climb upwards (isOnClimbable returned true, player
* does not move from/to ground).<br>
* Having checked the other stuff is prerequisite for calling this (!).
* @param jumpHeigth Height the player is allowed to have jumped.
* @return
*
* @param jumpHeigth
* Height the player is allowed to have jumped.
* @return true, if successful
*/
public boolean canClimbUp(double jumpHeigth) {
// TODO: distinguish vines.
@ -177,9 +213,10 @@ public class RichEntityLocation extends RichBoundsLocation {
/**
* Test if something solid/ground-like collides within the given margin
* above the eye height of the player.
*
*
* @param marginAboveEyeHeight
* @return
* the margin above eye height
* @return true, if is head obstructed
*/
public boolean isHeadObstructed(double marginAboveEyeHeight) {
return isHeadObstructed(marginAboveEyeHeight, true); // TODO: This is changed behavior, need to check calls.
@ -188,12 +225,12 @@ public class RichEntityLocation extends RichBoundsLocation {
/**
* Test if something solid/ground-like collides within the given margin
* above the eye height of the player.
*
*
* @param marginAboveEyeHeight
* Must be greater than or equal zero.
* @param stepCorrection
* If set to true, a correction method is used for leniency.
* @return
* @return true, if is head obstructed
* @throws IllegalArgumentException
* If marginAboveEyeHeight is smaller than 0.
*/
@ -220,8 +257,8 @@ public class RichEntityLocation extends RichBoundsLocation {
/**
* Test if something solid/ground-like collides within a default
* margin/estimation above the eye height of the player.
*
* @return
*
* @return true, if is head obstructed
*/
public boolean isHeadObstructed() {
return isHeadObstructed(0.0, true);
@ -229,42 +266,68 @@ public class RichEntityLocation extends RichBoundsLocation {
/**
* Convenience constructor for using mcAccess.getHeight for fullHeight.
*
* @param location
* the location
* @param entity
* the entity
* @param yOnGround
* the y on ground
*/
public void set(final Location location, final Entity entity, final double yOnGround) {
doSet(location, entity, mcAccess.getWidth(entity), mcAccess.getHeight(entity), yOnGround);
}
/**
*
* Sets the.
*
* @param location
* the location
* @param entity
* the entity
* @param fullHeight
* Allows to specify eyeHeight here. Currently might be
* overridden by eyeHeight, if that is greater.
* @param yOnGround
* the y on ground
*/
public void set(final Location location, final Entity entity, double fullHeight, final double yOnGround) {
doSet(location, entity, mcAccess.getWidth(entity), fullHeight, yOnGround);
}
/**
*
* Sets the.
*
* @param location
* the location
* @param entity
* the entity
* @param fullWidth
* Override the bounding box width (full width).
* @param fullHeight
* Allows to specify eyeHeight here. Currently might be
* overridden by eyeHeight, if that is greater.
* @param yOnGround
* the y on ground
*/
public void set(final Location location, final Entity entity, final double fullWidth, double fullHeight, final double yOnGround) {
doSet(location, entity, fullWidth, fullHeight, yOnGround);
}
/**
* Do set.
*
* @param location
* the location
* @param entity
* the entity
* @param fullWidth
* the full width
* @param fullHeight
* the full height
* @param yOnGround
* the y on ground
*/
protected void doSet(final Location location, final Entity entity, final double fullWidth, double fullHeight, final double yOnGround) {
if (entity instanceof LivingEntity) {
isLiving = true;
@ -284,6 +347,15 @@ public class RichEntityLocation extends RichBoundsLocation {
/**
* Not supported.
*
* @param location
* the location
* @param fullWidth
* the full width
* @param fullHeight
* the full height
* @param yOnGround
* the y on ground
*/
@Override
public void set(Location location, double fullWidth, double fullHeight, double yOnGround) {
@ -292,8 +364,11 @@ public class RichEntityLocation extends RichBoundsLocation {
/**
* Set cached info according to other.<br>
* Minimal optimizations: take block flags directly, on-ground max/min bounds, only set stairs if not on ground and not reset-condition.
* Minimal optimizations: take block flags directly, on-ground max/min
* bounds, only set stairs if not on ground and not reset-condition.
*
* @param other
* the other
*/
public void prepare(final RichEntityLocation other) {
super.prepare(other);
@ -308,6 +383,9 @@ public class RichEntityLocation extends RichBoundsLocation {
entity = null;
}
/* (non-Javadoc)
* @see fr.neatmonster.nocheatplus.utilities.RichBoundsLocation#toString()
*/
@Override
public String toString() {
final StringBuilder builder = new StringBuilder(128);

View File

@ -28,6 +28,10 @@ import fr.neatmonster.nocheatplus.checks.moving.model.VehicleMoveData;
import fr.neatmonster.nocheatplus.checks.moving.util.AuxMoving;
import fr.neatmonster.nocheatplus.checks.workaround.WRPT;
// TODO: Auto-generated Javadoc
/**
* The Class TeleportUtil.
*/
public class TeleportUtil {
/** Temp use. LocUtil.clone on passing. setWorld(null) after use. */
@ -36,10 +40,15 @@ public class TeleportUtil {
/**
* Teleport the player with vehicle, temporarily eject the passenger and set
* teleported in MovingData.
*
*
* @param vehicle
* the vehicle
* @param player
* the player
* @param location
* the location
* @param debug
* the debug
*/
public static void teleport(final Entity vehicle, final Player player, final Location location, final boolean debug) {
// TODO: Rubber band issue needs synchronizing with packet level and ignore certain incoming ones?
@ -116,9 +125,11 @@ public class TeleportUtil {
/**
* Force mounting the vehicle, eject existing passenger.
*
*
* @param passenger
* the passenger
* @param vehicle
* the vehicle
*/
public static void forceMount(Entity passenger, Entity vehicle) {
if (vehicle.getPassenger() != null) {

View File

@ -38,6 +38,7 @@ import fr.neatmonster.nocheatplus.logging.StaticLog;
import fr.neatmonster.nocheatplus.players.DataManager;
import fr.neatmonster.nocheatplus.utilities.ds.count.ActionFrequency;
// TODO: Auto-generated Javadoc
/**
* Task to run every tick, to update permissions and execute actions, and for lag measurement.
*
@ -48,15 +49,37 @@ import fr.neatmonster.nocheatplus.utilities.ds.count.ActionFrequency;
*/
public class TickTask implements Runnable {
/**
* The Class PermissionUpdateEntry.
*/
protected static final class PermissionUpdateEntry{
/** The check type. */
public final CheckType checkType;
/** The player name. */
public final String playerName;
/** The hash code. */
private final int hashCode;
/**
* Instantiates a new permission update entry.
*
* @param playerName
* the player name
* @param checkType
* the check type
*/
public PermissionUpdateEntry(final String playerName, final CheckType checkType) {
this.playerName = playerName;
this.checkType = checkType;
hashCode = playerName.hashCode() ^ checkType.hashCode();
}
/* (non-Javadoc)
* @see java.lang.Object#equals(java.lang.Object)
*/
@Override
public boolean equals(final Object obj) {
if (!(obj instanceof PermissionUpdateEntry)) {
@ -65,19 +88,36 @@ public class TickTask implements Runnable {
final PermissionUpdateEntry other = (PermissionUpdateEntry) obj;
return playerName.equals(other.playerName) && checkType.equals(other.checkType);
}
/* (non-Javadoc)
* @see java.lang.Object#hashCode()
*/
@Override
public int hashCode() {
return hashCode;
}
}
/**
* The Class ImprobableUpdateEntry.
*/
protected static final class ImprobableUpdateEntry {
/** The add level. */
public float addLevel;
/**
* Instantiates a new improbable update entry.
*
* @param addLevel
* the add level
*/
public ImprobableUpdateEntry(float addLevel) {
this.addLevel = addLevel;
}
}
/** The Constant lagMaxTicks. */
public static final int lagMaxTicks = 80;
/** Lock for accessing permissionUpdates. */
@ -86,6 +126,8 @@ public class TickTask implements Runnable {
private static Set<PermissionUpdateEntry> permissionUpdates = new LinkedHashSet<PermissionUpdateEntry>(50);
/** Improbable entries to update. */
private static Map<UUID, ImprobableUpdateEntry> improbableUpdates = new LinkedHashMap<UUID, TickTask.ImprobableUpdateEntry>(50);
/** The Constant improbableLock. */
private static final ReentrantLock improbableLock = new ReentrantLock();
/** Lock for delayedActions. */
@ -99,7 +141,7 @@ public class TickTask implements Runnable {
/** Last n tick durations, measured from run to run.*/
private static final long[] tickDurations = new long[lagMaxTicks];
/** Tick durations summed up in packs of n (nxn time covered) */
/** Tick durations summed up in packs of n (nxn time covered). */
private static final long[] tickDurationsSq = new long[lagMaxTicks];
/** Maximally covered time on ms for lag tracking, roughly. */
@ -111,13 +153,16 @@ public class TickTask implements Runnable {
/** Lag spikes > 150 ms counting (3 x 20 minutes). For lag spike length see spikeDurations. */
private static ActionFrequency[] spikes = new ActionFrequency[spikeDurations.length];
/** Task id of the running TickTask */
/** Task id of the running TickTask. */
protected static int taskId = -1;
/** The tick. */
protected static int tick = 0;
/** The time start. */
protected static long timeStart = 0;
/** The time last. */
protected static long timeLast = 0;
/** Lock flag set on disable. */
@ -206,8 +251,11 @@ public class TickTask implements Runnable {
/**
* Access method to request permission updates.<br>
* NOTE: Thread safe.
*
* @param playerName
* the player name
* @param checkType
* the check type
*/
public static void requestPermissionUpdate(final String playerName, final CheckType checkType) {
synchronized(permissionLock) {
@ -221,7 +269,9 @@ public class TickTask implements Runnable {
/**
* Request actions execution.<br>
* NOTE: Thread safe.
*
* @param actions
* the actions
*/
public static void requestActionsExecution(final ViolationData actions) {
synchronized (actionLock) {
@ -234,8 +284,11 @@ public class TickTask implements Runnable {
/**
* NOTE: Thread-safe.
*
* @param playerId
* @param amount
* the player id
* @param addLevel
* the add level
*/
public static void requestImprobableUpdate(final UUID playerId, final float addLevel) {
if (playerId == null) {
@ -253,13 +306,18 @@ public class TickTask implements Runnable {
}
/**
* Add a tick listener. Can be called during processing, but will take effect on the next tick.<br>
* Add a tick listener. Can be called during processing, but will take
* effect on the next tick.<br>
* NOTES:
* <li>Thread safe.</li>
* <li>Does not work if the TickTask is locked.</li>
* <li>For OnDemandTickListenerS, setRegistered(true) will get called if not locked.</li>
* <li>Will not add the same instance twice, but will call setRegistered each time for OnDemandTickListener instances.</li>
* <li>For OnDemandTickListenerS, setRegistered(true) will get called if not
* locked.</li>
* <li>Will not add the same instance twice, but will call setRegistered
* each time for OnDemandTickListener instances.</li>
*
* @param listener
* the listener
*/
public static void addTickListener(TickListener listener) {
synchronized (tickListeners) {
@ -276,12 +334,15 @@ public class TickTask implements Runnable {
}
/**
* Remove a tick listener. Can be called during processing, but will take effect on the next tick.<br>
* Remove a tick listener. Can be called during processing, but will take
* effect on the next tick.<br>
* NOTES:
* <li>Thread safe.</li>
* <li>Always works.</li>
* <li>For OnDemandTickListenerS, setRegistered(false) will get called.</li>
*
* @param listener
* the listener
* @return If previously contained.
*/
public static boolean removeTickListener(TickListener listener) {
@ -334,7 +395,8 @@ public class TickTask implements Runnable {
/**
* Get the time at which the task was started.
* @return
*
* @return the time start
*/
public static final long getTimeStart() {
return timeStart;
@ -342,7 +404,8 @@ public class TickTask implements Runnable {
/**
* Time when last time processing was finished.
* @return
*
* @return the time last
*/
public static final long getTimeLast() {
return timeLast;
@ -408,9 +471,11 @@ public class TickTask implements Runnable {
}
/**
* Get moderate lag spikes of the last hour (>150 ms, lowest tracked spike duration).
* Get moderate lag spikes of the last hour (>150 ms, lowest tracked spike
* duration).
*
* @return the moderate lag spikes
* @deprecated What is moderate :) ?
* @return
*/
public static final int getModerateLagSpikes() {
spikes[0].update(System.currentTimeMillis());
@ -418,9 +483,11 @@ public class TickTask implements Runnable {
}
/**
* Get heavy lag spikes of the last hour (> 450 ms supposedly, first duration bigger than 150 ms).
* Get heavy lag spikes of the last hour (> 450 ms supposedly, first
* duration bigger than 150 ms).
*
* @return the heavy lag spikes
* @deprecated What is heavy :) ?
* @return
*/
public static final int getHeavyLagSpikes() {
spikes[1].update(System.currentTimeMillis());
@ -428,8 +495,11 @@ public class TickTask implements Runnable {
}
/**
* Get total number of lag spikes counted at all. This is the number of lag spikes with a duration above spikeDuations[0] which should be 150 ms. This is the score of spikes[0].
* @return
* Get total number of lag spikes counted at all. This is the number of lag
* spikes with a duration above spikeDuations[0] which should be 150 ms.
* This is the score of spikes[0].
*
* @return the number of lag spikes
*/
public static final int getNumberOfLagSpikes() {
spikes[0].update(System.currentTimeMillis());
@ -438,15 +508,19 @@ public class TickTask implements Runnable {
/**
* Get the stepping for lag spike duration tracking.
* @return
*
* @return the lag spike durations
*/
public static final long[] getLagSpikeDurations() {
return Arrays.copyOf(spikeDurations, spikeDurations.length);
}
/**
* Get lag spike count according to getLagSpikeDurations() values. Entries of lower indexes contain the entries of higher indexes (so subtraction would be necessary to get spikes from...to).
* @return
* Get lag spike count according to getLagSpikeDurations() values. Entries
* of lower indexes contain the entries of higher indexes (so subtraction
* would be necessary to get spikes from...to).
*
* @return the lag spikes
*/
public static final int[] getLagSpikes() {
final int[] out = new int[spikeDurations.length];
@ -466,6 +540,13 @@ public class TickTask implements Runnable {
return locked;
}
/**
* Start.
*
* @param plugin
* the plugin
* @return the int
*/
// Public methods for internal use.
public static int start(final Plugin plugin) {
cancel();
@ -479,6 +560,9 @@ public class TickTask implements Runnable {
return taskId;
}
/**
* Cancel.
*/
public static void cancel() {
if (taskId == -1) {
return;
@ -490,7 +574,9 @@ public class TickTask implements Runnable {
/**
* Control if new elements can be added to request queues.<br>
* NOTE: This is just a flag, no sync is done here.
*
* @param locked
* the new locked
*/
public static void setLocked(boolean locked) {
// TODO: synchronize over lists !?
@ -561,6 +647,9 @@ public class TickTask implements Runnable {
}
}
/* (non-Javadoc)
* @see java.lang.Runnable#run()
*/
@Override
public void run() {
// Actions.

View File

@ -22,6 +22,7 @@ import org.bukkit.util.Vector;
import fr.neatmonster.nocheatplus.components.location.IGetPosition;
import fr.neatmonster.nocheatplus.components.location.IGetPositionWithLook;
// TODO: Auto-generated Javadoc
/**
* Auxiliary methods for trigonometry related tasks, such as distances, directions, angles.
* @author mc_dev
@ -40,12 +41,13 @@ public class TrigUtil {
/** Precision for the fight.direction check within the LocationTrace loop. */
public static final double DIRECTION_LOOP_PRECISION = 0.5;
/** The Constant useLoc. */
private static final Location useLoc = new Location(null, 0, 0, 0);
/**
* Check if a player looks at a target of a specific size, with a specific
* precision value (roughly).
*
*
* @param player
* the player
* @param targetX
@ -60,7 +62,7 @@ public class TrigUtil {
* the target height
* @param precision
* the precision
* @return
* @return the double
*/
public static double directionCheck(final Player player, final double targetX, final double targetY, final double targetZ, final double targetWidth, final double targetHeight, final double precision)
{
@ -73,12 +75,18 @@ public class TrigUtil {
/**
* Convenience method.
*
* @param sourceFoot
* the source foot
* @param eyeHeight
* the eye height
* @param dir
* the dir
* @param target
* @param precision (width/height are set to 1)
* @return
* the target
* @param precision
* (width/height are set to 1)
* @return the double
*/
public static double directionCheck(final Location sourceFoot, final double eyeHeight, final Vector dir, final Block target, final double precision)
{
@ -87,16 +95,26 @@ public class TrigUtil {
/**
* Convenience method.
*
* @param sourceFoot
* the source foot
* @param eyeHeight
* the eye height
* @param dir
* the dir
* @param targetX
* the target x
* @param targetY
* the target y
* @param targetZ
* the target z
* @param targetWidth
* the target width
* @param targetHeight
* the target height
* @param precision
* @return
* the precision
* @return the double
*/
public static double directionCheck(final Location sourceFoot, final double eyeHeight, final Vector dir, final double targetX, final double targetY, final double targetZ, final double targetWidth, final double targetHeight, final double precision)
{
@ -105,18 +123,31 @@ public class TrigUtil {
/**
* Check how far the looking direction is off the target.
* @param sourceX Source location of looking direction.
*
* @param sourceX
* Source location of looking direction.
* @param sourceY
* the source y
* @param sourceZ
* @param dirX Looking direction.
* the source z
* @param dirX
* Looking direction.
* @param dirY
* the dir y
* @param dirZ
* @param targetX Location that should be looked towards.
* the dir z
* @param targetX
* Location that should be looked towards.
* @param targetY
* the target y
* @param targetZ
* @param targetWidth xz extent
* @param targetHeight y extent
* the target z
* @param targetWidth
* xz extent
* @param targetHeight
* y extent
* @param precision
* the precision
* @return Some offset.
*/
public static double directionCheck(final double sourceX, final double sourceY, final double sourceZ, final double dirX, final double dirY, final double dirZ, final double targetX, final double targetY, final double targetZ, final double targetWidth, final double targetHeight, final double precision)
@ -151,32 +182,89 @@ public class TrigUtil {
return off;
}
/**
* Combined direction check.
*
* @param sourceFoot
* the source foot
* @param eyeHeight
* the eye height
* @param dir
* the dir
* @param targetX
* the target x
* @param targetY
* the target y
* @param targetZ
* the target z
* @param targetWidth
* the target width
* @param targetHeight
* the target height
* @param precision
* the precision
* @param anglePrecision
* the angle precision
* @return the double
*/
public static double combinedDirectionCheck(final Location sourceFoot, final double eyeHeight, final Vector dir, final double targetX, final double targetY, final double targetZ, final double targetWidth, final double targetHeight, final double precision, final double anglePrecision)
{
return combinedDirectionCheck(sourceFoot.getX(), sourceFoot.getY() + eyeHeight, sourceFoot.getZ(), dir.getX(), dir.getY(), dir.getZ(), targetX, targetY, targetZ, targetWidth, targetHeight, precision, anglePrecision);
}
/**
* Combined direction check.
*
* @param sourceFoot
* the source foot
* @param eyeHeight
* the eye height
* @param dir
* the dir
* @param target
* the target
* @param precision
* the precision
* @param anglePrecision
* the angle precision
* @return the double
*/
public static double combinedDirectionCheck(final Location sourceFoot, final double eyeHeight, final Vector dir, final Block target, final double precision, final double anglePrecision)
{
return combinedDirectionCheck(sourceFoot.getX(), sourceFoot.getY() + eyeHeight, sourceFoot.getZ(), dir.getX(), dir.getY(), dir.getZ(), target.getX(), target.getY(), target.getZ(), 1, 1, precision, anglePrecision);
}
/**
* Combine directionCheck with angle, in order to prevent low-distance abuse.
* Combine directionCheck with angle, in order to prevent low-distance
* abuse.
*
* @param sourceX
* the source x
* @param sourceY
* the source y
* @param sourceZ
* the source z
* @param dirX
* the dir x
* @param dirY
* the dir y
* @param dirZ
* the dir z
* @param targetX
* the target x
* @param targetY
* the target y
* @param targetZ
* the target z
* @param targetWidth
* the target width
* @param targetHeight
* the target height
* @param blockPrecision
* @param anglePrecision Precision in grad.
* @return
* the block precision
* @param anglePrecision
* Precision in grad.
* @return the double
*/
public static double combinedDirectionCheck(final double sourceX, final double sourceY, final double sourceZ, final double dirX, final double dirY, final double dirZ, final double targetX, final double targetY, final double targetZ, final double targetWidth, final double targetHeight, final double blockPrecision, final double anglePrecision)
{
@ -252,9 +340,12 @@ public class TrigUtil {
/**
* 3d-distance from location (exact) to block middle.
*
* @param location
* the location
* @param block
* @return
* the block
* @return the double
*/
public static final double distance(final Location location, final Block block)
{
@ -263,13 +354,20 @@ public class TrigUtil {
/**
* 3D-distance.
*
* @param x1
* the x1
* @param y1
* the y1
* @param z1
* the z1
* @param x2
* the x2
* @param y2
* the y2
* @param z2
* @return
* the z2
* @return the double
*/
public static final double distance(final double x1, final double y1, final double z1, final double x2, final double y2, final double z2) {
final double dx = Math.abs(x1 - x2);
@ -278,11 +376,29 @@ public class TrigUtil {
return Math.sqrt(dx * dx + dy * dy + dz * dz);
}
/**
* Distance squared.
*
* @param location1
* the location1
* @param location2
* the location2
* @return the double
*/
public static final double distanceSquared(final Location location1, final Location location2)
{
return distanceSquared(location1.getX(), location1.getY(), location1.getZ(), location2.getX(), location2.getY(), location2.getZ());
}
/**
* Distance squared.
*
* @param location1
* the location1
* @param location2
* the location2
* @return the double
*/
public static final double distanceSquared(final IGetPosition location1, final IGetPosition location2)
{
return distanceSquared(location1.getX(), location1.getY(), location1.getZ(), location2.getX(), location2.getY(), location2.getZ());
@ -290,20 +406,51 @@ public class TrigUtil {
/**
* Horizontal: squared distance.
* @param location1
* @param x1
* @return
*
* @param location
* the location
* @param x
* the x
* @param z
* the z
* @return the double
*/
public static final double distanceSquared(final IGetPosition location, final double x, final double z)
{
return distanceSquared(location.getX(), location.getZ(), x, z);
}
/**
* Distance squared.
*
* @param location1
* the location1
* @param location2
* the location2
* @return the double
*/
public static final double distanceSquared(final IGetPosition location1, final Location location2)
{
return distanceSquared(location1.getX(), location1.getY(), location1.getZ(), location2.getX(), location2.getY(), location2.getZ());
}
/**
* Distance squared.
*
* @param x1
* the x1
* @param y1
* the y1
* @param z1
* the z1
* @param x2
* the x2
* @param y2
* the y2
* @param z2
* the z2
* @return the double
*/
public static final double distanceSquared(final double x1, final double y1, final double z1, final double x2, final double y2, final double z2) {
final double dx = Math.abs(x1 - x2);
final double dy = Math.abs(y1 - y2);
@ -311,6 +458,19 @@ public class TrigUtil {
return dx * dx + dy * dy + dz * dz;
}
/**
* Distance squared.
*
* @param x1
* the x1
* @param z1
* the z1
* @param x2
* the x2
* @param z2
* the z2
* @return the double
*/
public static final double distanceSquared(final double x1, final double z1, final double x2, final double z2) {
final double dx = Math.abs(x1 - x2);
final double dz = Math.abs(z1 - z2);
@ -319,9 +479,12 @@ public class TrigUtil {
/**
* 2D-distance in x-z plane.
*
* @param location1
* the location1
* @param location2
* @return
* the location2
* @return the double
*/
public static final double xzDistance(final Location location1, final Location location2)
{
@ -330,9 +493,12 @@ public class TrigUtil {
/**
* 2D-distance in x-z plane.
*
* @param location1
* the location1
* @param location2
* @return
* the location2
* @return the double
*/
public static final double xzDistance(final IGetPosition location1, final IGetPosition location2)
{
@ -341,9 +507,12 @@ public class TrigUtil {
/**
* 2D-distance in x-z plane.
*
* @param location1
* the location1
* @param location2
* @return
* the location2
* @return the double
*/
public static final double xzDistance(final Location location1, final IGetPosition location2)
{
@ -352,11 +521,16 @@ public class TrigUtil {
/**
* 2D-distance.
*
* @param x1
* the x1
* @param z1
* the z1
* @param x2
* the x2
* @param z2
* @return
* the z2
* @return the double
*/
public static final double distance(final double x1, final double z1, final double x2, final double z2) {
final double dx = Math.abs(x1 - x2);
@ -365,17 +539,29 @@ public class TrigUtil {
}
/**
* Positive angle between vector from source to target and the vector for the given direction [0...PI].
* Positive angle between vector from source to target and the vector for
* the given direction [0...PI].
*
* @param sourceX
* the source x
* @param sourceY
* the source y
* @param sourceZ
* the source z
* @param dirX
* the dir x
* @param dirY
* the dir y
* @param dirZ
* the dir z
* @param targetX
* the target x
* @param targetY
* the target y
* @param targetZ
* @return Positive angle between vector from source to target and the vector for the given direction [0...PI].
* the target z
* @return Positive angle between vector from source to target and the
* vector for the given direction [0...PI].
*/
public static float angle(final double sourceX, final double sourceY, final double sourceZ, final double dirX, final double dirY, final double dirZ, final double targetX, final double targetY, final double targetZ) {
double dirLength = Math.sqrt(dirX * dirX + dirY * dirY + dirZ * dirZ);
@ -396,9 +582,12 @@ public class TrigUtil {
/**
* Angle of a 2d vector, x being the side at the angle. (radians).
*
* @param x
* the x
* @param z
* @return
* the z
* @return the double
*/
public static final double angle(final double x, final double z){
final double a;
@ -414,9 +603,13 @@ public class TrigUtil {
}
/**
* Get the difference of angles (radians) as given from angle(x,z), from a1 to a2, i.e. rather a2 - a1 in principle.
* Get the difference of angles (radians) as given from angle(x,z), from a1
* to a2, i.e. rather a2 - a1 in principle.
*
* @param a1
* the a1
* @param a2
* the a2
* @return Difference of angle from -pi to pi
*/
public static final double angleDiff(final double a1, final double a2){
@ -428,10 +621,15 @@ public class TrigUtil {
}
/**
* Yaw (angle in grad) difference. This ensures inputs are interpreted correctly (for 360 degree offsets).
* Yaw (angle in grad) difference. This ensures inputs are interpreted
* correctly (for 360 degree offsets).
*
* @param fromYaw
* the from yaw
* @param toYaw
* @return Angle difference to get from fromYaw to toYaw. Result is in [-180, 180].
* the to yaw
* @return Angle difference to get from fromYaw to toYaw. Result is in
* [-180, 180].
*/
public static final float yawDiff(float fromYaw, float toYaw){
if (fromYaw <= -360f) fromYaw = -((-fromYaw) % 360f);
@ -446,9 +644,12 @@ public class TrigUtil {
/**
* Manhattan distance.
*
* @param loc1
* the loc1
* @param loc2
* @return
* the loc2
* @return the int
*/
public static int manhattan(final Location loc1, final Location loc2) {
return manhattan(loc1.getBlockX(), loc1.getBlockY(), loc1.getBlockZ(), loc2.getBlockX(), loc2.getBlockY(), loc2.getBlockZ());
@ -456,47 +657,96 @@ public class TrigUtil {
/**
* Manhattan distance.
*
* @param x1
* the x1
* @param y1
* the y1
* @param z1
* the z1
* @param block
* @return
* the block
* @return the int
*/
public static int manhattan(final int x1, final int y1, final int z1, final Block block) {
return manhattan(x1, y1, z1, block.getX(), block.getY(), block.getZ());
}
/**
* Manhattan.
*
* @param x1
* the x1
* @param z1
* the z1
* @param x2
* the x2
* @param z2
* the z2
* @return the double
*/
public static double manhattan(final double x1,final double z1, final double x2, final double z2){
return manhattan(Location.locToBlock(x1), Location.locToBlock(z1), Location.locToBlock(x2), Location.locToBlock(z2));
}
/**
* Manhattan distance (steps along the sides of an orthogonal grid).
*
* @param x1
* the x1
* @param y1
* the y1
* @param z1
* the z1
* @param x2
* the x2
* @param y2
* the y2
* @param z2
* @return
* the z2
* @return the int
*/
public static int manhattan(final int x1, final int y1, final int z1, final int x2, final int y2, final int z2){
return Math.abs(x1 - x2) + Math.abs(y1 - y2) + Math.abs(z1 - z2);
}
/**
* Manhattan.
*
* @param x1
* the x1
* @param y1
* the y1
* @param z1
* the z1
* @param x2
* the x2
* @param y2
* the y2
* @param z2
* the z2
* @return the double
*/
public static double manhattan(final double x1, final double y1, final double z1, final double x2, final double y2, final double z2){
return manhattan(Location.locToBlock(x1), Location.locToBlock(y1), Location.locToBlock(z1), Location.locToBlock(x2), Location.locToBlock(y2), Location.locToBlock(z2));
}
/**
* Maximum distance comparing dx, dy, dz.
*
* @param x1
* the x1
* @param y1
* the y1
* @param z1
* the z1
* @param x2
* the x2
* @param y2
* the y2
* @param z2
* @return
* the z2
* @return the int
*/
public static int maxDistance(final int x1, final int y1, final int z1, final int x2, final int y2, final int z2){
return Math.max(Math.max(Math.abs(x1 - x2), Math.abs(y1 - y2)), Math.abs(z1 - z2));
@ -504,24 +754,36 @@ public class TrigUtil {
/**
* Maximum distance comparing dx, dy, dz.
*
* @param x1
* the x1
* @param y1
* the y1
* @param z1
* the z1
* @param x2
* the x2
* @param y2
* the y2
* @param z2
* @return
* the z2
* @return the double
*/
public static double maxDistance(final double x1, final double y1, final double z1, final double x2, final double y2, final double z2){
return Math.max(Math.max(Math.abs(x1 - x2), Math.abs(y1 - y2)), Math.abs(z1 - z2));
}
/**
* Check if the x-z plane move is "any backwards" regarding the yaw direction.
* Check if the x-z plane move is "any backwards" regarding the yaw
* direction.
*
* @param xDistance
* the x distance
* @param zDistance
* the z distance
* @param yaw
* @return
* the yaw
* @return true, if is moving backwards
*/
public static boolean isMovingBackwards(final double xDistance, final double zDistance, final float yaw) {
return xDistance < 0D && zDistance > 0D && yaw > 180F && yaw < 270F
@ -532,8 +794,11 @@ public class TrigUtil {
/**
* Compare position and looking direction.
*
* @param loc1
* the loc1
* @param loc2
* the loc2
* @return Returns false if either is null.
*/
public static boolean isSamePosAndLook(final Location loc1, final Location loc2) {
@ -543,9 +808,11 @@ public class TrigUtil {
/**
* Test if both locations have the exact same coordinates. Does not check
* yaw/pitch.
*
*
* @param loc1
* the loc1
* @param loc2
* the loc2
* @return Returns false if either is null.
*/
public static boolean isSamePos(final Location loc1, final Location loc2) {
@ -555,8 +822,11 @@ public class TrigUtil {
/**
* Compare position and looking direction.
*
* @param loc1
* the loc1
* @param loc2
* the loc2
* @return Returns false if either is null.
*/
public static boolean isSamePosAndLook(final IGetPositionWithLook loc1, final Location loc2) {
@ -566,9 +836,11 @@ public class TrigUtil {
/**
* Test if both locations have the exact same coordinates. Does not check
* yaw/pitch.
*
*
* @param loc1
* the loc1
* @param loc2
* the loc2
* @return Returns false if either is null.
*/
public static boolean isSamePos(final IGetPositionWithLook loc1, final Location loc2) {
@ -578,8 +850,11 @@ public class TrigUtil {
/**
* Compare position and looking direction.
*
* @param loc1
* the loc1
* @param loc2
* the loc2
* @return Returns false if either is null.
*/
public static boolean isSamePosAndLook(final IGetPositionWithLook loc1, final IGetPositionWithLook loc2) {
@ -589,9 +864,11 @@ public class TrigUtil {
/**
* Test if both locations have the exact same coordinates. Does not check
* yaw/pitch.
*
*
* @param loc1
* the loc1
* @param loc2
* the loc2
* @return Returns false if either is null.
*/
public static boolean isSamePos(final IGetPositionWithLook loc1, final IGetPositionWithLook loc2) {
@ -601,10 +878,15 @@ public class TrigUtil {
/**
* Test if the coordinates represent the same position.
*
* @param loc
* the loc
* @param x
* the x
* @param y
* the y
* @param z
* the z
* @return Returns false if loc is null;
*/
public static boolean isSamePos(final Location loc, final double x, final double y, final double z) {
@ -616,13 +898,20 @@ public class TrigUtil {
/**
* Test if the coordinates represent the same position.
*
* @param x1
* the x1
* @param y1
* the y1
* @param z1
* the z1
* @param x2
* the x2
* @param y2
* the y2
* @param z2
* @return
* the z2
* @return true, if is same pos
*/
public static boolean isSamePos(final double x1, final double y1, final double z1, final double x2, final double y2, final double z2){
return x1 == x2 && y1 == y2 && z1 == z2;
@ -630,23 +919,34 @@ public class TrigUtil {
/**
* Test if the coordinates represent the same position (2D).
*
* @param x1
* the x1
* @param z1
* the z1
* @param x2
* the x2
* @param z2
* @return
* the z2
* @return true, if is same pos
*/
public static boolean isSamePos(final double x1, final double z1, final double x2, final double z2){
return x1 == x2 && z1 == z2;
}
/**
* Test if the given double-coordinates are on the same block as specified by the int-coordinates.
* Test if the given double-coordinates are on the same block as specified
* by the int-coordinates.
*
* @param loc
* the loc
* @param x
* the x
* @param y
* the y
* @param z
* @return
* the z
* @return true, if is same block
*/
public static boolean isSameBlock(final Location loc, final double x, final double y, final double z) {
if (loc == null) {
@ -656,14 +956,21 @@ public class TrigUtil {
}
/**
*
* Checks if is same block.
*
* @param x1
* the x1
* @param y1
* the y1
* @param z1
* the z1
* @param x2
* the x2
* @param y2
* the y2
* @param z2
* @return
* the z2
* @return true, if is same block
*/
public static boolean isSameBlock(final int x1, final int y1, final int z1, final double x2, final double y2, final double z2) {
return x1 == Location.locToBlock(x2) && z1 == Location.locToBlock(z2) && y1 == Location.locToBlock(y2);
@ -671,12 +978,16 @@ public class TrigUtil {
/**
* Test if the block coordinate is intersecting with min+max bounds,
* assuming the a full block. Excludes the case of only the edges intersecting.
*
* assuming the a full block. Excludes the case of only the edges
* intersecting.
*
* @param min
* the min
* @param max
* @param block Block coordinate of the block.
* @return
* the max
* @param block
* Block coordinate of the block.
* @return true, if successful
*/
public static boolean intersectsBlock(final double min, final double max, final int block) {
final double db = (double) block;

View File

@ -1,3 +1,17 @@
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package fr.neatmonster.nocheatplus.utilities.collision;
/**

View File

@ -1,3 +1,17 @@
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package fr.neatmonster.nocheatplus.utilities.collision;
import org.bukkit.Location;

View File

@ -1,3 +1,17 @@
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package fr.neatmonster.nocheatplus.utilities.collision;
import java.util.LinkedList;

View File

@ -1,3 +1,17 @@
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package fr.neatmonster.nocheatplus.utilities.collision;
/**

View File

@ -1,3 +1,17 @@
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package fr.neatmonster.nocheatplus.utilities.collision;
import fr.neatmonster.nocheatplus.utilities.BlockCache;

View File

@ -1,3 +1,17 @@
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package fr.neatmonster.nocheatplus.utilities.collision;
public interface ISetMargins {

View File

@ -1,3 +1,17 @@
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package fr.neatmonster.nocheatplus.utilities.collision;
import fr.neatmonster.nocheatplus.utilities.BlockCache;

View File

@ -1,3 +1,17 @@
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package fr.neatmonster.nocheatplus.compat.meta;
import org.bukkit.entity.Entity;

View File

@ -1,3 +1,17 @@
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package fr.neatmonster.nocheatplus.compat.registry;
import fr.neatmonster.nocheatplus.compat.MCAccess;

View File

@ -1,3 +1,17 @@
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package fr.neatmonster.nocheatplus.compat.registry;
import fr.neatmonster.nocheatplus.NCPAPIProvider;

View File

@ -1,3 +1,17 @@
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package fr.neatmonster.nocheatplus.components.registry;
import java.util.ArrayList;

View File

@ -1,3 +1,17 @@
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package fr.neatmonster.nocheatplus.components.registry.event;
import fr.neatmonster.nocheatplus.components.registry.GenericInstanceRegistry;