Reformat code
This commit is contained in:
parent
53f1508a01
commit
20b545b93d
108 changed files with 10123 additions and 9809 deletions
2
pom.xml
2
pom.xml
|
@ -1,4 +1,4 @@
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>fr.leomelki</groupId>
|
<groupId>fr.leomelki</groupId>
|
||||||
|
|
|
@ -2,30 +2,29 @@
|
||||||
* PacketWrapper - ProtocolLib wrappers for Minecraft packets
|
* PacketWrapper - ProtocolLib wrappers for Minecraft packets
|
||||||
* Copyright (C) dmulloy2 <http://dmulloy2.net>
|
* Copyright (C) dmulloy2 <http://dmulloy2.net>
|
||||||
* Copyright (C) Kristian S. Strangeland
|
* Copyright (C) Kristian S. Strangeland
|
||||||
*
|
* <p>
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
* <p>
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
* <p>
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
package fr.leomelki.com.comphenix.packetwrapper;
|
package fr.leomelki.com.comphenix.packetwrapper;
|
||||||
|
|
||||||
import java.lang.reflect.InvocationTargetException;
|
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
import com.comphenix.protocol.PacketType;
|
import com.comphenix.protocol.PacketType;
|
||||||
import com.comphenix.protocol.ProtocolLibrary;
|
import com.comphenix.protocol.ProtocolLibrary;
|
||||||
import com.comphenix.protocol.events.PacketContainer;
|
import com.comphenix.protocol.events.PacketContainer;
|
||||||
import com.google.common.base.Objects;
|
import com.google.common.base.Objects;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import java.lang.reflect.InvocationTargetException;
|
||||||
|
|
||||||
public abstract class AbstractPacket {
|
public abstract class AbstractPacket {
|
||||||
// The packet we will be modifying
|
// The packet we will be modifying
|
||||||
|
@ -64,7 +63,7 @@ public abstract class AbstractPacket {
|
||||||
* @throws RuntimeException If the packet cannot be sent.
|
* @throws RuntimeException If the packet cannot be sent.
|
||||||
*/
|
*/
|
||||||
public void sendPacket(Player receiver) {
|
public void sendPacket(Player receiver) {
|
||||||
if(receiver == null)
|
if (receiver == null)
|
||||||
return;
|
return;
|
||||||
try {
|
try {
|
||||||
ProtocolLibrary.getProtocolManager().sendServerPacket(receiver,
|
ProtocolLibrary.getProtocolManager().sendServerPacket(receiver,
|
||||||
|
|
|
@ -2,17 +2,17 @@
|
||||||
* PacketWrapper - ProtocolLib wrappers for Minecraft packets
|
* PacketWrapper - ProtocolLib wrappers for Minecraft packets
|
||||||
* Copyright (C) dmulloy2 <http://dmulloy2.net>
|
* Copyright (C) dmulloy2 <http://dmulloy2.net>
|
||||||
* Copyright (C) Kristian S. Strangeland
|
* Copyright (C) Kristian S. Strangeland
|
||||||
*
|
* <p>
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
* <p>
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
* <p>
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -2,30 +2,30 @@
|
||||||
* PacketWrapper - ProtocolLib wrappers for Minecraft packets
|
* PacketWrapper - ProtocolLib wrappers for Minecraft packets
|
||||||
* Copyright (C) dmulloy2 <http://dmulloy2.net>
|
* Copyright (C) dmulloy2 <http://dmulloy2.net>
|
||||||
* Copyright (C) Kristian S. Strangeland
|
* Copyright (C) Kristian S. Strangeland
|
||||||
*
|
* <p>
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
* <p>
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
* <p>
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
package fr.leomelki.com.comphenix.packetwrapper;
|
package fr.leomelki.com.comphenix.packetwrapper;
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
|
|
||||||
import com.comphenix.protocol.PacketType;
|
import com.comphenix.protocol.PacketType;
|
||||||
import com.comphenix.protocol.events.PacketContainer;
|
import com.comphenix.protocol.events.PacketContainer;
|
||||||
import com.comphenix.protocol.wrappers.EnumWrappers;
|
import com.comphenix.protocol.wrappers.EnumWrappers;
|
||||||
import com.comphenix.protocol.wrappers.EnumWrappers.ChatType;
|
import com.comphenix.protocol.wrappers.EnumWrappers.ChatType;
|
||||||
import com.comphenix.protocol.wrappers.WrappedChatComponent;
|
import com.comphenix.protocol.wrappers.WrappedChatComponent;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
public class WrapperPlayServerChat extends AbstractPacket {
|
public class WrapperPlayServerChat extends AbstractPacket {
|
||||||
public static final PacketType TYPE = PacketType.Play.Server.CHAT;
|
public static final PacketType TYPE = PacketType.Play.Server.CHAT;
|
||||||
|
|
||||||
|
@ -95,8 +95,7 @@ public class WrapperPlayServerChat extends AbstractPacket {
|
||||||
public void setPosition(byte value) {
|
public void setPosition(byte value) {
|
||||||
handle.getBytes().writeSafely(0, value);
|
handle.getBytes().writeSafely(0, value);
|
||||||
|
|
||||||
if (EnumWrappers.getChatTypeClass() != null)
|
if (EnumWrappers.getChatTypeClass() != null) {
|
||||||
{
|
|
||||||
Arrays.stream(ChatType.values()).filter(t -> t.getId() == value).findAny()
|
Arrays.stream(ChatType.values()).filter(t -> t.getId() == value).findAny()
|
||||||
.ifPresent(t -> handle.getChatTypes().writeSafely(0, t));
|
.ifPresent(t -> handle.getChatTypes().writeSafely(0, t));
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,17 +2,17 @@
|
||||||
* PacketWrapper - ProtocolLib wrappers for Minecraft packets
|
* PacketWrapper - ProtocolLib wrappers for Minecraft packets
|
||||||
* Copyright (C) dmulloy2 <http://dmulloy2.net>
|
* Copyright (C) dmulloy2 <http://dmulloy2.net>
|
||||||
* Copyright (C) Kristian S. Strangeland
|
* Copyright (C) Kristian S. Strangeland
|
||||||
*
|
* <p>
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
* <p>
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
* <p>
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -2,28 +2,27 @@
|
||||||
* PacketWrapper - ProtocolLib wrappers for Minecraft packets
|
* PacketWrapper - ProtocolLib wrappers for Minecraft packets
|
||||||
* Copyright (C) dmulloy2 <http://dmulloy2.net>
|
* Copyright (C) dmulloy2 <http://dmulloy2.net>
|
||||||
* Copyright (C) Kristian S. Strangeland
|
* Copyright (C) Kristian S. Strangeland
|
||||||
*
|
* <p>
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
* <p>
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
* <p>
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
package fr.leomelki.com.comphenix.packetwrapper;
|
package fr.leomelki.com.comphenix.packetwrapper;
|
||||||
|
|
||||||
import org.bukkit.World;
|
|
||||||
import org.bukkit.entity.Entity;
|
|
||||||
|
|
||||||
import com.comphenix.protocol.PacketType;
|
import com.comphenix.protocol.PacketType;
|
||||||
import com.comphenix.protocol.events.PacketContainer;
|
import com.comphenix.protocol.events.PacketContainer;
|
||||||
import com.comphenix.protocol.events.PacketEvent;
|
import com.comphenix.protocol.events.PacketEvent;
|
||||||
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.entity.Entity;
|
||||||
|
|
||||||
public class WrapperPlayServerEntity extends AbstractPacket {
|
public class WrapperPlayServerEntity extends AbstractPacket {
|
||||||
public static final PacketType TYPE = PacketType.Play.Server.ENTITY;
|
public static final PacketType TYPE = PacketType.Play.Server.ENTITY;
|
||||||
|
|
|
@ -2,17 +2,17 @@
|
||||||
* PacketWrapper - ProtocolLib wrappers for Minecraft packets
|
* PacketWrapper - ProtocolLib wrappers for Minecraft packets
|
||||||
* Copyright (C) dmulloy2 <http://dmulloy2.net>
|
* Copyright (C) dmulloy2 <http://dmulloy2.net>
|
||||||
* Copyright (C) Kristian S. Strangeland
|
* Copyright (C) Kristian S. Strangeland
|
||||||
*
|
* <p>
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
* <p>
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
* <p>
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -2,30 +2,29 @@
|
||||||
* PacketWrapper - ProtocolLib wrappers for Minecraft packets
|
* PacketWrapper - ProtocolLib wrappers for Minecraft packets
|
||||||
* Copyright (C) dmulloy2 <http://dmulloy2.net>
|
* Copyright (C) dmulloy2 <http://dmulloy2.net>
|
||||||
* Copyright (C) Kristian S. Strangeland
|
* Copyright (C) Kristian S. Strangeland
|
||||||
*
|
* <p>
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
* <p>
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
* <p>
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
package fr.leomelki.com.comphenix.packetwrapper;
|
package fr.leomelki.com.comphenix.packetwrapper;
|
||||||
|
|
||||||
import org.bukkit.World;
|
|
||||||
import org.bukkit.entity.Entity;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
|
||||||
|
|
||||||
import com.comphenix.protocol.PacketType;
|
import com.comphenix.protocol.PacketType;
|
||||||
import com.comphenix.protocol.events.PacketContainer;
|
import com.comphenix.protocol.events.PacketContainer;
|
||||||
import com.comphenix.protocol.events.PacketEvent;
|
import com.comphenix.protocol.events.PacketEvent;
|
||||||
import com.comphenix.protocol.wrappers.EnumWrappers.ItemSlot;
|
import com.comphenix.protocol.wrappers.EnumWrappers.ItemSlot;
|
||||||
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.entity.Entity;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
public class WrapperPlayServerEntityEquipment extends AbstractPacket {
|
public class WrapperPlayServerEntityEquipment extends AbstractPacket {
|
||||||
public static final PacketType TYPE =
|
public static final PacketType TYPE =
|
||||||
|
|
|
@ -2,28 +2,27 @@
|
||||||
* PacketWrapper - ProtocolLib wrappers for Minecraft packets
|
* PacketWrapper - ProtocolLib wrappers for Minecraft packets
|
||||||
* Copyright (C) dmulloy2 <http://dmulloy2.net>
|
* Copyright (C) dmulloy2 <http://dmulloy2.net>
|
||||||
* Copyright (C) Kristian S. Strangeland
|
* Copyright (C) Kristian S. Strangeland
|
||||||
*
|
* <p>
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
* <p>
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
* <p>
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
package fr.leomelki.com.comphenix.packetwrapper;
|
package fr.leomelki.com.comphenix.packetwrapper;
|
||||||
|
|
||||||
import org.bukkit.World;
|
|
||||||
import org.bukkit.entity.Entity;
|
|
||||||
|
|
||||||
import com.comphenix.protocol.PacketType;
|
import com.comphenix.protocol.PacketType;
|
||||||
import com.comphenix.protocol.events.PacketContainer;
|
import com.comphenix.protocol.events.PacketContainer;
|
||||||
import com.comphenix.protocol.events.PacketEvent;
|
import com.comphenix.protocol.events.PacketEvent;
|
||||||
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.entity.Entity;
|
||||||
|
|
||||||
public class WrapperPlayServerEntityLook extends AbstractPacket {
|
public class WrapperPlayServerEntityLook extends AbstractPacket {
|
||||||
public static final PacketType TYPE = PacketType.Play.Server.ENTITY_LOOK;
|
public static final PacketType TYPE = PacketType.Play.Server.ENTITY_LOOK;
|
||||||
|
|
|
@ -2,31 +2,30 @@
|
||||||
* PacketWrapper - ProtocolLib wrappers for Minecraft packets
|
* PacketWrapper - ProtocolLib wrappers for Minecraft packets
|
||||||
* Copyright (C) dmulloy2 <http://dmulloy2.net>
|
* Copyright (C) dmulloy2 <http://dmulloy2.net>
|
||||||
* Copyright (C) Kristian S. Strangeland
|
* Copyright (C) Kristian S. Strangeland
|
||||||
*
|
* <p>
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
* <p>
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
* <p>
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
package fr.leomelki.com.comphenix.packetwrapper;
|
package fr.leomelki.com.comphenix.packetwrapper;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.bukkit.World;
|
|
||||||
import org.bukkit.entity.Entity;
|
|
||||||
|
|
||||||
import com.comphenix.protocol.PacketType;
|
import com.comphenix.protocol.PacketType;
|
||||||
import com.comphenix.protocol.events.PacketContainer;
|
import com.comphenix.protocol.events.PacketContainer;
|
||||||
import com.comphenix.protocol.events.PacketEvent;
|
import com.comphenix.protocol.events.PacketEvent;
|
||||||
import com.comphenix.protocol.wrappers.WrappedWatchableObject;
|
import com.comphenix.protocol.wrappers.WrappedWatchableObject;
|
||||||
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.entity.Entity;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class WrapperPlayServerEntityMetadata extends AbstractPacket {
|
public class WrapperPlayServerEntityMetadata extends AbstractPacket {
|
||||||
public static final PacketType TYPE =
|
public static final PacketType TYPE =
|
||||||
|
|
|
@ -2,28 +2,27 @@
|
||||||
* PacketWrapper - ProtocolLib wrappers for Minecraft packets
|
* PacketWrapper - ProtocolLib wrappers for Minecraft packets
|
||||||
* Copyright (C) dmulloy2 <http://dmulloy2.net>
|
* Copyright (C) dmulloy2 <http://dmulloy2.net>
|
||||||
* Copyright (C) Kristian S. Strangeland
|
* Copyright (C) Kristian S. Strangeland
|
||||||
*
|
* <p>
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
* <p>
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
* <p>
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
package fr.leomelki.com.comphenix.packetwrapper;
|
package fr.leomelki.com.comphenix.packetwrapper;
|
||||||
|
|
||||||
import org.bukkit.World;
|
|
||||||
import org.bukkit.entity.Entity;
|
|
||||||
|
|
||||||
import com.comphenix.protocol.PacketType;
|
import com.comphenix.protocol.PacketType;
|
||||||
import com.comphenix.protocol.events.PacketContainer;
|
import com.comphenix.protocol.events.PacketContainer;
|
||||||
import com.comphenix.protocol.events.PacketEvent;
|
import com.comphenix.protocol.events.PacketEvent;
|
||||||
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.entity.Entity;
|
||||||
|
|
||||||
public class WrapperPlayServerEntityTeleport extends AbstractPacket {
|
public class WrapperPlayServerEntityTeleport extends AbstractPacket {
|
||||||
public static final PacketType TYPE =
|
public static final PacketType TYPE =
|
||||||
|
|
|
@ -2,17 +2,17 @@
|
||||||
* PacketWrapper - ProtocolLib wrappers for Minecraft packets
|
* PacketWrapper - ProtocolLib wrappers for Minecraft packets
|
||||||
* Copyright (C) dmulloy2 <http://dmulloy2.net>
|
* Copyright (C) dmulloy2 <http://dmulloy2.net>
|
||||||
* Copyright (C) Kristian S. Strangeland
|
* Copyright (C) Kristian S. Strangeland
|
||||||
*
|
* <p>
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
* <p>
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
* <p>
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -2,17 +2,17 @@
|
||||||
* PacketWrapper - ProtocolLib wrappers for Minecraft packets
|
* PacketWrapper - ProtocolLib wrappers for Minecraft packets
|
||||||
* Copyright (C) dmulloy2 <http://dmulloy2.net>
|
* Copyright (C) dmulloy2 <http://dmulloy2.net>
|
||||||
* Copyright (C) Kristian S. Strangeland
|
* Copyright (C) Kristian S. Strangeland
|
||||||
*
|
* <p>
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
* <p>
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
* <p>
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -2,32 +2,31 @@
|
||||||
* PacketWrapper - ProtocolLib wrappers for Minecraft packets
|
* PacketWrapper - ProtocolLib wrappers for Minecraft packets
|
||||||
* Copyright (C) dmulloy2 <http://dmulloy2.net>
|
* Copyright (C) dmulloy2 <http://dmulloy2.net>
|
||||||
* Copyright (C) Kristian S. Strangeland
|
* Copyright (C) Kristian S. Strangeland
|
||||||
*
|
* <p>
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
* <p>
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
* <p>
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
package fr.leomelki.com.comphenix.packetwrapper;
|
package fr.leomelki.com.comphenix.packetwrapper;
|
||||||
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
import org.bukkit.World;
|
|
||||||
import org.bukkit.entity.Entity;
|
|
||||||
import org.bukkit.util.Vector;
|
|
||||||
|
|
||||||
import com.comphenix.protocol.PacketType;
|
import com.comphenix.protocol.PacketType;
|
||||||
import com.comphenix.protocol.events.PacketContainer;
|
import com.comphenix.protocol.events.PacketContainer;
|
||||||
import com.comphenix.protocol.events.PacketEvent;
|
import com.comphenix.protocol.events.PacketEvent;
|
||||||
import com.comphenix.protocol.wrappers.WrappedDataWatcher;
|
import com.comphenix.protocol.wrappers.WrappedDataWatcher;
|
||||||
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.entity.Entity;
|
||||||
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
public class WrapperPlayServerNamedEntitySpawn extends AbstractPacket {
|
public class WrapperPlayServerNamedEntitySpawn extends AbstractPacket {
|
||||||
public static final PacketType TYPE =
|
public static final PacketType TYPE =
|
||||||
|
|
|
@ -2,27 +2,26 @@
|
||||||
* PacketWrapper - ProtocolLib wrappers for Minecraft packets
|
* PacketWrapper - ProtocolLib wrappers for Minecraft packets
|
||||||
* Copyright (C) dmulloy2 <http://dmulloy2.net>
|
* Copyright (C) dmulloy2 <http://dmulloy2.net>
|
||||||
* Copyright (C) Kristian S. Strangeland
|
* Copyright (C) Kristian S. Strangeland
|
||||||
*
|
* <p>
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
* <p>
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
* <p>
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
package fr.leomelki.com.comphenix.packetwrapper;
|
package fr.leomelki.com.comphenix.packetwrapper;
|
||||||
|
|
||||||
import org.bukkit.Sound;
|
|
||||||
|
|
||||||
import com.comphenix.protocol.PacketType;
|
import com.comphenix.protocol.PacketType;
|
||||||
import com.comphenix.protocol.events.PacketContainer;
|
import com.comphenix.protocol.events.PacketContainer;
|
||||||
import com.comphenix.protocol.wrappers.EnumWrappers.SoundCategory;
|
import com.comphenix.protocol.wrappers.EnumWrappers.SoundCategory;
|
||||||
|
import org.bukkit.Sound;
|
||||||
|
|
||||||
public class WrapperPlayServerNamedSoundEffect extends AbstractPacket {
|
public class WrapperPlayServerNamedSoundEffect extends AbstractPacket {
|
||||||
public static final PacketType TYPE =
|
public static final PacketType TYPE =
|
||||||
|
|
|
@ -2,29 +2,29 @@
|
||||||
* PacketWrapper - ProtocolLib wrappers for Minecraft packets
|
* PacketWrapper - ProtocolLib wrappers for Minecraft packets
|
||||||
* Copyright (C) dmulloy2 <http://dmulloy2.net>
|
* Copyright (C) dmulloy2 <http://dmulloy2.net>
|
||||||
* Copyright (C) Kristian S. Strangeland
|
* Copyright (C) Kristian S. Strangeland
|
||||||
*
|
* <p>
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
* <p>
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
* <p>
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
package fr.leomelki.com.comphenix.packetwrapper;
|
package fr.leomelki.com.comphenix.packetwrapper;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import com.comphenix.protocol.PacketType;
|
import com.comphenix.protocol.PacketType;
|
||||||
import com.comphenix.protocol.events.PacketContainer;
|
import com.comphenix.protocol.events.PacketContainer;
|
||||||
import com.comphenix.protocol.wrappers.EnumWrappers.PlayerInfoAction;
|
import com.comphenix.protocol.wrappers.EnumWrappers.PlayerInfoAction;
|
||||||
import com.comphenix.protocol.wrappers.PlayerInfoData;
|
import com.comphenix.protocol.wrappers.PlayerInfoData;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class WrapperPlayServerPlayerInfo extends AbstractPacket {
|
public class WrapperPlayServerPlayerInfo extends AbstractPacket {
|
||||||
public static final PacketType TYPE = PacketType.Play.Server.PLAYER_INFO;
|
public static final PacketType TYPE = PacketType.Play.Server.PLAYER_INFO;
|
||||||
|
|
||||||
|
|
|
@ -2,32 +2,35 @@
|
||||||
* PacketWrapper - ProtocolLib wrappers for Minecraft packets
|
* PacketWrapper - ProtocolLib wrappers for Minecraft packets
|
||||||
* Copyright (C) dmulloy2 <http://dmulloy2.net>
|
* Copyright (C) dmulloy2 <http://dmulloy2.net>
|
||||||
* Copyright (C) Kristian S. Strangeland
|
* Copyright (C) Kristian S. Strangeland
|
||||||
*
|
* <p>
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
* <p>
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
* <p>
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
package fr.leomelki.com.comphenix.packetwrapper;
|
package fr.leomelki.com.comphenix.packetwrapper;
|
||||||
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import com.comphenix.protocol.PacketType;
|
import com.comphenix.protocol.PacketType;
|
||||||
import com.comphenix.protocol.events.PacketContainer;
|
import com.comphenix.protocol.events.PacketContainer;
|
||||||
import com.comphenix.protocol.reflect.StructureModifier;
|
import com.comphenix.protocol.reflect.StructureModifier;
|
||||||
import com.comphenix.protocol.utility.MinecraftReflection;
|
import com.comphenix.protocol.utility.MinecraftReflection;
|
||||||
import com.comphenix.protocol.wrappers.EnumWrappers;
|
import com.comphenix.protocol.wrappers.EnumWrappers;
|
||||||
|
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
public class WrapperPlayServerPosition extends AbstractPacket {
|
public class WrapperPlayServerPosition extends AbstractPacket {
|
||||||
public static final PacketType TYPE = PacketType.Play.Server.POSITION;
|
public static final PacketType TYPE = PacketType.Play.Server.POSITION;
|
||||||
|
private static final Class<?> FLAGS_CLASS = MinecraftReflection
|
||||||
|
.getMinecraftClass("EnumPlayerTeleportFlags",
|
||||||
|
"PacketPlayOutPosition$EnumPlayerTeleportFlags");
|
||||||
|
|
||||||
public WrapperPlayServerPosition() {
|
public WrapperPlayServerPosition() {
|
||||||
super(new PacketContainer(TYPE), TYPE);
|
super(new PacketContainer(TYPE), TYPE);
|
||||||
|
@ -138,14 +141,6 @@ public class WrapperPlayServerPosition extends AbstractPacket {
|
||||||
handle.getFloat().write(1, value);
|
handle.getFloat().write(1, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final Class<?> FLAGS_CLASS = MinecraftReflection
|
|
||||||
.getMinecraftClass("EnumPlayerTeleportFlags",
|
|
||||||
"PacketPlayOutPosition$EnumPlayerTeleportFlags");
|
|
||||||
|
|
||||||
public enum PlayerTeleportFlag {
|
|
||||||
X, Y, Z, Y_ROT, X_ROT
|
|
||||||
}
|
|
||||||
|
|
||||||
private StructureModifier<Set<PlayerTeleportFlag>> getFlagsModifier() {
|
private StructureModifier<Set<PlayerTeleportFlag>> getFlagsModifier() {
|
||||||
return handle.getSets(
|
return handle.getSets(
|
||||||
EnumWrappers.getGenericConverter(FLAGS_CLASS, PlayerTeleportFlag.class));
|
EnumWrappers.getGenericConverter(FLAGS_CLASS, PlayerTeleportFlag.class));
|
||||||
|
@ -158,4 +153,8 @@ public class WrapperPlayServerPosition extends AbstractPacket {
|
||||||
public void setFlags(Set<PlayerTeleportFlag> value) {
|
public void setFlags(Set<PlayerTeleportFlag> value) {
|
||||||
getFlagsModifier().write(0, value);
|
getFlagsModifier().write(0, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public enum PlayerTeleportFlag {
|
||||||
|
X, Y, Z, Y_ROT, X_ROT
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,28 +2,27 @@
|
||||||
* PacketWrapper - ProtocolLib wrappers for Minecraft packets
|
* PacketWrapper - ProtocolLib wrappers for Minecraft packets
|
||||||
* Copyright (C) dmulloy2 <http://dmulloy2.net>
|
* Copyright (C) dmulloy2 <http://dmulloy2.net>
|
||||||
* Copyright (C) Kristian S. Strangeland
|
* Copyright (C) Kristian S. Strangeland
|
||||||
*
|
* <p>
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
* <p>
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
* <p>
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
package fr.leomelki.com.comphenix.packetwrapper;
|
package fr.leomelki.com.comphenix.packetwrapper;
|
||||||
|
|
||||||
import org.bukkit.WorldType;
|
|
||||||
|
|
||||||
import com.comphenix.protocol.PacketType;
|
import com.comphenix.protocol.PacketType;
|
||||||
import com.comphenix.protocol.events.PacketContainer;
|
import com.comphenix.protocol.events.PacketContainer;
|
||||||
import com.comphenix.protocol.wrappers.EnumWrappers.Difficulty;
|
import com.comphenix.protocol.wrappers.EnumWrappers.Difficulty;
|
||||||
import com.comphenix.protocol.wrappers.EnumWrappers.NativeGameMode;
|
import com.comphenix.protocol.wrappers.EnumWrappers.NativeGameMode;
|
||||||
|
import org.bukkit.WorldType;
|
||||||
|
|
||||||
public class WrapperPlayServerRespawn extends AbstractPacket {
|
public class WrapperPlayServerRespawn extends AbstractPacket {
|
||||||
public static final PacketType TYPE = PacketType.Play.Server.RESPAWN;
|
public static final PacketType TYPE = PacketType.Play.Server.RESPAWN;
|
||||||
|
|
|
@ -2,17 +2,17 @@
|
||||||
* PacketWrapper - ProtocolLib wrappers for Minecraft packets
|
* PacketWrapper - ProtocolLib wrappers for Minecraft packets
|
||||||
* Copyright (C) dmulloy2 <http://dmulloy2.net>
|
* Copyright (C) dmulloy2 <http://dmulloy2.net>
|
||||||
* Copyright (C) Kristian S. Strangeland
|
* Copyright (C) Kristian S. Strangeland
|
||||||
*
|
* <p>
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
* <p>
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
* <p>
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -2,17 +2,17 @@
|
||||||
* PacketWrapper - ProtocolLib wrappers for Minecraft packets
|
* PacketWrapper - ProtocolLib wrappers for Minecraft packets
|
||||||
* Copyright (C) dmulloy2 <http://dmulloy2.net>
|
* Copyright (C) dmulloy2 <http://dmulloy2.net>
|
||||||
* Copyright (C) Kristian S. Strangeland
|
* Copyright (C) Kristian S. Strangeland
|
||||||
*
|
* <p>
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
* <p>
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
* <p>
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
@ -36,23 +36,6 @@ public class WrapperPlayServerScoreboardObjective extends AbstractPacket {
|
||||||
super(packet, TYPE);
|
super(packet, TYPE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Enum containing all known packet modes.
|
|
||||||
*
|
|
||||||
* @author dmulloy2
|
|
||||||
*/
|
|
||||||
public static class Mode extends IntEnum {
|
|
||||||
public static final int ADD_OBJECTIVE = 0;
|
|
||||||
public static final int REMOVE_OBJECTIVE = 1;
|
|
||||||
public static final int UPDATE_VALUE = 2;
|
|
||||||
|
|
||||||
private static final Mode INSTANCE = new Mode();
|
|
||||||
|
|
||||||
public static Mode getInstance() {
|
|
||||||
return INSTANCE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve Objective name.
|
* Retrieve Objective name.
|
||||||
* <p>
|
* <p>
|
||||||
|
@ -138,4 +121,21 @@ public class WrapperPlayServerScoreboardObjective extends AbstractPacket {
|
||||||
public enum HealthDisplay {
|
public enum HealthDisplay {
|
||||||
INTEGER, HEARTS
|
INTEGER, HEARTS
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enum containing all known packet modes.
|
||||||
|
*
|
||||||
|
* @author dmulloy2
|
||||||
|
*/
|
||||||
|
public static class Mode extends IntEnum {
|
||||||
|
public static final int ADD_OBJECTIVE = 0;
|
||||||
|
public static final int REMOVE_OBJECTIVE = 1;
|
||||||
|
public static final int UPDATE_VALUE = 2;
|
||||||
|
|
||||||
|
private static final Mode INSTANCE = new Mode();
|
||||||
|
|
||||||
|
public static Mode getInstance() {
|
||||||
|
return INSTANCE;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,17 +2,17 @@
|
||||||
* PacketWrapper - ProtocolLib wrappers for Minecraft packets
|
* PacketWrapper - ProtocolLib wrappers for Minecraft packets
|
||||||
* Copyright (C) dmulloy2 <http://dmulloy2.net>
|
* Copyright (C) dmulloy2 <http://dmulloy2.net>
|
||||||
* Copyright (C) Kristian S. Strangeland
|
* Copyright (C) Kristian S. Strangeland
|
||||||
*
|
* <p>
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
* <p>
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
* <p>
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -2,33 +2,32 @@
|
||||||
* PacketWrapper - ProtocolLib wrappers for Minecraft packets
|
* PacketWrapper - ProtocolLib wrappers for Minecraft packets
|
||||||
* Copyright (C) dmulloy2 <http://dmulloy2.net>
|
* Copyright (C) dmulloy2 <http://dmulloy2.net>
|
||||||
* Copyright (C) Kristian S. Strangeland
|
* Copyright (C) Kristian S. Strangeland
|
||||||
*
|
* <p>
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
* <p>
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
* <p>
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
package fr.leomelki.com.comphenix.packetwrapper;
|
package fr.leomelki.com.comphenix.packetwrapper;
|
||||||
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import com.comphenix.protocol.PacketType;
|
import com.comphenix.protocol.PacketType;
|
||||||
import com.comphenix.protocol.events.PacketContainer;
|
import com.comphenix.protocol.events.PacketContainer;
|
||||||
import com.comphenix.protocol.reflect.IntEnum;
|
import com.comphenix.protocol.reflect.IntEnum;
|
||||||
import com.comphenix.protocol.utility.MinecraftReflection;
|
import com.comphenix.protocol.utility.MinecraftReflection;
|
||||||
import com.comphenix.protocol.wrappers.WrappedChatComponent;
|
import com.comphenix.protocol.wrappers.WrappedChatComponent;
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class WrapperPlayServerScoreboardTeam extends AbstractPacket {
|
public class WrapperPlayServerScoreboardTeam extends AbstractPacket {
|
||||||
public static final PacketType TYPE =
|
public static final PacketType TYPE =
|
||||||
PacketType.Play.Server.SCOREBOARD_TEAM;
|
PacketType.Play.Server.SCOREBOARD_TEAM;
|
||||||
|
@ -42,25 +41,6 @@ public class WrapperPlayServerScoreboardTeam extends AbstractPacket {
|
||||||
super(packet, TYPE);
|
super(packet, TYPE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Enum containing all known modes.
|
|
||||||
*
|
|
||||||
* @author dmulloy2
|
|
||||||
*/
|
|
||||||
public static class Mode extends IntEnum {
|
|
||||||
public static final int TEAM_CREATED = 0;
|
|
||||||
public static final int TEAM_REMOVED = 1;
|
|
||||||
public static final int TEAM_UPDATED = 2;
|
|
||||||
public static final int PLAYERS_ADDED = 3;
|
|
||||||
public static final int PLAYERS_REMOVED = 4;
|
|
||||||
|
|
||||||
private static final Mode INSTANCE = new Mode();
|
|
||||||
|
|
||||||
public static Mode getInstance() {
|
|
||||||
return INSTANCE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve Team Name.
|
* Retrieve Team Name.
|
||||||
* <p>
|
* <p>
|
||||||
|
@ -276,4 +256,23 @@ public class WrapperPlayServerScoreboardTeam extends AbstractPacket {
|
||||||
public void setPackOptionData(int value) {
|
public void setPackOptionData(int value) {
|
||||||
handle.getIntegers().write(1, value);
|
handle.getIntegers().write(1, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enum containing all known modes.
|
||||||
|
*
|
||||||
|
* @author dmulloy2
|
||||||
|
*/
|
||||||
|
public static class Mode extends IntEnum {
|
||||||
|
public static final int TEAM_CREATED = 0;
|
||||||
|
public static final int TEAM_REMOVED = 1;
|
||||||
|
public static final int TEAM_UPDATED = 2;
|
||||||
|
public static final int PLAYERS_ADDED = 3;
|
||||||
|
public static final int PLAYERS_REMOVED = 4;
|
||||||
|
|
||||||
|
private static final Mode INSTANCE = new Mode();
|
||||||
|
|
||||||
|
public static Mode getInstance() {
|
||||||
|
return INSTANCE;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,86 +2,38 @@
|
||||||
* PacketWrapper - ProtocolLib wrappers for Minecraft packets
|
* PacketWrapper - ProtocolLib wrappers for Minecraft packets
|
||||||
* Copyright (C) dmulloy2 <http://dmulloy2.net>
|
* Copyright (C) dmulloy2 <http://dmulloy2.net>
|
||||||
* Copyright (C) Kristian S. Strangeland
|
* Copyright (C) Kristian S. Strangeland
|
||||||
*
|
* <p>
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
* <p>
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
* <p>
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
package fr.leomelki.com.comphenix.packetwrapper;
|
package fr.leomelki.com.comphenix.packetwrapper;
|
||||||
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
import org.bukkit.World;
|
|
||||||
import org.bukkit.entity.Entity;
|
|
||||||
|
|
||||||
import com.comphenix.protocol.PacketType;
|
import com.comphenix.protocol.PacketType;
|
||||||
import com.comphenix.protocol.ProtocolLibrary;
|
import com.comphenix.protocol.ProtocolLibrary;
|
||||||
import com.comphenix.protocol.events.PacketContainer;
|
import com.comphenix.protocol.events.PacketContainer;
|
||||||
import com.comphenix.protocol.events.PacketEvent;
|
import com.comphenix.protocol.events.PacketEvent;
|
||||||
import com.comphenix.protocol.injector.PacketConstructor;
|
import com.comphenix.protocol.injector.PacketConstructor;
|
||||||
import com.comphenix.protocol.reflect.IntEnum;
|
import com.comphenix.protocol.reflect.IntEnum;
|
||||||
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.entity.Entity;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
public class WrapperPlayServerSpawnEntity extends AbstractPacket {
|
public class WrapperPlayServerSpawnEntity extends AbstractPacket {
|
||||||
public static final PacketType TYPE = PacketType.Play.Server.SPAWN_ENTITY;
|
public static final PacketType TYPE = PacketType.Play.Server.SPAWN_ENTITY;
|
||||||
|
|
||||||
private static PacketConstructor entityConstructor;
|
private static PacketConstructor entityConstructor;
|
||||||
|
|
||||||
/**
|
|
||||||
* Represents the different object types.
|
|
||||||
*
|
|
||||||
* @author Kristian
|
|
||||||
*/
|
|
||||||
public static class ObjectTypes extends IntEnum {
|
|
||||||
public static final int BOAT = 1;
|
|
||||||
public static final int ITEM_STACK = 2;
|
|
||||||
public static final int AREA_EFFECT_CLOUD = 3;
|
|
||||||
public static final int MINECART = 10;
|
|
||||||
public static final int ACTIVATED_TNT = 50;
|
|
||||||
public static final int ENDER_CRYSTAL = 51;
|
|
||||||
public static final int TIPPED_ARROW_PROJECTILE = 60;
|
|
||||||
public static final int SNOWBALL_PROJECTILE = 61;
|
|
||||||
public static final int EGG_PROJECTILE = 62;
|
|
||||||
public static final int GHAST_FIREBALL = 63;
|
|
||||||
public static final int BLAZE_FIREBALL = 64;
|
|
||||||
public static final int THROWN_ENDERPEARL = 65;
|
|
||||||
public static final int WITHER_SKULL_PROJECTILE = 66;
|
|
||||||
public static final int SHULKER_BULLET = 67;
|
|
||||||
public static final int FALLING_BLOCK = 70;
|
|
||||||
public static final int ITEM_FRAME = 71;
|
|
||||||
public static final int EYE_OF_ENDER = 72;
|
|
||||||
public static final int THROWN_POTION = 73;
|
|
||||||
public static final int THROWN_EXP_BOTTLE = 75;
|
|
||||||
public static final int FIREWORK_ROCKET = 76;
|
|
||||||
public static final int LEASH_KNOT = 77;
|
|
||||||
public static final int ARMORSTAND = 78;
|
|
||||||
public static final int FISHING_FLOAT = 90;
|
|
||||||
public static final int SPECTRAL_ARROW = 91;
|
|
||||||
public static final int DRAGON_FIREBALL = 93;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The singleton instance. Can also be retrieved from the parent class.
|
|
||||||
*/
|
|
||||||
private static final ObjectTypes INSTANCE = new ObjectTypes();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Retrieve an instance of the object types enum.
|
|
||||||
*
|
|
||||||
* @return Object type enum.
|
|
||||||
*/
|
|
||||||
public static ObjectTypes getInstance() {
|
|
||||||
return INSTANCE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public WrapperPlayServerSpawnEntity() {
|
public WrapperPlayServerSpawnEntity() {
|
||||||
super(new PacketContainer(TYPE), TYPE);
|
super(new PacketContainer(TYPE), TYPE);
|
||||||
handle.getModifier().writeDefaults();
|
handle.getModifier().writeDefaults();
|
||||||
|
@ -115,6 +67,15 @@ public class WrapperPlayServerSpawnEntity extends AbstractPacket {
|
||||||
return handle.getIntegers().read(0);
|
return handle.getIntegers().read(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set entity ID of the Object.
|
||||||
|
*
|
||||||
|
* @param value - new value.
|
||||||
|
*/
|
||||||
|
public void setEntityID(int value) {
|
||||||
|
handle.getIntegers().write(0, value);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve the entity that will be spawned.
|
* Retrieve the entity that will be spawned.
|
||||||
*
|
*
|
||||||
|
@ -135,15 +96,6 @@ public class WrapperPlayServerSpawnEntity extends AbstractPacket {
|
||||||
return getEntity(event.getPlayer().getWorld());
|
return getEntity(event.getPlayer().getWorld());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Set entity ID of the Object.
|
|
||||||
*
|
|
||||||
* @param value - new value.
|
|
||||||
*/
|
|
||||||
public void setEntityID(int value) {
|
|
||||||
handle.getIntegers().write(0, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
public UUID getUniqueId() {
|
public UUID getUniqueId() {
|
||||||
return handle.getUUIDs().read(0);
|
return handle.getUUIDs().read(0);
|
||||||
}
|
}
|
||||||
|
@ -375,4 +327,51 @@ public class WrapperPlayServerSpawnEntity extends AbstractPacket {
|
||||||
public void setObjectData(int value) {
|
public void setObjectData(int value) {
|
||||||
handle.getIntegers().write(7, value);
|
handle.getIntegers().write(7, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents the different object types.
|
||||||
|
*
|
||||||
|
* @author Kristian
|
||||||
|
*/
|
||||||
|
public static class ObjectTypes extends IntEnum {
|
||||||
|
public static final int BOAT = 1;
|
||||||
|
public static final int ITEM_STACK = 2;
|
||||||
|
public static final int AREA_EFFECT_CLOUD = 3;
|
||||||
|
public static final int MINECART = 10;
|
||||||
|
public static final int ACTIVATED_TNT = 50;
|
||||||
|
public static final int ENDER_CRYSTAL = 51;
|
||||||
|
public static final int TIPPED_ARROW_PROJECTILE = 60;
|
||||||
|
public static final int SNOWBALL_PROJECTILE = 61;
|
||||||
|
public static final int EGG_PROJECTILE = 62;
|
||||||
|
public static final int GHAST_FIREBALL = 63;
|
||||||
|
public static final int BLAZE_FIREBALL = 64;
|
||||||
|
public static final int THROWN_ENDERPEARL = 65;
|
||||||
|
public static final int WITHER_SKULL_PROJECTILE = 66;
|
||||||
|
public static final int SHULKER_BULLET = 67;
|
||||||
|
public static final int FALLING_BLOCK = 70;
|
||||||
|
public static final int ITEM_FRAME = 71;
|
||||||
|
public static final int EYE_OF_ENDER = 72;
|
||||||
|
public static final int THROWN_POTION = 73;
|
||||||
|
public static final int THROWN_EXP_BOTTLE = 75;
|
||||||
|
public static final int FIREWORK_ROCKET = 76;
|
||||||
|
public static final int LEASH_KNOT = 77;
|
||||||
|
public static final int ARMORSTAND = 78;
|
||||||
|
public static final int FISHING_FLOAT = 90;
|
||||||
|
public static final int SPECTRAL_ARROW = 91;
|
||||||
|
public static final int DRAGON_FIREBALL = 93;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The singleton instance. Can also be retrieved from the parent class.
|
||||||
|
*/
|
||||||
|
private static final ObjectTypes INSTANCE = new ObjectTypes();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieve an instance of the object types enum.
|
||||||
|
*
|
||||||
|
* @return Object type enum.
|
||||||
|
*/
|
||||||
|
public static ObjectTypes getInstance() {
|
||||||
|
return INSTANCE;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,33 +2,32 @@
|
||||||
* PacketWrapper - ProtocolLib wrappers for Minecraft packets
|
* PacketWrapper - ProtocolLib wrappers for Minecraft packets
|
||||||
* Copyright (C) dmulloy2 <http://dmulloy2.net>
|
* Copyright (C) dmulloy2 <http://dmulloy2.net>
|
||||||
* Copyright (C) Kristian S. Strangeland
|
* Copyright (C) Kristian S. Strangeland
|
||||||
*
|
* <p>
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
* <p>
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
* <p>
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
package fr.leomelki.com.comphenix.packetwrapper;
|
package fr.leomelki.com.comphenix.packetwrapper;
|
||||||
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
import org.bukkit.World;
|
|
||||||
import org.bukkit.entity.Entity;
|
|
||||||
import org.bukkit.entity.EntityType;
|
|
||||||
|
|
||||||
import com.comphenix.protocol.PacketType;
|
import com.comphenix.protocol.PacketType;
|
||||||
import com.comphenix.protocol.ProtocolLibrary;
|
import com.comphenix.protocol.ProtocolLibrary;
|
||||||
import com.comphenix.protocol.events.PacketContainer;
|
import com.comphenix.protocol.events.PacketContainer;
|
||||||
import com.comphenix.protocol.events.PacketEvent;
|
import com.comphenix.protocol.events.PacketEvent;
|
||||||
import com.comphenix.protocol.injector.PacketConstructor;
|
import com.comphenix.protocol.injector.PacketConstructor;
|
||||||
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.entity.Entity;
|
||||||
|
import org.bukkit.entity.EntityType;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
public class WrapperPlayServerSpawnEntityLiving extends AbstractPacket {
|
public class WrapperPlayServerSpawnEntityLiving extends AbstractPacket {
|
||||||
public static final PacketType TYPE =
|
public static final PacketType TYPE =
|
||||||
|
@ -67,6 +66,15 @@ public class WrapperPlayServerSpawnEntityLiving extends AbstractPacket {
|
||||||
return handle.getIntegers().read(0);
|
return handle.getIntegers().read(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set entity ID.
|
||||||
|
*
|
||||||
|
* @param value - new value.
|
||||||
|
*/
|
||||||
|
public void setEntityID(int value) {
|
||||||
|
handle.getIntegers().write(0, value);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve the entity that will be spawned.
|
* Retrieve the entity that will be spawned.
|
||||||
*
|
*
|
||||||
|
@ -95,15 +103,6 @@ public class WrapperPlayServerSpawnEntityLiving extends AbstractPacket {
|
||||||
handle.getUUIDs().write(0, value);
|
handle.getUUIDs().write(0, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Set entity ID.
|
|
||||||
*
|
|
||||||
* @param value - new value.
|
|
||||||
*/
|
|
||||||
public void setEntityID(int value) {
|
|
||||||
handle.getIntegers().write(0, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve the type of mob.
|
* Retrieve the type of mob.
|
||||||
*
|
*
|
||||||
|
|
|
@ -2,17 +2,17 @@
|
||||||
* This file is part of PacketWrapper.
|
* This file is part of PacketWrapper.
|
||||||
* Copyright (C) 2012-2015 Kristian S. Strangeland
|
* Copyright (C) 2012-2015 Kristian S. Strangeland
|
||||||
* Copyright (C) 2015 dmulloy2
|
* Copyright (C) 2015 dmulloy2
|
||||||
*
|
* <p>
|
||||||
* PacketWrapper is free software: you can redistribute it and/or modify
|
* PacketWrapper is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU Lesser General Public License as published by
|
* it under the terms of the GNU Lesser General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
* <p>
|
||||||
* PacketWrapper is distributed in the hope that it will be useful,
|
* PacketWrapper is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
* <p>
|
||||||
* You should have received a copy of the GNU Lesser General Public License
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
* along with PacketWrapper. If not, see <http://www.gnu.org/licenses/>.
|
* along with PacketWrapper. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -2,17 +2,17 @@
|
||||||
* PacketWrapper - ProtocolLib wrappers for Minecraft packets
|
* PacketWrapper - ProtocolLib wrappers for Minecraft packets
|
||||||
* Copyright (C) dmulloy2 <http://dmulloy2.net>
|
* Copyright (C) dmulloy2 <http://dmulloy2.net>
|
||||||
* Copyright (C) Kristian S. Strangeland
|
* Copyright (C) Kristian S. Strangeland
|
||||||
*
|
* <p>
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
* <p>
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
* <p>
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -2,17 +2,17 @@
|
||||||
* PacketWrapper - ProtocolLib wrappers for Minecraft packets
|
* PacketWrapper - ProtocolLib wrappers for Minecraft packets
|
||||||
* Copyright (C) dmulloy2 <http://dmulloy2.net>
|
* Copyright (C) dmulloy2 <http://dmulloy2.net>
|
||||||
* Copyright (C) Kristian S. Strangeland
|
* Copyright (C) Kristian S. Strangeland
|
||||||
*
|
* <p>
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
* <p>
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
* <p>
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -2,17 +2,17 @@
|
||||||
* PacketWrapper - ProtocolLib wrappers for Minecraft packets
|
* PacketWrapper - ProtocolLib wrappers for Minecraft packets
|
||||||
* Copyright (C) dmulloy2 <http://dmulloy2.net>
|
* Copyright (C) dmulloy2 <http://dmulloy2.net>
|
||||||
* Copyright (C) Kristian S. Strangeland
|
* Copyright (C) Kristian S. Strangeland
|
||||||
*
|
* <p>
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
* <p>
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
* <p>
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -1,18 +1,26 @@
|
||||||
package fr.leomelki.loupgarou;
|
package fr.leomelki.loupgarou;
|
||||||
|
|
||||||
|
|
||||||
import java.io.File;
|
import com.comphenix.protocol.PacketType;
|
||||||
import java.lang.reflect.Constructor;
|
import com.comphenix.protocol.ProtocolLibrary;
|
||||||
import java.util.ArrayList;
|
import com.comphenix.protocol.ProtocolManager;
|
||||||
import java.util.Arrays;
|
import com.comphenix.protocol.events.ListenerPriority;
|
||||||
import java.util.HashMap;
|
import com.comphenix.protocol.events.PacketAdapter;
|
||||||
import java.util.List;
|
import com.comphenix.protocol.events.PacketEvent;
|
||||||
|
import com.comphenix.protocol.wrappers.EnumWrappers.ItemSlot;
|
||||||
import org.bukkit.Bukkit;
|
import com.comphenix.protocol.wrappers.PlayerInfoData;
|
||||||
import org.bukkit.ChatColor;
|
import com.comphenix.protocol.wrappers.WrappedChatComponent;
|
||||||
import org.bukkit.Location;
|
import fr.leomelki.com.comphenix.packetwrapper.*;
|
||||||
import org.bukkit.Material;
|
import fr.leomelki.loupgarou.classes.LGGame;
|
||||||
import org.bukkit.Sound;
|
import fr.leomelki.loupgarou.classes.LGPlayer;
|
||||||
|
import fr.leomelki.loupgarou.classes.LGWinType;
|
||||||
|
import fr.leomelki.loupgarou.events.LGSkinLoadEvent;
|
||||||
|
import fr.leomelki.loupgarou.events.LGUpdatePrefixEvent;
|
||||||
|
import fr.leomelki.loupgarou.listeners.*;
|
||||||
|
import fr.leomelki.loupgarou.roles.*;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
import org.bukkit.*;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.configuration.file.FileConfiguration;
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
|
@ -25,81 +33,36 @@ import org.json.simple.JSONObject;
|
||||||
import org.json.simple.parser.JSONParser;
|
import org.json.simple.parser.JSONParser;
|
||||||
import org.json.simple.parser.ParseException;
|
import org.json.simple.parser.ParseException;
|
||||||
|
|
||||||
import com.comphenix.protocol.PacketType;
|
import java.io.File;
|
||||||
import com.comphenix.protocol.ProtocolLibrary;
|
import java.lang.reflect.Constructor;
|
||||||
import com.comphenix.protocol.ProtocolManager;
|
import java.util.ArrayList;
|
||||||
import com.comphenix.protocol.events.ListenerPriority;
|
import java.util.Arrays;
|
||||||
import com.comphenix.protocol.events.PacketAdapter;
|
import java.util.HashMap;
|
||||||
import com.comphenix.protocol.events.PacketEvent;
|
import java.util.List;
|
||||||
import com.comphenix.protocol.wrappers.EnumWrappers.ItemSlot;
|
|
||||||
import com.comphenix.protocol.wrappers.PlayerInfoData;
|
|
||||||
import com.comphenix.protocol.wrappers.WrappedChatComponent;
|
|
||||||
|
|
||||||
import fr.leomelki.com.comphenix.packetwrapper.WrapperPlayServerEntityEquipment;
|
public class MainLg extends JavaPlugin {
|
||||||
import fr.leomelki.com.comphenix.packetwrapper.WrapperPlayServerNamedSoundEffect;
|
@Getter
|
||||||
import fr.leomelki.com.comphenix.packetwrapper.WrapperPlayServerPlayerInfo;
|
private static final String prefix = ""/*"§7[§9Loup-Garou§7] "*/;
|
||||||
import fr.leomelki.com.comphenix.packetwrapper.WrapperPlayServerScoreboardTeam;
|
|
||||||
import fr.leomelki.com.comphenix.packetwrapper.WrapperPlayServerUpdateHealth;
|
|
||||||
import fr.leomelki.com.comphenix.packetwrapper.WrapperPlayServerUpdateTime;
|
|
||||||
import fr.leomelki.loupgarou.classes.LGGame;
|
|
||||||
import fr.leomelki.loupgarou.classes.LGPlayer;
|
|
||||||
import fr.leomelki.loupgarou.classes.LGWinType;
|
|
||||||
import fr.leomelki.loupgarou.events.LGSkinLoadEvent;
|
|
||||||
import fr.leomelki.loupgarou.events.LGUpdatePrefixEvent;
|
|
||||||
import fr.leomelki.loupgarou.listeners.CancelListener;
|
|
||||||
import fr.leomelki.loupgarou.listeners.ChatListener;
|
|
||||||
import fr.leomelki.loupgarou.listeners.JoinListener;
|
|
||||||
import fr.leomelki.loupgarou.listeners.LoupGarouListener;
|
|
||||||
import fr.leomelki.loupgarou.listeners.VoteListener;
|
|
||||||
import fr.leomelki.loupgarou.roles.RAnge;
|
|
||||||
import fr.leomelki.loupgarou.roles.RAssassin;
|
|
||||||
import fr.leomelki.loupgarou.roles.RBouffon;
|
|
||||||
import fr.leomelki.loupgarou.roles.RChaperonRouge;
|
|
||||||
import fr.leomelki.loupgarou.roles.RChasseur;
|
|
||||||
import fr.leomelki.loupgarou.roles.RChasseurDeVampire;
|
|
||||||
import fr.leomelki.loupgarou.roles.RChienLoup;
|
|
||||||
import fr.leomelki.loupgarou.roles.RCorbeau;
|
|
||||||
import fr.leomelki.loupgarou.roles.RCupidon;
|
|
||||||
import fr.leomelki.loupgarou.roles.RDetective;
|
|
||||||
import fr.leomelki.loupgarou.roles.RDictateur;
|
|
||||||
import fr.leomelki.loupgarou.roles.REnfantSauvage;
|
|
||||||
import fr.leomelki.loupgarou.roles.RFaucheur;
|
|
||||||
import fr.leomelki.loupgarou.roles.RGarde;
|
|
||||||
import fr.leomelki.loupgarou.roles.RGrandMechantLoup;
|
|
||||||
import fr.leomelki.loupgarou.roles.RLoupGarou;
|
|
||||||
import fr.leomelki.loupgarou.roles.RLoupGarouBlanc;
|
|
||||||
import fr.leomelki.loupgarou.roles.RLoupGarouNoir;
|
|
||||||
import fr.leomelki.loupgarou.roles.RMedium;
|
|
||||||
import fr.leomelki.loupgarou.roles.RMontreurDOurs;
|
|
||||||
import fr.leomelki.loupgarou.roles.RPetiteFille;
|
|
||||||
import fr.leomelki.loupgarou.roles.RPirate;
|
|
||||||
import fr.leomelki.loupgarou.roles.RPretre;
|
|
||||||
import fr.leomelki.loupgarou.roles.RPyromane;
|
|
||||||
import fr.leomelki.loupgarou.roles.RSorciere;
|
|
||||||
import fr.leomelki.loupgarou.roles.RSurvivant;
|
|
||||||
import fr.leomelki.loupgarou.roles.RVampire;
|
|
||||||
import fr.leomelki.loupgarou.roles.RVillageois;
|
|
||||||
import fr.leomelki.loupgarou.roles.RVoyante;
|
|
||||||
import fr.leomelki.loupgarou.roles.Role;
|
|
||||||
import lombok.Getter;
|
|
||||||
import lombok.Setter;
|
|
||||||
|
|
||||||
public class MainLg extends JavaPlugin{
|
|
||||||
private static MainLg instance;
|
private static MainLg instance;
|
||||||
@Getter private final HashMap<String, Constructor<? extends Role>> roles = new HashMap<>();
|
@Getter
|
||||||
@Getter private static final String prefix = ""/*"§7[§9Loup-Garou§7] "*/;
|
private final HashMap<String, Constructor<? extends Role>> roles = new HashMap<>();
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
private LGGame currentGame;//Because for now, only one game will be playable on one server (flemme)
|
||||||
|
|
||||||
@Getter @Setter private LGGame currentGame;//Because for now, only one game will be playable on one server (flemme)
|
public static MainLg getInstance() {
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
instance = this;
|
instance = this;
|
||||||
loadRoles();
|
loadRoles();
|
||||||
if(!new File(getDataFolder(), "config.yml").exists()) {//Créer la config
|
if (!new File(getDataFolder(), "config.yml").exists()) {//Créer la config
|
||||||
FileConfiguration config = getConfig();
|
FileConfiguration config = getConfig();
|
||||||
config.set("spawns", new ArrayList<List<Double>>());
|
config.set("spawns", new ArrayList<List<Double>>());
|
||||||
for(String role : roles.keySet())//Nombre de participant pour chaque rôle
|
for (String role : roles.keySet())//Nombre de participant pour chaque rôle
|
||||||
config.set("role."+role, 1);
|
config.set("role." + role, 1);
|
||||||
saveConfig();
|
saveConfig();
|
||||||
}
|
}
|
||||||
loadConfig();
|
loadConfig();
|
||||||
|
@ -109,7 +72,7 @@ public class MainLg extends JavaPlugin{
|
||||||
Bukkit.getPluginManager().registerEvents(new ChatListener(this), this);
|
Bukkit.getPluginManager().registerEvents(new ChatListener(this), this);
|
||||||
Bukkit.getPluginManager().registerEvents(new LoupGarouListener(), this);
|
Bukkit.getPluginManager().registerEvents(new LoupGarouListener(), this);
|
||||||
|
|
||||||
for(Player player : Bukkit.getOnlinePlayers())
|
for (Player player : Bukkit.getOnlinePlayers())
|
||||||
Bukkit.getPluginManager().callEvent(new PlayerJoinEvent(player, "is connected"));
|
Bukkit.getPluginManager().callEvent(new PlayerJoinEvent(player, "is connected"));
|
||||||
|
|
||||||
ProtocolManager protocolManager = ProtocolLibrary.getProtocolManager();
|
ProtocolManager protocolManager = ProtocolLibrary.getProtocolManager();
|
||||||
|
@ -118,7 +81,7 @@ public class MainLg extends JavaPlugin{
|
||||||
public void onPacketSending(PacketEvent event) {
|
public void onPacketSending(PacketEvent event) {
|
||||||
WrapperPlayServerUpdateTime time = new WrapperPlayServerUpdateTime(event.getPacket());
|
WrapperPlayServerUpdateTime time = new WrapperPlayServerUpdateTime(event.getPacket());
|
||||||
LGPlayer lgp = LGPlayer.thePlayer(instance, event.getPlayer());
|
LGPlayer lgp = LGPlayer.thePlayer(instance, event.getPlayer());
|
||||||
if(lgp.getGame() != null && lgp.getGame().getTime() != time.getTimeOfDay())
|
if (lgp.getGame() != null && lgp.getGame().getTime() != time.getTimeOfDay())
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -128,7 +91,7 @@ public class MainLg extends JavaPlugin{
|
||||||
@Override
|
@Override
|
||||||
public void onPacketSending(PacketEvent event) {
|
public void onPacketSending(PacketEvent event) {
|
||||||
WrapperPlayServerNamedSoundEffect sound = new WrapperPlayServerNamedSoundEffect(event.getPacket());
|
WrapperPlayServerNamedSoundEffect sound = new WrapperPlayServerNamedSoundEffect(event.getPacket());
|
||||||
if(sound.getSoundEffect() == Sound.ENTITY_PLAYER_ATTACK_NODAMAGE)
|
if (sound.getSoundEffect() == Sound.ENTITY_PLAYER_ATTACK_NODAMAGE)
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -139,19 +102,19 @@ public class MainLg extends JavaPlugin{
|
||||||
LGPlayer player = LGPlayer.thePlayer(instance, event.getPlayer());
|
LGPlayer player = LGPlayer.thePlayer(instance, event.getPlayer());
|
||||||
WrapperPlayServerPlayerInfo info = new WrapperPlayServerPlayerInfo(event.getPacket());
|
WrapperPlayServerPlayerInfo info = new WrapperPlayServerPlayerInfo(event.getPacket());
|
||||||
ArrayList<PlayerInfoData> datas = new ArrayList<>();
|
ArrayList<PlayerInfoData> datas = new ArrayList<>();
|
||||||
for(PlayerInfoData data : info.getData()) {
|
for (PlayerInfoData data : info.getData()) {
|
||||||
LGPlayer lgp = LGPlayer.thePlayer(instance, Bukkit.getPlayer(data.getProfile().getUUID()));
|
LGPlayer lgp = LGPlayer.thePlayer(instance, Bukkit.getPlayer(data.getProfile().getUUID()));
|
||||||
if(player.getGame() != null && player.getGame() == lgp.getGame()) {
|
if (player.getGame() != null && player.getGame() == lgp.getGame()) {
|
||||||
LGUpdatePrefixEvent evt2 = new LGUpdatePrefixEvent(player.getGame(), lgp, player, "");
|
LGUpdatePrefixEvent evt2 = new LGUpdatePrefixEvent(player.getGame(), lgp, player, "");
|
||||||
WrappedChatComponent displayName = data.getDisplayName();
|
WrappedChatComponent displayName = data.getDisplayName();
|
||||||
Bukkit.getPluginManager().callEvent(evt2);
|
Bukkit.getPluginManager().callEvent(evt2);
|
||||||
if(evt2.getPrefix().length() > 0) {
|
if (evt2.getPrefix().length() > 0) {
|
||||||
try {
|
try {
|
||||||
if(displayName != null) {
|
if (displayName != null) {
|
||||||
JSONObject obj = (JSONObject) new JSONParser().parse(displayName.getJson());
|
JSONObject obj = (JSONObject) new JSONParser().parse(displayName.getJson());
|
||||||
displayName = WrappedChatComponent.fromText(evt2.getPrefix()+obj.get("text"));
|
displayName = WrappedChatComponent.fromText(evt2.getPrefix() + obj.get("text"));
|
||||||
} else
|
} else
|
||||||
displayName = WrappedChatComponent.fromText(evt2.getPrefix()+data.getProfile().getName());
|
displayName = WrappedChatComponent.fromText(evt2.getPrefix() + data.getProfile().getName());
|
||||||
} catch (ParseException e) {
|
} catch (ParseException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
@ -159,7 +122,7 @@ public class MainLg extends JavaPlugin{
|
||||||
LGSkinLoadEvent evt = new LGSkinLoadEvent(lgp.getGame(), lgp, player, data.getProfile());
|
LGSkinLoadEvent evt = new LGSkinLoadEvent(lgp.getGame(), lgp, player, data.getProfile());
|
||||||
Bukkit.getPluginManager().callEvent(evt);
|
Bukkit.getPluginManager().callEvent(evt);
|
||||||
datas.add(new PlayerInfoData(evt.getProfile(), data.getLatency(), data.getGameMode(), displayName));
|
datas.add(new PlayerInfoData(evt.getProfile(), data.getLatency(), data.getGameMode(), displayName));
|
||||||
}else
|
} else
|
||||||
datas.add(data);
|
datas.add(data);
|
||||||
}
|
}
|
||||||
info.setData(datas);
|
info.setData(datas);
|
||||||
|
@ -169,7 +132,7 @@ public class MainLg extends JavaPlugin{
|
||||||
@Override
|
@Override
|
||||||
public void onPacketSending(PacketEvent event) {
|
public void onPacketSending(PacketEvent event) {
|
||||||
LGPlayer player = LGPlayer.thePlayer(instance, event.getPlayer());
|
LGPlayer player = LGPlayer.thePlayer(instance, event.getPlayer());
|
||||||
if(player.getGame() != null && player.getGame().isStarted()) {
|
if (player.getGame() != null && player.getGame().isStarted()) {
|
||||||
WrapperPlayServerUpdateHealth health = new WrapperPlayServerUpdateHealth(event.getPacket());
|
WrapperPlayServerUpdateHealth health = new WrapperPlayServerUpdateHealth(event.getPacket());
|
||||||
health.setFood(6);
|
health.setFood(6);
|
||||||
}
|
}
|
||||||
|
@ -182,12 +145,12 @@ public class MainLg extends JavaPlugin{
|
||||||
WrapperPlayServerScoreboardTeam team = new WrapperPlayServerScoreboardTeam(event.getPacket());
|
WrapperPlayServerScoreboardTeam team = new WrapperPlayServerScoreboardTeam(event.getPacket());
|
||||||
team.setColor(ChatColor.WHITE);
|
team.setColor(ChatColor.WHITE);
|
||||||
Player other = Bukkit.getPlayer(team.getName());
|
Player other = Bukkit.getPlayer(team.getName());
|
||||||
if(other == null)return;
|
if (other == null) return;
|
||||||
LGPlayer lgp = LGPlayer.thePlayer(instance, other);
|
LGPlayer lgp = LGPlayer.thePlayer(instance, other);
|
||||||
if(player.getGame() != null && player.getGame() == lgp.getGame()) {
|
if (player.getGame() != null && player.getGame() == lgp.getGame()) {
|
||||||
LGUpdatePrefixEvent evt2 = new LGUpdatePrefixEvent(player.getGame(), lgp, player, "");
|
LGUpdatePrefixEvent evt2 = new LGUpdatePrefixEvent(player.getGame(), lgp, player, "");
|
||||||
Bukkit.getPluginManager().callEvent(evt2);
|
Bukkit.getPluginManager().callEvent(evt2);
|
||||||
if(evt2.getPrefix().length() > 0)
|
if (evt2.getPrefix().length() > 0)
|
||||||
team.setPrefix(WrappedChatComponent.fromText(evt2.getPrefix()));
|
team.setPrefix(WrappedChatComponent.fromText(evt2.getPrefix()));
|
||||||
else
|
else
|
||||||
team.setPrefix(WrappedChatComponent.fromText("§f"));
|
team.setPrefix(WrappedChatComponent.fromText("§f"));
|
||||||
|
@ -198,9 +161,9 @@ public class MainLg extends JavaPlugin{
|
||||||
@Override
|
@Override
|
||||||
public void onPacketSending(PacketEvent event) {
|
public void onPacketSending(PacketEvent event) {
|
||||||
LGPlayer player = LGPlayer.thePlayer(instance, event.getPlayer());
|
LGPlayer player = LGPlayer.thePlayer(instance, event.getPlayer());
|
||||||
if(player.getGame() != null) {
|
if (player.getGame() != null) {
|
||||||
WrapperPlayServerEntityEquipment equip = new WrapperPlayServerEntityEquipment(event.getPacket());
|
WrapperPlayServerEntityEquipment equip = new WrapperPlayServerEntityEquipment(event.getPacket());
|
||||||
if(equip.getSlot() == ItemSlot.OFFHAND && equip.getEntityID() != player.getPlayer().getEntityId())
|
if (equip.getSlot() == ItemSlot.OFFHAND && equip.getEntityID() != player.getPlayer().getEntityId())
|
||||||
equip.setItem(new ItemStack(Material.AIR));
|
equip.setItem(new ItemStack(Material.AIR));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -211,56 +174,56 @@ public class MainLg extends JavaPlugin{
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
if(label.equalsIgnoreCase("ww")) {
|
if (label.equalsIgnoreCase("ww")) {
|
||||||
if(!sender.hasPermission("loupgarou.admin")) {
|
if (!sender.hasPermission("loupgarou.admin")) {
|
||||||
sender.sendMessage(prefix+"§4Erreur: Vous n'avez pas la permission...");
|
sender.sendMessage(prefix + "§4Erreur: Vous n'avez pas la permission...");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if(args.length >= 1) {
|
if (args.length >= 1) {
|
||||||
if(args[0].equalsIgnoreCase("addspawn")) {
|
if (args[0].equalsIgnoreCase("addspawn")) {
|
||||||
Player player = (Player)sender;
|
Player player = (Player) sender;
|
||||||
Location loc = player.getLocation();
|
Location loc = player.getLocation();
|
||||||
List<Object> list = (List<Object>) getConfig().getList("spawns");
|
List<Object> list = (List<Object>) getConfig().getList("spawns");
|
||||||
list.add(Arrays.asList((double)loc.getBlockX(), loc.getY(), (double)loc.getBlockZ(), (double)loc.getYaw(), (double)loc.getPitch()));
|
list.add(Arrays.asList((double) loc.getBlockX(), loc.getY(), (double) loc.getBlockZ(), (double) loc.getYaw(), (double) loc.getPitch()));
|
||||||
saveConfig();
|
saveConfig();
|
||||||
loadConfig();
|
loadConfig();
|
||||||
sender.sendMessage(prefix+"§aLa position a bien été ajoutée !");
|
sender.sendMessage(prefix + "§aLa position a bien été ajoutée !");
|
||||||
return true;
|
return true;
|
||||||
}else if(args[0].equalsIgnoreCase("end")) {
|
} else if (args[0].equalsIgnoreCase("end")) {
|
||||||
if(args.length != 2) {
|
if (args.length != 2) {
|
||||||
sender.sendMessage("§4Utilisation : §c/lg end <pseudo>");
|
sender.sendMessage("§4Utilisation : §c/lg end <pseudo>");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
Player selected = Bukkit.getPlayer(args[1]);
|
Player selected = Bukkit.getPlayer(args[1]);
|
||||||
if(selected == null) {
|
if (selected == null) {
|
||||||
sender.sendMessage("§4Erreur : §cLe joueur §4"+args[1]+"§c n'est pas connecté.");
|
sender.sendMessage("§4Erreur : §cLe joueur §4" + args[1] + "§c n'est pas connecté.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
LGGame game = LGPlayer.thePlayer(instance, selected).getGame();
|
LGGame game = LGPlayer.thePlayer(instance, selected).getGame();
|
||||||
if(game == null) {
|
if (game == null) {
|
||||||
sender.sendMessage("§4Erreur : §cLe joueur §4"+selected.getName()+"§c n'est pas dans une partie.");
|
sender.sendMessage("§4Erreur : §cLe joueur §4" + selected.getName() + "§c n'est pas dans une partie.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
game.cancelWait();
|
game.cancelWait();
|
||||||
game.endGame(LGWinType.EQUAL);
|
game.endGame(LGWinType.EQUAL);
|
||||||
game.broadcastMessage("§cLa partie a été arrêtée de force !");
|
game.broadcastMessage("§cLa partie a été arrêtée de force !");
|
||||||
return true;
|
return true;
|
||||||
}else if(args[0].equalsIgnoreCase("start")) {
|
} else if (args[0].equalsIgnoreCase("start")) {
|
||||||
if(args.length < 2) {
|
if (args.length < 2) {
|
||||||
sender.sendMessage("§4Utilisation : §c/lg start <pseudo>");
|
sender.sendMessage("§4Utilisation : §c/lg start <pseudo>");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
Player player = Bukkit.getPlayer(args[1]);
|
Player player = Bukkit.getPlayer(args[1]);
|
||||||
if(player == null) {
|
if (player == null) {
|
||||||
sender.sendMessage("§4Erreur : §cLe joueur §4"+args[1]+"§c n'existe pas !");
|
sender.sendMessage("§4Erreur : §cLe joueur §4" + args[1] + "§c n'existe pas !");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
LGPlayer lgp = LGPlayer.thePlayer(instance, player);
|
LGPlayer lgp = LGPlayer.thePlayer(instance, player);
|
||||||
if(lgp.getGame() == null) {
|
if (lgp.getGame() == null) {
|
||||||
sender.sendMessage("§4Erreur : §cLe joueur §4"+lgp.getName()+"§c n'est pas dans une partie.");
|
sender.sendMessage("§4Erreur : §cLe joueur §4" + lgp.getName() + "§c n'est pas dans une partie.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if(MainLg.getInstance().getConfig().getList("spawns").size() < lgp.getGame().getMaxPlayers()) {
|
if (MainLg.getInstance().getConfig().getList("spawns").size() < lgp.getGame().getMaxPlayers()) {
|
||||||
sender.sendMessage("§4Erreur : §cIl n'y a pas assez de points de spawn !");
|
sender.sendMessage("§4Erreur : §cIl n'y a pas assez de points de spawn !");
|
||||||
sender.sendMessage("§8§oPour les définir, merci de faire §7/lg addSpawn");
|
sender.sendMessage("§8§oPour les définir, merci de faire §7/lg addSpawn");
|
||||||
return true;
|
return true;
|
||||||
|
@ -268,143 +231,147 @@ public class MainLg extends JavaPlugin{
|
||||||
sender.sendMessage("§aVous avez bien démarré une nouvelle partie !");
|
sender.sendMessage("§aVous avez bien démarré une nouvelle partie !");
|
||||||
lgp.getGame().updateStart();
|
lgp.getGame().updateStart();
|
||||||
return true;
|
return true;
|
||||||
}else if(args[0].equalsIgnoreCase("reloadconfig")) {
|
} else if (args[0].equalsIgnoreCase("reloadconfig")) {
|
||||||
sender.sendMessage("§aVous avez bien reload la config !");
|
sender.sendMessage("§aVous avez bien reload la config !");
|
||||||
sender.sendMessage("§7§oSi vous avez changé les rôles, écriver §8§o/lg joinall§7§o !");
|
sender.sendMessage("§7§oSi vous avez changé les rôles, écriver §8§o/lg joinall§7§o !");
|
||||||
loadConfig();
|
loadConfig();
|
||||||
return true;
|
return true;
|
||||||
}else if(args[0].equalsIgnoreCase("joinall")) {
|
} else if (args[0].equalsIgnoreCase("joinall")) {
|
||||||
for(Player p : Bukkit.getOnlinePlayers())
|
for (Player p : Bukkit.getOnlinePlayers())
|
||||||
Bukkit.getPluginManager().callEvent(new PlayerQuitEvent(p, "joinall"));
|
Bukkit.getPluginManager().callEvent(new PlayerQuitEvent(p, "joinall"));
|
||||||
for(Player p : Bukkit.getOnlinePlayers())
|
for (Player p : Bukkit.getOnlinePlayers())
|
||||||
Bukkit.getPluginManager().callEvent(new PlayerJoinEvent(p, "joinall"));
|
Bukkit.getPluginManager().callEvent(new PlayerJoinEvent(p, "joinall"));
|
||||||
return true;
|
return true;
|
||||||
}else if(args[0].equalsIgnoreCase("reloadPacks")) {
|
} else if (args[0].equalsIgnoreCase("reloadPacks")) {
|
||||||
for(Player p : Bukkit.getOnlinePlayers())
|
for (Player p : Bukkit.getOnlinePlayers())
|
||||||
Bukkit.getPluginManager().callEvent(new PlayerQuitEvent(p, "reloadPacks"));
|
Bukkit.getPluginManager().callEvent(new PlayerQuitEvent(p, "reloadPacks"));
|
||||||
for(Player p : Bukkit.getOnlinePlayers())
|
for (Player p : Bukkit.getOnlinePlayers())
|
||||||
Bukkit.getPluginManager().callEvent(new PlayerJoinEvent(p, "reloadPacks"));
|
Bukkit.getPluginManager().callEvent(new PlayerJoinEvent(p, "reloadPacks"));
|
||||||
return true;
|
return true;
|
||||||
}else if(args[0].equalsIgnoreCase("nextNight")) {
|
} else if (args[0].equalsIgnoreCase("nextNight")) {
|
||||||
sender.sendMessage("§aVous êtes passé à la prochaine nuit");
|
sender.sendMessage("§aVous êtes passé à la prochaine nuit");
|
||||||
if(getCurrentGame() != null) {
|
if (getCurrentGame() != null) {
|
||||||
getCurrentGame().broadcastMessage("§2§lLe passage à la prochaine nuit a été forcé !");
|
getCurrentGame().broadcastMessage("§2§lLe passage à la prochaine nuit a été forcé !");
|
||||||
for(LGPlayer lgp : getCurrentGame().getInGame())
|
for (LGPlayer lgp : getCurrentGame().getInGame())
|
||||||
lgp.stopChoosing();
|
lgp.stopChoosing();
|
||||||
getCurrentGame().cancelWait();
|
getCurrentGame().cancelWait();
|
||||||
getCurrentGame().nextNight();
|
getCurrentGame().nextNight();
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}else if(args[0].equalsIgnoreCase("nextDay")) {
|
} else if (args[0].equalsIgnoreCase("nextDay")) {
|
||||||
sender.sendMessage("§aVous êtes passé à la prochaine journée");
|
sender.sendMessage("§aVous êtes passé à la prochaine journée");
|
||||||
if(getCurrentGame() != null) {
|
if (getCurrentGame() != null) {
|
||||||
getCurrentGame().broadcastMessage("§2§lLe passage à la prochaine journée a été forcé !");
|
getCurrentGame().broadcastMessage("§2§lLe passage à la prochaine journée a été forcé !");
|
||||||
getCurrentGame().cancelWait();
|
getCurrentGame().cancelWait();
|
||||||
for(LGPlayer lgp : getCurrentGame().getInGame())
|
for (LGPlayer lgp : getCurrentGame().getInGame())
|
||||||
lgp.stopChoosing();
|
lgp.stopChoosing();
|
||||||
getCurrentGame().endNight();
|
getCurrentGame().endNight();
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}else if(args[0].equalsIgnoreCase("roles")) {
|
} else if (args[0].equalsIgnoreCase("roles")) {
|
||||||
if(args.length == 1 || args[1].equalsIgnoreCase("list")) {
|
if (args.length == 1 || args[1].equalsIgnoreCase("list")) {
|
||||||
sender.sendMessage(prefix+"§6Voici la liste des rôles:");
|
sender.sendMessage(prefix + "§6Voici la liste des rôles:");
|
||||||
int index = 0;
|
int index = 0;
|
||||||
for(String role : getRoles().keySet())
|
for (String role : getRoles().keySet())
|
||||||
sender.sendMessage(prefix+" §e- "+index+++" - §6"+role+" §e> "+MainLg.getInstance().getConfig().getInt("role."+role));
|
sender.sendMessage(prefix + " §e- " + index++ + " - §6" + role + " §e> " + MainLg.getInstance().getConfig().getInt("role." + role));
|
||||||
sender.sendMessage("\n"+prefix+" §7Écrivez §8§o/lg roles set <role_id/role_name> <nombre>§7 pour définir le nombre de joueurs qui devrons avoir ce rôle.");
|
sender.sendMessage("\n" + prefix + " §7Écrivez §8§o/lg roles set <role_id/role_name> <nombre>§7 pour définir le nombre de joueurs qui devrons avoir ce rôle.");
|
||||||
} else {
|
} else {
|
||||||
if(args[1].equalsIgnoreCase("set") && args.length == 4) {
|
if (args[1].equalsIgnoreCase("set") && args.length == 4) {
|
||||||
String role = null;
|
String role = null;
|
||||||
if(args[2].length() <= 2)
|
if (args[2].length() <= 2)
|
||||||
try {
|
try {
|
||||||
int i = Integer.parseInt(args[2]);
|
int i = Integer.parseInt(args[2]);
|
||||||
Object[] array = getRoles().keySet().toArray();
|
Object[] array = getRoles().keySet().toArray();
|
||||||
if(array.length <= i) {
|
if (array.length <= i) {
|
||||||
sender.sendMessage(prefix+"§4Erreur: §cCe rôle n'existe pas.");
|
sender.sendMessage(prefix + "§4Erreur: §cCe rôle n'existe pas.");
|
||||||
return true;
|
return true;
|
||||||
}else
|
} else
|
||||||
role = (String)array[i];
|
role = (String) array[i];
|
||||||
}catch(Exception err) {sender.sendMessage(prefix+"§4Erreur: §cCeci n'est pas un nombre");}
|
} catch (Exception err) {
|
||||||
|
sender.sendMessage(prefix + "§4Erreur: §cCeci n'est pas un nombre");
|
||||||
|
}
|
||||||
else
|
else
|
||||||
role = args[2];
|
role = args[2];
|
||||||
|
|
||||||
if(role != null) {
|
if (role != null) {
|
||||||
String real_role = null;
|
String real_role = null;
|
||||||
for(String real : getRoles().keySet())
|
for (String real : getRoles().keySet())
|
||||||
if(real.equalsIgnoreCase(role)) {
|
if (real.equalsIgnoreCase(role)) {
|
||||||
real_role = real;
|
real_role = real;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(real_role != null) {
|
if (real_role != null) {
|
||||||
try {
|
try {
|
||||||
MainLg.getInstance().getConfig().set("role."+real_role, Integer.valueOf(args[3]));
|
MainLg.getInstance().getConfig().set("role." + real_role, Integer.valueOf(args[3]));
|
||||||
sender.sendMessage(prefix+"§6Il y aura §e"+args[3]+" §6"+real_role);
|
sender.sendMessage(prefix + "§6Il y aura §e" + args[3] + " §6" + real_role);
|
||||||
saveConfig();
|
saveConfig();
|
||||||
loadConfig();
|
loadConfig();
|
||||||
sender.sendMessage("§7§oSi vous avez fini de changer les rôles, écriver §8§o/lg joinall§7§o !");
|
sender.sendMessage("§7§oSi vous avez fini de changer les rôles, écriver §8§o/lg joinall§7§o !");
|
||||||
}catch(Exception err) {
|
} catch (Exception err) {
|
||||||
sender.sendMessage(prefix+"§4Erreur: §c"+args[3]+" n'est pas un nombre");
|
sender.sendMessage(prefix + "§4Erreur: §c" + args[3] + " n'est pas un nombre");
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
sender.sendMessage(prefix+"§4Erreur: §cLe rôle que vous avez entré est incorrect");
|
sender.sendMessage(prefix + "§4Erreur: §cLe rôle que vous avez entré est incorrect");
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
sender.sendMessage(prefix+"§4Erreur: §cCommande incorrecte.");
|
sender.sendMessage(prefix + "§4Erreur: §cCommande incorrecte.");
|
||||||
sender.sendMessage(prefix+"§4Essayez §c/lg roles set <role_id/role_name> <nombre>§4 ou §c/lg roles list");
|
sender.sendMessage(prefix + "§4Essayez §c/lg roles set <role_id/role_name> <nombre>§4 ou §c/lg roles list");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
sender.sendMessage(prefix+"§4Erreur: §cCommande incorrecte.");
|
sender.sendMessage(prefix + "§4Erreur: §cCommande incorrecte.");
|
||||||
sender.sendMessage(prefix+"§4Essayez /lg §caddSpawn/end/start/nextNight/nextDay/reloadConfig/roles/reloadPacks/joinAll");
|
sender.sendMessage(prefix + "§4Essayez /lg §caddSpawn/end/start/nextNight/nextDay/reloadConfig/roles/reloadPacks/joinAll");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
||||||
if(!sender.hasPermission("loupgarou.admin"))
|
if (!sender.hasPermission("loupgarou.admin"))
|
||||||
return new ArrayList<>(0);
|
return new ArrayList<>(0);
|
||||||
|
|
||||||
if(args.length > 1) {
|
if (args.length > 1) {
|
||||||
if(args[0].equalsIgnoreCase("roles"))
|
if (args[0].equalsIgnoreCase("roles"))
|
||||||
if(args.length == 2)
|
if (args.length == 2)
|
||||||
return getStartingList(args[1], "list", "set");
|
return getStartingList(args[1], "list", "set");
|
||||||
else if(args.length == 3 && args[1].equalsIgnoreCase("set"))
|
else if (args.length == 3 && args[1].equalsIgnoreCase("set"))
|
||||||
return getStartingList(args[2], getRoles().keySet().toArray(new String[getRoles().size()]));
|
return getStartingList(args[2], getRoles().keySet().toArray(new String[getRoles().size()]));
|
||||||
else if(args.length == 4)
|
else if (args.length == 4)
|
||||||
return Arrays.asList("0", "1", "2", "3", "4", "5", "6", "7", "8", "9");
|
return Arrays.asList("0", "1", "2", "3", "4", "5", "6", "7", "8", "9");
|
||||||
}else if(args.length == 1)
|
} else if (args.length == 1)
|
||||||
return getStartingList(args[0], "addSpawn", "end", "start", "nextNight", "nextDay", "reloadConfig", "roles", "joinAll", "reloadPacks");
|
return getStartingList(args[0], "addSpawn", "end", "start", "nextNight", "nextDay", "reloadConfig", "roles", "joinAll", "reloadPacks");
|
||||||
return new ArrayList<>(0);
|
return new ArrayList<>(0);
|
||||||
}
|
}
|
||||||
private List<String> getStartingList(String startsWith, String... list){
|
|
||||||
|
private List<String> getStartingList(String startsWith, String... list) {
|
||||||
startsWith = startsWith.toLowerCase();
|
startsWith = startsWith.toLowerCase();
|
||||||
ArrayList<String> returnlist = new ArrayList<>();
|
ArrayList<String> returnlist = new ArrayList<>();
|
||||||
if(startsWith.length() == 0)
|
if (startsWith.length() == 0)
|
||||||
return Arrays.asList(list);
|
return Arrays.asList(list);
|
||||||
for(String s : list)
|
for (String s : list)
|
||||||
if(s.toLowerCase().startsWith(startsWith))
|
if (s.toLowerCase().startsWith(startsWith))
|
||||||
returnlist.add(s);
|
returnlist.add(s);
|
||||||
return returnlist;
|
return returnlist;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void loadConfig() {
|
public void loadConfig() {
|
||||||
int players = 0;
|
int players = 0;
|
||||||
for(String role : roles.keySet())
|
for (String role : roles.keySet())
|
||||||
players += getConfig().getInt("role."+role);
|
players += getConfig().getInt("role." + role);
|
||||||
currentGame = new LGGame(this, players);
|
currentGame = new LGGame(this, players);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDisable() {
|
public void onDisable() {
|
||||||
ProtocolLibrary.getProtocolManager().removePacketListeners(this);
|
ProtocolLibrary.getProtocolManager().removePacketListeners(this);
|
||||||
}
|
}
|
||||||
public static MainLg getInstance() {
|
|
||||||
return instance;
|
|
||||||
}
|
|
||||||
private void loadRoles() {
|
private void loadRoles() {
|
||||||
try {
|
try {
|
||||||
roles.put("LoupGarou", RLoupGarou.class.getConstructor(LGGame.class));
|
roles.put("LoupGarou", RLoupGarou.class.getConstructor(LGGame.class));
|
||||||
|
|
|
@ -6,8 +6,11 @@ import lombok.RequiredArgsConstructor;
|
||||||
|
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public class IndexedRole {
|
public class IndexedRole {
|
||||||
@Getter private final Role role;
|
@Getter
|
||||||
@Getter private int number = 1;
|
private final Role role;
|
||||||
|
@Getter
|
||||||
|
private int number = 1;
|
||||||
|
|
||||||
public void increase() {
|
public void increase() {
|
||||||
number++;
|
number++;
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -1,7 +1,6 @@
|
||||||
package fr.leomelki.loupgarou.classes;
|
package fr.leomelki.loupgarou.classes;
|
||||||
|
|
||||||
import com.comphenix.protocol.wrappers.WrappedSignedProperty;
|
import com.comphenix.protocol.wrappers.WrappedSignedProperty;
|
||||||
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
|
|
||||||
|
@ -10,5 +9,6 @@ public enum LGCustomSkin {
|
||||||
VILLAGER(new WrappedSignedProperty("textures", "eyJ0aW1lc3RhbXAiOjE1NzcwNTE5MDIyNDgsInByb2ZpbGVJZCI6Ijc4YWQzMjI2YmJkYTQwMGZiNTExMjAzMDY4MGNjN2I0IiwicHJvZmlsZU5hbWUiOiJTaHl0b29zIiwidGV4dHVyZXMiOnsiU0tJTiI6eyJ1cmwiOiJodHRwOi8vdGV4dHVyZXMubWluZWNyYWZ0Lm5ldC90ZXh0dXJlLzYxZmE3Y2UyYmQxMmJmMzBjOTcxZjUwZjJiMGIyYTZkZWUyOWU4MWM5MmJkZmFhZjFkMDJlNjM5YzJiZjMzNWEiLCJtZXRhZGF0YSI6eyJtb2RlbCI6InNsaW0ifX19fQ==", "Qk3Gh9IbVwqIvzv0t3vNrGhzW1ejvKls/7n1vqC7UozJYFotECsBla3DFrxrLvTVsCMAQ3cXGq9QjfFF1U/q0NYvWNXVPbrIxX6LH2t2SI9F1+WLQ7LGYwwABzMGDClJXkuUr0yEOPtCwoTgvinVkCZmNRrN0VDAwd+ie3LCnuBjo3iabjA4dxXLE59mnvCGKo5pGdqThn/KikUldvYGBjpQa+X5F+jQhj7TucZ8t0VJ2t05TkKHS+bcIcmCD+UorGG1N5uiNkQe89BMXZKQEebydtnH5RT8efqHfYT5aZY/6IJKTMqIeclcWy2f6LIfRb97AeifOPPHTfjl2Q6wjvOdnvGuNa+Xk6biNM7cLz1KQzdMM0CvkiZZ9XtFul5+PXEobx2IjIEcrStZX0fl/NZid+kf+2RXbPKx4Z+07q5PbeCzr1UD3DMWlrEMQQppIB26uhPLS9mh3IvM9bhx+vIbByr1Z5p3aT4J2mbhwwmf/LUpNUyMn6oHt19zX6cEcSbncGBLgEHOrUXgxdK/Sm4lJKA1Mr3M0o8CSt7ldLc6mA4oBPMK/OV/c0rwb1W2GWOUyw99dNT/jFSFXyyjCHW0+5FkAW+H+8Y0dZ3U4UWaAmX4JNfdxiih97eTBKEvIC8V48hiFS/UV9A9LBVPNkca/4lanh/jNZ7VRQ+/vU8=")),
|
VILLAGER(new WrappedSignedProperty("textures", "eyJ0aW1lc3RhbXAiOjE1NzcwNTE5MDIyNDgsInByb2ZpbGVJZCI6Ijc4YWQzMjI2YmJkYTQwMGZiNTExMjAzMDY4MGNjN2I0IiwicHJvZmlsZU5hbWUiOiJTaHl0b29zIiwidGV4dHVyZXMiOnsiU0tJTiI6eyJ1cmwiOiJodHRwOi8vdGV4dHVyZXMubWluZWNyYWZ0Lm5ldC90ZXh0dXJlLzYxZmE3Y2UyYmQxMmJmMzBjOTcxZjUwZjJiMGIyYTZkZWUyOWU4MWM5MmJkZmFhZjFkMDJlNjM5YzJiZjMzNWEiLCJtZXRhZGF0YSI6eyJtb2RlbCI6InNsaW0ifX19fQ==", "Qk3Gh9IbVwqIvzv0t3vNrGhzW1ejvKls/7n1vqC7UozJYFotECsBla3DFrxrLvTVsCMAQ3cXGq9QjfFF1U/q0NYvWNXVPbrIxX6LH2t2SI9F1+WLQ7LGYwwABzMGDClJXkuUr0yEOPtCwoTgvinVkCZmNRrN0VDAwd+ie3LCnuBjo3iabjA4dxXLE59mnvCGKo5pGdqThn/KikUldvYGBjpQa+X5F+jQhj7TucZ8t0VJ2t05TkKHS+bcIcmCD+UorGG1N5uiNkQe89BMXZKQEebydtnH5RT8efqHfYT5aZY/6IJKTMqIeclcWy2f6LIfRb97AeifOPPHTfjl2Q6wjvOdnvGuNa+Xk6biNM7cLz1KQzdMM0CvkiZZ9XtFul5+PXEobx2IjIEcrStZX0fl/NZid+kf+2RXbPKx4Z+07q5PbeCzr1UD3DMWlrEMQQppIB26uhPLS9mh3IvM9bhx+vIbByr1Z5p3aT4J2mbhwwmf/LUpNUyMn6oHt19zX6cEcSbncGBLgEHOrUXgxdK/Sm4lJKA1Mr3M0o8CSt7ldLc6mA4oBPMK/OV/c0rwb1W2GWOUyw99dNT/jFSFXyyjCHW0+5FkAW+H+8Y0dZ3U4UWaAmX4JNfdxiih97eTBKEvIC8V48hiFS/UV9A9LBVPNkca/4lanh/jNZ7VRQ+/vU8=")),
|
||||||
MAYOR(new WrappedSignedProperty("textures", "eyJ0aW1lc3RhbXAiOjE1NzcwNTE4NjcxMDcsInByb2ZpbGVJZCI6Ijc4YWQzMjI2YmJkYTQwMGZiNTExMjAzMDY4MGNjN2I0IiwicHJvZmlsZU5hbWUiOiJTaHl0b29zIiwidGV4dHVyZXMiOnsiU0tJTiI6eyJ1cmwiOiJodHRwOi8vdGV4dHVyZXMubWluZWNyYWZ0Lm5ldC90ZXh0dXJlLzUzYTk5NjljMjU0YWRkYmZkNjdmNDJlZmMxODNkZDg5ZWE3ZTliOGE4NDY2YWNkOWZhMWZmMTYzMTQ0MTczMDMifX19", "fq/bN78Y70k2clbfg6sLRuj4mhvDTz58fKI3/0XvzJH/bQF5Mf+jcFwpXJN+ZiupMaHFHI1bBQ20lrzlGvtrCoYu9+Bx4otin0NQVxc3pOEewikzYub64niMPq8irGJrS2pB1B2Uym5F+/wX8TXOkySyAo1r3lzh6qmfe1bpNG7gcc9+ulYdAbnyhxTko3d8poBsjLnadpo0/rBNMkNIua9ryIE3WHW+DOxLwpLpd3TAB15RnA3/qvyBlqQBny1M24ccjmzxjiUbzF66EtTC+BRs3eS8or/vxvdmi70e295gMoERZJ5pFukxe9LB0IEg9cLHwuEl7OC8FcuLUQFnm1EVPjfSlSF36Sd+iVwjFE/x1zINKYsDHwF/TM+yAWOv+PwgGxgQj1C97VaWEkrHXDMEzgxi8DAcPbDBwcyBZXRgOJTHRSH2ATvGDqeT7iQbPrP+y0YNFUDXyBrKYgscgA7bMtBgWvW75SdvcIhqQEVe/jMivMWDuvwhQF4lUGonHc0B5wi1216fqTypEcOeaa5ab+siNssFXpEsaFP9l+1o6uYjNbBpptEAsIlKbnjDaVSkCTvsW7ICaPAZcZCavpyST5MYTv6C7n/bwl3nfzzI7U1LYvYi/gMEHKWfNwLs4T+4VQ3xZD0DpkEQgDrax+Wt182K6OvrAcOcCAfWySo=\",\"name")),
|
MAYOR(new WrappedSignedProperty("textures", "eyJ0aW1lc3RhbXAiOjE1NzcwNTE4NjcxMDcsInByb2ZpbGVJZCI6Ijc4YWQzMjI2YmJkYTQwMGZiNTExMjAzMDY4MGNjN2I0IiwicHJvZmlsZU5hbWUiOiJTaHl0b29zIiwidGV4dHVyZXMiOnsiU0tJTiI6eyJ1cmwiOiJodHRwOi8vdGV4dHVyZXMubWluZWNyYWZ0Lm5ldC90ZXh0dXJlLzUzYTk5NjljMjU0YWRkYmZkNjdmNDJlZmMxODNkZDg5ZWE3ZTliOGE4NDY2YWNkOWZhMWZmMTYzMTQ0MTczMDMifX19", "fq/bN78Y70k2clbfg6sLRuj4mhvDTz58fKI3/0XvzJH/bQF5Mf+jcFwpXJN+ZiupMaHFHI1bBQ20lrzlGvtrCoYu9+Bx4otin0NQVxc3pOEewikzYub64niMPq8irGJrS2pB1B2Uym5F+/wX8TXOkySyAo1r3lzh6qmfe1bpNG7gcc9+ulYdAbnyhxTko3d8poBsjLnadpo0/rBNMkNIua9ryIE3WHW+DOxLwpLpd3TAB15RnA3/qvyBlqQBny1M24ccjmzxjiUbzF66EtTC+BRs3eS8or/vxvdmi70e295gMoERZJ5pFukxe9LB0IEg9cLHwuEl7OC8FcuLUQFnm1EVPjfSlSF36Sd+iVwjFE/x1zINKYsDHwF/TM+yAWOv+PwgGxgQj1C97VaWEkrHXDMEzgxi8DAcPbDBwcyBZXRgOJTHRSH2ATvGDqeT7iQbPrP+y0YNFUDXyBrKYgscgA7bMtBgWvW75SdvcIhqQEVe/jMivMWDuvwhQF4lUGonHc0B5wi1216fqTypEcOeaa5ab+siNssFXpEsaFP9l+1o6uYjNbBpptEAsIlKbnjDaVSkCTvsW7ICaPAZcZCavpyST5MYTv6C7n/bwl3nfzzI7U1LYvYi/gMEHKWfNwLs4T+4VQ3xZD0DpkEQgDrax+Wt182K6OvrAcOcCAfWySo=\",\"name")),
|
||||||
WEREWOLF(new WrappedSignedProperty("textures", "eyJ0aW1lc3RhbXAiOjE1NzcwNTE3NTU1NDgsInByb2ZpbGVJZCI6Ijc4YWQzMjI2YmJkYTQwMGZiNTExMjAzMDY4MGNjN2I0IiwicHJvZmlsZU5hbWUiOiJTaHl0b29zIiwidGV4dHVyZXMiOnsiU0tJTiI6eyJ1cmwiOiJodHRwOi8vdGV4dHVyZXMubWluZWNyYWZ0Lm5ldC90ZXh0dXJlL2U1NGE2MmRhNGMzZTI5YjdiZWM4ZTI0YzhiNTAyZGZjNWNmMTNmYjc0NjFhN2I5YWY2NGY2Yjc1ZGFhNmE2MDUifX19", "k0cT/rDkBW3QMqSavKc0Nbu39ft3i0TLLhxLht7LKKuA+Q+amCmzw/NZjZRtJc/R87uyl2B+JHLTWTOcbDQX2bE7fIzEvYFhvbb2dasxeYA03wBwZ+OuJlhhxWSSX2NoAI6gEGcWQ3k4xcf+xhtD+5eddjL5k+Dv/kVW6qCWprfPSmd4+KQ0aVwyBkbheyTBSaamtpPj24UYM1EL9POF/PrbmiipfSthp7DkwL4PprW+0Z3pzFMgY46Ay2VJYxa+Q6q3IlYqSXMkjJccf3msyOTGe3JSiQc1Du/djffvLIoyjybolNb5rQ/OrnYIEtnqCuXstJJd3J+a6F8w4DkS2ZMVY4lvidb4coVeFmm9Nk/afqqyG99TDmvZNFWFSeaaxGSWeZPkneAEFuFQXn76sl1xdtXkgXmP8H0yvs9SwA9UnGoldIay6D1HzAOGo3n3stV6188K0ucey1KsH6nNlZfT2hnqvI1lfKD67oQNFfl4kDLRwArfZJUmcQOJh9/fk6/bJvgYuElEkGy++0FkuKKkRJHPIW5+kPZguNo96cAAGxhSH3IIscLoxDdn53iSnngpKttWfG6ccI/XMGTWp4wCq6IC2IBZcmKEqK+fN5dVbR4tn79pXlQ2Yyk7kvXaZjdVHrKC1Buw1gjjC1EvmiJjTRZVHPYlCTkfy+hdqzE="));
|
WEREWOLF(new WrappedSignedProperty("textures", "eyJ0aW1lc3RhbXAiOjE1NzcwNTE3NTU1NDgsInByb2ZpbGVJZCI6Ijc4YWQzMjI2YmJkYTQwMGZiNTExMjAzMDY4MGNjN2I0IiwicHJvZmlsZU5hbWUiOiJTaHl0b29zIiwidGV4dHVyZXMiOnsiU0tJTiI6eyJ1cmwiOiJodHRwOi8vdGV4dHVyZXMubWluZWNyYWZ0Lm5ldC90ZXh0dXJlL2U1NGE2MmRhNGMzZTI5YjdiZWM4ZTI0YzhiNTAyZGZjNWNmMTNmYjc0NjFhN2I5YWY2NGY2Yjc1ZGFhNmE2MDUifX19", "k0cT/rDkBW3QMqSavKc0Nbu39ft3i0TLLhxLht7LKKuA+Q+amCmzw/NZjZRtJc/R87uyl2B+JHLTWTOcbDQX2bE7fIzEvYFhvbb2dasxeYA03wBwZ+OuJlhhxWSSX2NoAI6gEGcWQ3k4xcf+xhtD+5eddjL5k+Dv/kVW6qCWprfPSmd4+KQ0aVwyBkbheyTBSaamtpPj24UYM1EL9POF/PrbmiipfSthp7DkwL4PprW+0Z3pzFMgY46Ay2VJYxa+Q6q3IlYqSXMkjJccf3msyOTGe3JSiQc1Du/djffvLIoyjybolNb5rQ/OrnYIEtnqCuXstJJd3J+a6F8w4DkS2ZMVY4lvidb4coVeFmm9Nk/afqqyG99TDmvZNFWFSeaaxGSWeZPkneAEFuFQXn76sl1xdtXkgXmP8H0yvs9SwA9UnGoldIay6D1HzAOGo3n3stV6188K0ucey1KsH6nNlZfT2hnqvI1lfKD67oQNFfl4kDLRwArfZJUmcQOJh9/fk6/bJvgYuElEkGy++0FkuKKkRJHPIW5+kPZguNo96cAAGxhSH3IIscLoxDdn53iSnngpKttWfG6ccI/XMGTWp4wCq6IC2IBZcmKEqK+fN5dVbR4tn79pXlQ2Yyk7kvXaZjdVHrKC1Buw1gjjC1EvmiJjTRZVHPYlCTkfy+hdqzE="));
|
||||||
@Getter private final WrappedSignedProperty property;
|
@Getter
|
||||||
|
private final WrappedSignedProperty property;
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,22 +1,11 @@
|
||||||
package fr.leomelki.loupgarou.classes;
|
package fr.leomelki.loupgarou.classes;
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
import org.bukkit.GameMode;
|
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.craftbukkit.v1_15_R1.entity.CraftPlayer;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.potion.PotionEffect;
|
|
||||||
import org.bukkit.potion.PotionEffectType;
|
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
|
||||||
|
|
||||||
import com.comphenix.protocol.wrappers.EnumWrappers.NativeGameMode;
|
import com.comphenix.protocol.wrappers.EnumWrappers.NativeGameMode;
|
||||||
import com.comphenix.protocol.wrappers.EnumWrappers.PlayerInfoAction;
|
import com.comphenix.protocol.wrappers.EnumWrappers.PlayerInfoAction;
|
||||||
import com.comphenix.protocol.wrappers.EnumWrappers.TitleAction;
|
import com.comphenix.protocol.wrappers.EnumWrappers.TitleAction;
|
||||||
import com.comphenix.protocol.wrappers.PlayerInfoData;
|
import com.comphenix.protocol.wrappers.PlayerInfoData;
|
||||||
import com.comphenix.protocol.wrappers.WrappedChatComponent;
|
import com.comphenix.protocol.wrappers.WrappedChatComponent;
|
||||||
import com.comphenix.protocol.wrappers.WrappedGameProfile;
|
import com.comphenix.protocol.wrappers.WrappedGameProfile;
|
||||||
|
|
||||||
import fr.leomelki.com.comphenix.packetwrapper.WrapperPlayServerChat;
|
import fr.leomelki.com.comphenix.packetwrapper.WrapperPlayServerChat;
|
||||||
import fr.leomelki.com.comphenix.packetwrapper.WrapperPlayServerPlayerInfo;
|
import fr.leomelki.com.comphenix.packetwrapper.WrapperPlayServerPlayerInfo;
|
||||||
import fr.leomelki.com.comphenix.packetwrapper.WrapperPlayServerScoreboardTeam;
|
import fr.leomelki.com.comphenix.packetwrapper.WrapperPlayServerScoreboardTeam;
|
||||||
|
@ -37,67 +26,101 @@ import net.minecraft.server.v1_15_R1.DimensionManager;
|
||||||
import net.minecraft.server.v1_15_R1.EnumGamemode;
|
import net.minecraft.server.v1_15_R1.EnumGamemode;
|
||||||
import net.minecraft.server.v1_15_R1.PacketPlayOutRespawn;
|
import net.minecraft.server.v1_15_R1.PacketPlayOutRespawn;
|
||||||
import net.minecraft.server.v1_15_R1.WorldType;
|
import net.minecraft.server.v1_15_R1.WorldType;
|
||||||
|
import org.bukkit.GameMode;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.craftbukkit.v1_15_R1.entity.CraftPlayer;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.potion.PotionEffect;
|
||||||
|
import org.bukkit.potion.PotionEffectType;
|
||||||
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
public class LGPlayer {
|
public class LGPlayer {
|
||||||
private static final HashMap<Player, LGPlayer> cachedPlayers = new HashMap<>();
|
private static final HashMap<Player, LGPlayer> cachedPlayers = new HashMap<>();
|
||||||
private final MainLg plugin;
|
private final MainLg plugin;
|
||||||
|
@Getter
|
||||||
public static LGPlayer thePlayer(MainLg plugin, Player player) {
|
private final VariableCache cache = new VariableCache();
|
||||||
LGPlayer lgp = cachedPlayers.get(player);
|
public boolean canSelectDead;
|
||||||
if(lgp == null) {
|
@Getter
|
||||||
lgp = new LGPlayer(plugin, player);
|
boolean muted;
|
||||||
cachedPlayers.put(player, lgp);
|
long lastChoose;
|
||||||
}
|
@Getter
|
||||||
return lgp;
|
@Setter
|
||||||
}
|
private int place;
|
||||||
public static LGPlayer removePlayer(Player player) {
|
@Getter
|
||||||
return cachedPlayers.remove(player);//.remove();
|
private Player player;
|
||||||
}
|
@Getter
|
||||||
@Getter @Setter private int place;
|
@Setter
|
||||||
@Getter private Player player;
|
private boolean dead;
|
||||||
@Getter @Setter private boolean dead;
|
@Setter
|
||||||
@Setter @Getter private Role role;
|
@Getter
|
||||||
|
private Role role;
|
||||||
private LGChooseCallback chooseCallback;
|
private LGChooseCallback chooseCallback;
|
||||||
private List<LGPlayer> blacklistedChoice = new ArrayList<>(0);
|
private List<LGPlayer> blacklistedChoice = new ArrayList<>(0);
|
||||||
@Getter private final VariableCache cache = new VariableCache();
|
@Getter
|
||||||
@Getter @Setter private LGGame game;
|
@Setter
|
||||||
@Getter @Setter private String latestObjective;
|
private LGGame game;
|
||||||
@Getter private CustomScoreboard scoreboard;
|
@Getter
|
||||||
|
@Setter
|
||||||
|
private String latestObjective;
|
||||||
|
@Getter
|
||||||
|
private CustomScoreboard scoreboard;
|
||||||
|
private String name;
|
||||||
|
@Getter
|
||||||
|
private LGChat chat;
|
||||||
|
|
||||||
public LGPlayer(MainLg mainLg, Player player) {
|
public LGPlayer(MainLg mainLg, Player player) {
|
||||||
this.plugin = mainLg;
|
this.plugin = mainLg;
|
||||||
this.player = player;
|
this.player = player;
|
||||||
}
|
}
|
||||||
|
|
||||||
public LGPlayer(MainLg mainLg, String name) {
|
public LGPlayer(MainLg mainLg, String name) {
|
||||||
this.plugin = mainLg;
|
this.plugin = mainLg;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static LGPlayer thePlayer(MainLg plugin, Player player) {
|
||||||
|
LGPlayer lgp = cachedPlayers.get(player);
|
||||||
|
if (lgp == null) {
|
||||||
|
lgp = new LGPlayer(plugin, player);
|
||||||
|
cachedPlayers.put(player, lgp);
|
||||||
|
}
|
||||||
|
return lgp;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static LGPlayer removePlayer(Player player) {
|
||||||
|
return cachedPlayers.remove(player);//.remove();
|
||||||
|
}
|
||||||
|
|
||||||
public void setScoreboard(CustomScoreboard scoreboard) {
|
public void setScoreboard(CustomScoreboard scoreboard) {
|
||||||
if(player != null) {
|
if (player != null) {
|
||||||
if(this.scoreboard != null)
|
if (this.scoreboard != null)
|
||||||
this.scoreboard.hide();
|
this.scoreboard.hide();
|
||||||
|
|
||||||
this.scoreboard = scoreboard;
|
this.scoreboard = scoreboard;
|
||||||
|
|
||||||
if(scoreboard != null)
|
if (scoreboard != null)
|
||||||
scoreboard.show();
|
scoreboard.show();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sendActionBarMessage(String msg) {
|
public void sendActionBarMessage(String msg) {
|
||||||
if(this.player != null) {
|
if (this.player != null) {
|
||||||
WrapperPlayServerChat chat = new WrapperPlayServerChat();
|
WrapperPlayServerChat chat = new WrapperPlayServerChat();
|
||||||
chat.setPosition((byte)2);
|
chat.setPosition((byte) 2);
|
||||||
chat.setMessage(WrappedChatComponent.fromText(msg));
|
chat.setMessage(WrappedChatComponent.fromText(msg));
|
||||||
chat.sendPacket(getPlayer());
|
chat.sendPacket(getPlayer());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sendMessage(String msg) {
|
public void sendMessage(String msg) {
|
||||||
if(this.player != null)
|
if (this.player != null)
|
||||||
getPlayer().sendMessage(MainLg.getPrefix()+msg);
|
getPlayer().sendMessage(MainLg.getPrefix() + msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sendTitle(String title, String subTitle, int stay) {
|
public void sendTitle(String title, String subTitle, int stay) {
|
||||||
if(this.player != null) {
|
if (this.player != null) {
|
||||||
WrapperPlayServerTitle titlePacket = new WrapperPlayServerTitle();
|
WrapperPlayServerTitle titlePacket = new WrapperPlayServerTitle();
|
||||||
titlePacket.setAction(TitleAction.TIMES);
|
titlePacket.setAction(TitleAction.TIMES);
|
||||||
titlePacket.setFadeIn(10);
|
titlePacket.setFadeIn(10);
|
||||||
|
@ -116,21 +139,21 @@ public class LGPlayer {
|
||||||
titlePacket.sendPacket(player);
|
titlePacket.sendPacket(player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void remove() {
|
public void remove() {
|
||||||
this.player = null;
|
this.player = null;
|
||||||
}
|
}
|
||||||
private String name;
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return player != null ? getPlayer().getName() : name;
|
return player != null ? getPlayer().getName() : name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public boolean join(LGGame game) {
|
public boolean join(LGGame game) {
|
||||||
if(getPlayer().getGameMode() == GameMode.SPECTATOR) {
|
if (getPlayer().getGameMode() == GameMode.SPECTATOR) {
|
||||||
sendMessage("§cÉtant en mode spectateur, vous ne rejoignez pas la partie !");
|
sendMessage("§cÉtant en mode spectateur, vous ne rejoignez pas la partie !");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if(game.tryToJoin(this)) {
|
if (game.tryToJoin(this)) {
|
||||||
//To update the skin
|
//To update the skin
|
||||||
updateOwnSkin();
|
updateOwnSkin();
|
||||||
getPlayer().setWalkSpeed(0.2f);
|
getPlayer().setWalkSpeed(0.2f);
|
||||||
|
@ -139,27 +162,25 @@ public class LGPlayer {
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void choose(LGChooseCallback callback, LGPlayer... blacklisted) {
|
public void choose(LGChooseCallback callback, LGPlayer... blacklisted) {
|
||||||
this.blacklistedChoice = blacklisted == null ? new ArrayList<>(0) : Arrays.asList(blacklisted);
|
this.blacklistedChoice = blacklisted == null ? new ArrayList<>(0) : Arrays.asList(blacklisted);
|
||||||
this.chooseCallback = callback;
|
this.chooseCallback = callback;
|
||||||
//sendMessage("§7§oTIP: Regardez un joueur et tapez le afin de le sélectionner.");
|
//sendMessage("§7§oTIP: Regardez un joueur et tapez le afin de le sélectionner.");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void stopChoosing() {
|
public void stopChoosing() {
|
||||||
this.blacklistedChoice = null;
|
this.blacklistedChoice = null;
|
||||||
this.chooseCallback = null;
|
this.chooseCallback = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface LGChooseCallback{
|
|
||||||
void callback(LGPlayer choosen);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void showView() {
|
public void showView() {
|
||||||
if(getGame() != null && player != null)
|
if (getGame() != null && player != null)
|
||||||
for(LGPlayer lgp : getGame().getAlive())
|
for (LGPlayer lgp : getGame().getAlive())
|
||||||
if(!lgp.isDead()) {
|
if (!lgp.isDead()) {
|
||||||
if(lgp != this && lgp.getPlayer() != null)
|
if (lgp != this && lgp.getPlayer() != null)
|
||||||
getPlayer().showPlayer(plugin, lgp.getPlayer());
|
getPlayer().showPlayer(plugin, lgp.getPlayer());
|
||||||
else{
|
else {
|
||||||
WrapperPlayServerScoreboardTeam team = new WrapperPlayServerScoreboardTeam();
|
WrapperPlayServerScoreboardTeam team = new WrapperPlayServerScoreboardTeam();
|
||||||
team.setMode(2);
|
team.setMode(2);
|
||||||
team.setName(lgp.getName());
|
team.setName(lgp.getName());
|
||||||
|
@ -182,9 +203,9 @@ public class LGPlayer {
|
||||||
|
|
||||||
//TODO Update prefix for only one guy
|
//TODO Update prefix for only one guy
|
||||||
public void updatePrefix() {
|
public void updatePrefix() {
|
||||||
if(getGame() != null && !isDead() && player != null) {
|
if (getGame() != null && !isDead() && player != null) {
|
||||||
List<String> meList = Collections.singletonList(getName());
|
List<String> meList = Collections.singletonList(getName());
|
||||||
for(LGPlayer lgp : getGame().getInGame()) {
|
for (LGPlayer lgp : getGame().getInGame()) {
|
||||||
WrapperPlayServerPlayerInfo info = new WrapperPlayServerPlayerInfo();
|
WrapperPlayServerPlayerInfo info = new WrapperPlayServerPlayerInfo();
|
||||||
ArrayList<PlayerInfoData> infos = new ArrayList<>();
|
ArrayList<PlayerInfoData> infos = new ArrayList<>();
|
||||||
info.setAction(PlayerInfoAction.ADD_PLAYER);
|
info.setAction(PlayerInfoAction.ADD_PLAYER);
|
||||||
|
@ -201,14 +222,15 @@ public class LGPlayer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void hideView() {
|
public void hideView() {
|
||||||
if(getGame() != null && player != null) {
|
if (getGame() != null && player != null) {
|
||||||
WrapperPlayServerPlayerInfo info = new WrapperPlayServerPlayerInfo();
|
WrapperPlayServerPlayerInfo info = new WrapperPlayServerPlayerInfo();
|
||||||
ArrayList<PlayerInfoData> infos = new ArrayList<>();
|
ArrayList<PlayerInfoData> infos = new ArrayList<>();
|
||||||
info.setAction(PlayerInfoAction.ADD_PLAYER);
|
info.setAction(PlayerInfoAction.ADD_PLAYER);
|
||||||
for(LGPlayer lgp : getGame().getAlive())
|
for (LGPlayer lgp : getGame().getAlive())
|
||||||
if(lgp != this && lgp.getPlayer() != null) {
|
if (lgp != this && lgp.getPlayer() != null) {
|
||||||
if(!lgp.isDead())
|
if (!lgp.isDead())
|
||||||
infos.add(new PlayerInfoData(new WrappedGameProfile(lgp.getPlayer().getUniqueId(), lgp.getName()), 0, NativeGameMode.ADVENTURE, WrappedChatComponent.fromText(lgp.getName())));
|
infos.add(new PlayerInfoData(new WrappedGameProfile(lgp.getPlayer().getUniqueId(), lgp.getName()), 0, NativeGameMode.ADVENTURE, WrappedChatComponent.fromText(lgp.getName())));
|
||||||
getPlayer().hidePlayer(plugin, lgp.getPlayer());
|
getPlayer().hidePlayer(plugin, lgp.getPlayer());
|
||||||
}
|
}
|
||||||
|
@ -221,24 +243,25 @@ public class LGPlayer {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateSkin() {
|
public void updateSkin() {
|
||||||
if(getGame() != null && player != null) {
|
if (getGame() != null && player != null) {
|
||||||
for(LGPlayer lgp : getGame().getInGame()) {
|
for (LGPlayer lgp : getGame().getInGame()) {
|
||||||
if(lgp == this) {
|
if (lgp == this) {
|
||||||
WrapperPlayServerPlayerInfo info = new WrapperPlayServerPlayerInfo();
|
WrapperPlayServerPlayerInfo info = new WrapperPlayServerPlayerInfo();
|
||||||
ArrayList<PlayerInfoData> infos = new ArrayList<>();
|
ArrayList<PlayerInfoData> infos = new ArrayList<>();
|
||||||
info.setAction(PlayerInfoAction.ADD_PLAYER);
|
info.setAction(PlayerInfoAction.ADD_PLAYER);
|
||||||
infos.add(new PlayerInfoData(new WrappedGameProfile(getPlayer().getUniqueId(), getName()), 0, NativeGameMode.ADVENTURE, WrappedChatComponent.fromText(getName())));
|
infos.add(new PlayerInfoData(new WrappedGameProfile(getPlayer().getUniqueId(), getName()), 0, NativeGameMode.ADVENTURE, WrappedChatComponent.fromText(getName())));
|
||||||
info.setData(infos);
|
info.setData(infos);
|
||||||
info.sendPacket(getPlayer());
|
info.sendPacket(getPlayer());
|
||||||
}else if(!isDead() && lgp.getPlayer() != null){
|
} else if (!isDead() && lgp.getPlayer() != null) {
|
||||||
lgp.getPlayer().hidePlayer(plugin, getPlayer());
|
lgp.getPlayer().hidePlayer(plugin, getPlayer());
|
||||||
lgp.getPlayer().showPlayer(plugin, getPlayer());
|
lgp.getPlayer().showPlayer(plugin, getPlayer());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateOwnSkin() {
|
public void updateOwnSkin() {
|
||||||
if(player != null) {
|
if (player != null) {
|
||||||
//On change son skin avec un packet de PlayerInfo (dans le tab)
|
//On change son skin avec un packet de PlayerInfo (dans le tab)
|
||||||
WrapperPlayServerPlayerInfo infos = new WrapperPlayServerPlayerInfo();
|
WrapperPlayServerPlayerInfo infos = new WrapperPlayServerPlayerInfo();
|
||||||
infos.setAction(PlayerInfoAction.ADD_PLAYER);
|
infos.setAction(PlayerInfoAction.ADD_PLAYER);
|
||||||
|
@ -247,7 +270,7 @@ public class LGPlayer {
|
||||||
infos.sendPacket(getPlayer());
|
infos.sendPacket(getPlayer());
|
||||||
//Pour qu'il voit son skin changer (sa main et en f5), on lui dit qu'il respawn (alors qu'il n'est pas mort mais ça marche quand même mdr)
|
//Pour qu'il voit son skin changer (sa main et en f5), on lui dit qu'il respawn (alors qu'il n'est pas mort mais ça marche quand même mdr)
|
||||||
PacketPlayOutRespawn respawn = new PacketPlayOutRespawn(DimensionManager.OVERWORLD, 0, WorldType.NORMAL, EnumGamemode.ADVENTURE);
|
PacketPlayOutRespawn respawn = new PacketPlayOutRespawn(DimensionManager.OVERWORLD, 0, WorldType.NORMAL, EnumGamemode.ADVENTURE);
|
||||||
((CraftPlayer)getPlayer()).getHandle().playerConnection.sendPacket(respawn);
|
((CraftPlayer) getPlayer()).getHandle().playerConnection.sendPacket(respawn);
|
||||||
//Enfin, on le téléporte à sa potion actuelle car sinon il se verra dans le vide
|
//Enfin, on le téléporte à sa potion actuelle car sinon il se verra dans le vide
|
||||||
getPlayer().teleport(getPlayer().getLocation());
|
getPlayer().teleport(getPlayer().getLocation());
|
||||||
float speed = getPlayer().getWalkSpeed();
|
float speed = getPlayer().getWalkSpeed();
|
||||||
|
@ -263,18 +286,18 @@ public class LGPlayer {
|
||||||
//Et c'est bon, le joueur se voit avec un nouveau skin avec quasiment aucun problème visible à l'écran :D
|
//Et c'est bon, le joueur se voit avec un nouveau skin avec quasiment aucun problème visible à l'écran :D
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public boolean canSelectDead;
|
|
||||||
public LGPlayer getPlayerOnCursor(List<LGPlayer> list) {
|
public LGPlayer getPlayerOnCursor(List<LGPlayer> list) {
|
||||||
Location loc = getPlayer().getLocation();
|
Location loc = getPlayer().getLocation();
|
||||||
if(loc.getPitch() > 60)
|
if (loc.getPitch() > 60)
|
||||||
if(blacklistedChoice.contains(this))
|
if (blacklistedChoice.contains(this))
|
||||||
return null;
|
return null;
|
||||||
else
|
else
|
||||||
return this;
|
return this;
|
||||||
for(int i = 0;i<50;i++) {
|
for (int i = 0; i < 50; i++) {
|
||||||
loc.add(loc.getDirection());
|
loc.add(loc.getDirection());
|
||||||
for(LGPlayer player : list) {
|
for (LGPlayer player : list) {
|
||||||
if(player != this && !blacklistedChoice.contains(player) && (!player.isDead() || canSelectDead) && VariousUtils.distanceSquaredXZ(loc, player.getPlayer().getLocation()) < 0.35 && Math.abs(loc.getY()-player.getPlayer().getLocation().getY()) < 2) {
|
if (player != this && !blacklistedChoice.contains(player) && (!player.isDead() || canSelectDead) && VariousUtils.distanceSquaredXZ(loc, player.getPlayer().getLocation()) < 0.35 && Math.abs(loc.getY() - player.getPlayer().getLocation().getY()) < 2) {
|
||||||
return player;
|
return player;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -285,6 +308,7 @@ public class LGPlayer {
|
||||||
public RoleType getRoleType() {
|
public RoleType getRoleType() {
|
||||||
return this.getCache().getBoolean("vampire") ? RoleType.VAMPIRE : this.getCache().getBoolean("infected") ? RoleType.LOUP_GAROU : getRole().getType(this);
|
return this.getCache().getBoolean("vampire") ? RoleType.VAMPIRE : this.getCache().getBoolean("infected") ? RoleType.LOUP_GAROU : getRole().getType(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public RoleWinType getRoleWinType() {
|
public RoleWinType getRoleWinType() {
|
||||||
return this.getCache().getBoolean("vampire") ? RoleWinType.VAMPIRE : this.getCache().getBoolean("infected") ? RoleWinType.LOUP_GAROU : getRole().getWinType(this);
|
return this.getCache().getBoolean("vampire") ? RoleWinType.VAMPIRE : this.getCache().getBoolean("infected") ? RoleWinType.LOUP_GAROU : getRole().getWinType(this);
|
||||||
}
|
}
|
||||||
|
@ -293,44 +317,42 @@ public class LGPlayer {
|
||||||
return !this.getCache().getBoolean("vampire");
|
return !this.getCache().getBoolean("vampire");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Getter
|
|
||||||
boolean muted;
|
|
||||||
|
|
||||||
public void die() {
|
public void die() {
|
||||||
setMuted();
|
setMuted();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void setMuted() {
|
private void setMuted() {
|
||||||
if(player != null)
|
if (player != null)
|
||||||
for(LGPlayer lgp : getGame().getInGame())
|
for (LGPlayer lgp : getGame().getInGame())
|
||||||
if(lgp != this && lgp.getPlayer() != null)
|
if (lgp != this && lgp.getPlayer() != null)
|
||||||
lgp.getPlayer().hidePlayer(plugin, getPlayer());
|
lgp.getPlayer().hidePlayer(plugin, getPlayer());
|
||||||
muted = true;
|
muted = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void resetMuted() {
|
public void resetMuted() {
|
||||||
muted = false;
|
muted = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Getter private LGChat chat;
|
|
||||||
|
|
||||||
public void joinChat(LGChat chat, LGChatCallback callback) {
|
public void joinChat(LGChat chat, LGChatCallback callback) {
|
||||||
joinChat(chat, callback, false);
|
joinChat(chat, callback, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void joinChat(LGChat chat) {
|
public void joinChat(LGChat chat) {
|
||||||
joinChat(chat, null, false);
|
joinChat(chat, null, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void joinChat(LGChat chat, boolean muted) {
|
public void joinChat(LGChat chat, boolean muted) {
|
||||||
joinChat(chat, null, muted);
|
joinChat(chat, null, muted);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void joinChat(LGChat chat, LGChatCallback callback, boolean muted) {
|
public void joinChat(LGChat chat, LGChatCallback callback, boolean muted) {
|
||||||
if(this.chat != null && !muted)
|
if (this.chat != null && !muted)
|
||||||
this.chat.leave(this);
|
this.chat.leave(this);
|
||||||
|
|
||||||
if(!muted)
|
if (!muted)
|
||||||
this.chat = chat;
|
this.chat = chat;
|
||||||
|
|
||||||
if(chat != null && player != null)
|
if (chat != null && player != null)
|
||||||
chat.join(this, callback == null ? chat.getDefaultCallback() : callback);
|
chat.join(this, callback == null ? chat.getDefaultCallback() : callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -340,26 +362,26 @@ public class LGPlayer {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onChat(String message) {
|
public void onChat(String message) {
|
||||||
if(chat != null) {
|
if (chat != null) {
|
||||||
chat.sendMessage(this, message);
|
chat.sendMessage(this, message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void playAudio(LGSound sound, double volume) {
|
public void playAudio(LGSound sound, double volume) {
|
||||||
if(player != null)
|
if (player != null)
|
||||||
getPlayer().playSound(getPlayer().getLocation(), sound.getSound(), (float)volume, 1);
|
getPlayer().playSound(getPlayer().getLocation(), sound.getSound(), (float) volume, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void stopAudio(LGSound sound) {
|
public void stopAudio(LGSound sound) {
|
||||||
if(player != null)
|
if (player != null)
|
||||||
getPlayer().stopSound(sound.getSound());
|
getPlayer().stopSound(sound.getSound());
|
||||||
}
|
}
|
||||||
|
|
||||||
long lastChoose;
|
|
||||||
public void chooseAction() {
|
public void chooseAction() {
|
||||||
long now = System.currentTimeMillis();
|
long now = System.currentTimeMillis();
|
||||||
if(lastChoose+200 < now) {
|
if (lastChoose + 200 < now) {
|
||||||
if(chooseCallback != null)
|
if (chooseCallback != null)
|
||||||
chooseCallback.callback(getPlayerOnCursor(getGame().getInGame()));
|
chooseCallback.callback(getPlayerOnCursor(getGame().getInGame()));
|
||||||
lastChoose = now;
|
lastChoose = now;
|
||||||
}
|
}
|
||||||
|
@ -367,6 +389,10 @@ public class LGPlayer {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return super.toString()+" ("+getName()+")";
|
return super.toString() + " (" + getName() + ")";
|
||||||
|
}
|
||||||
|
|
||||||
|
public interface LGChooseCallback {
|
||||||
|
void callback(LGPlayer choosen);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
package fr.leomelki.loupgarou.classes;
|
package fr.leomelki.loupgarou.classes;
|
||||||
|
|
||||||
import org.bukkit.Sound;
|
|
||||||
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
import org.bukkit.Sound;
|
||||||
|
|
||||||
public enum LGSound {
|
public enum LGSound {
|
||||||
KILL(Sound.ENTITY_BLAZE_DEATH),
|
KILL(Sound.ENTITY_BLAZE_DEATH),
|
||||||
|
@ -13,7 +12,8 @@ public enum LGSound {
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
final Sound sound;
|
final Sound sound;
|
||||||
LGSound(Sound sound){
|
|
||||||
|
LGSound(Sound sound) {
|
||||||
this.sound = sound;
|
this.sound = sound;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,17 @@
|
||||||
package fr.leomelki.loupgarou.classes;
|
package fr.leomelki.loupgarou.classes;
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
import com.comphenix.protocol.wrappers.EnumWrappers.ItemSlot;
|
||||||
import java.util.*;
|
import com.comphenix.protocol.wrappers.WrappedDataWatcher;
|
||||||
import java.util.Map.Entry;
|
import com.comphenix.protocol.wrappers.WrappedDataWatcher.WrappedDataWatcherObject;
|
||||||
|
import com.comphenix.protocol.wrappers.WrappedWatchableObject;
|
||||||
|
import fr.leomelki.com.comphenix.packetwrapper.*;
|
||||||
|
import fr.leomelki.loupgarou.MainLg;
|
||||||
|
import fr.leomelki.loupgarou.classes.LGGame.TextGenerator;
|
||||||
|
import fr.leomelki.loupgarou.classes.LGPlayer.LGChooseCallback;
|
||||||
|
import fr.leomelki.loupgarou.events.LGVoteLeaderChange;
|
||||||
|
import fr.leomelki.loupgarou.utils.VariousUtils;
|
||||||
|
import lombok.Getter;
|
||||||
|
import net.minecraft.server.v1_15_R1.*;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
|
@ -13,83 +21,16 @@ import org.bukkit.entity.EntityType;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
|
||||||
import com.comphenix.protocol.wrappers.EnumWrappers.ItemSlot;
|
import java.lang.reflect.Field;
|
||||||
import com.comphenix.protocol.wrappers.WrappedDataWatcher;
|
import java.util.*;
|
||||||
import com.comphenix.protocol.wrappers.WrappedDataWatcher.WrappedDataWatcherObject;
|
import java.util.Map.Entry;
|
||||||
import com.comphenix.protocol.wrappers.WrappedWatchableObject;
|
|
||||||
|
|
||||||
import fr.leomelki.com.comphenix.packetwrapper.WrapperPlayServerEntityDestroy;
|
|
||||||
import fr.leomelki.com.comphenix.packetwrapper.WrapperPlayServerEntityEquipment;
|
|
||||||
import fr.leomelki.com.comphenix.packetwrapper.WrapperPlayServerEntityLook;
|
|
||||||
import fr.leomelki.com.comphenix.packetwrapper.WrapperPlayServerEntityMetadata;
|
|
||||||
import fr.leomelki.com.comphenix.packetwrapper.WrapperPlayServerSpawnEntityLiving;
|
|
||||||
import fr.leomelki.loupgarou.MainLg;
|
|
||||||
import fr.leomelki.loupgarou.classes.LGGame.TextGenerator;
|
|
||||||
import fr.leomelki.loupgarou.classes.LGPlayer.LGChooseCallback;
|
|
||||||
import fr.leomelki.loupgarou.events.LGVoteLeaderChange;
|
|
||||||
import fr.leomelki.loupgarou.utils.VariousUtils;
|
|
||||||
import lombok.Getter;
|
|
||||||
import net.minecraft.server.v1_15_R1.DataWatcher;
|
|
||||||
import net.minecraft.server.v1_15_R1.DataWatcherObject;
|
|
||||||
import net.minecraft.server.v1_15_R1.Entity;
|
|
||||||
import net.minecraft.server.v1_15_R1.EntityArmorStand;
|
|
||||||
import net.minecraft.server.v1_15_R1.IChatBaseComponent;
|
|
||||||
import net.minecraft.server.v1_15_R1.PacketPlayOutEntityMetadata;
|
|
||||||
|
|
||||||
public class LGVote {
|
public class LGVote {
|
||||||
@Getter LGPlayer choosen;
|
private static final EntityArmorStand eas = new EntityArmorStand(((CraftWorld) Bukkit.getWorlds().get(0)).getHandle(), 0, 0, 0);
|
||||||
private int timeout;
|
|
||||||
private final int initialTimeout;
|
|
||||||
private final int littleTimeout;
|
|
||||||
private Runnable callback;
|
|
||||||
private final LGGame game;
|
|
||||||
@Getter private List<LGPlayer> participants, viewers;
|
|
||||||
private final TextGenerator generator;
|
|
||||||
@Getter private final HashMap<LGPlayer, List<LGPlayer>> votes = new HashMap<>();
|
|
||||||
private int votesSize = 0;
|
|
||||||
private LGPlayer mayor;
|
|
||||||
private ArrayList<LGPlayer> latestTop = new ArrayList<>(), blacklisted = new ArrayList<>();
|
|
||||||
private final boolean randomIfEqual;
|
|
||||||
@Getter private boolean mayorVote;
|
|
||||||
private boolean ended;
|
|
||||||
public LGVote(int timeout, int littleTimeout, LGGame game, boolean positiveVote, boolean randomIfEqual, TextGenerator generator) {
|
|
||||||
this.littleTimeout = littleTimeout;
|
|
||||||
this.initialTimeout = timeout;
|
|
||||||
this.timeout = timeout;
|
|
||||||
this.game = game;
|
|
||||||
this.generator = generator;
|
|
||||||
this.randomIfEqual = randomIfEqual;
|
|
||||||
}
|
|
||||||
public void start(List<LGPlayer> participants, List<LGPlayer> viewers, Runnable callback) {
|
|
||||||
this.callback = callback;
|
|
||||||
this.participants = participants;
|
|
||||||
this.viewers = viewers;
|
|
||||||
game.wait(timeout, this::end, generator);
|
|
||||||
for(LGPlayer player : participants)
|
|
||||||
player.choose(getChooseCallback(player));
|
|
||||||
}
|
|
||||||
public void start(List<LGPlayer> participants, List<LGPlayer> viewers, Runnable callback, ArrayList<LGPlayer> blacklisted) {
|
|
||||||
this.callback = callback;
|
|
||||||
this.participants = participants;
|
|
||||||
this.viewers = viewers;
|
|
||||||
game.wait(timeout, this::end, generator);
|
|
||||||
for(LGPlayer player : participants)
|
|
||||||
player.choose(getChooseCallback(player));
|
|
||||||
this.blacklisted = blacklisted;
|
|
||||||
}
|
|
||||||
public void start(List<LGPlayer> participants, List<LGPlayer> viewers, Runnable callback, LGPlayer mayor) {
|
|
||||||
this.callback = callback;
|
|
||||||
this.participants = participants;
|
|
||||||
this.viewers = viewers;
|
|
||||||
this.mayor = mayor;
|
|
||||||
game.wait(timeout, this::end, generator);
|
|
||||||
for(LGPlayer player : participants)
|
|
||||||
player.choose(getChooseCallback(player));
|
|
||||||
}
|
|
||||||
private static DataWatcherObject<Optional<IChatBaseComponent>> az;
|
private static DataWatcherObject<Optional<IChatBaseComponent>> az;
|
||||||
private static DataWatcherObject<Boolean> aA;
|
private static DataWatcherObject<Boolean> aA;
|
||||||
private static DataWatcherObject<Byte> T;
|
private static DataWatcherObject<Byte> T;
|
||||||
private static final EntityArmorStand eas = new EntityArmorStand(((CraftWorld)Bukkit.getWorlds().get(0)).getHandle(), 0, 0, 0);
|
|
||||||
static {
|
static {
|
||||||
try {
|
try {
|
||||||
Field f = Entity.class.getDeclaredField("az");
|
Field f = Entity.class.getDeclaredField("az");
|
||||||
|
@ -101,61 +42,125 @@ public class LGVote {
|
||||||
f = Entity.class.getDeclaredField("T");
|
f = Entity.class.getDeclaredField("T");
|
||||||
f.setAccessible(true);
|
f.setAccessible(true);
|
||||||
T = (DataWatcherObject<Byte>) f.get(null);
|
T = (DataWatcherObject<Byte>) f.get(null);
|
||||||
}catch(Exception err) {
|
} catch (Exception err) {
|
||||||
err.printStackTrace();
|
err.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final WrappedDataWatcherObject invisible = new WrappedDataWatcherObject(0, WrappedDataWatcher.Registry.get(Byte.class));
|
||||||
|
final WrappedDataWatcherObject noGravity = new WrappedDataWatcherObject(5, WrappedDataWatcher.Registry.get(Boolean.class));
|
||||||
|
private final int initialTimeout;
|
||||||
|
private final int littleTimeout;
|
||||||
|
private final LGGame game;
|
||||||
|
private final TextGenerator generator;
|
||||||
|
@Getter
|
||||||
|
private final HashMap<LGPlayer, List<LGPlayer>> votes = new HashMap<>();
|
||||||
|
private final boolean randomIfEqual;
|
||||||
|
@Getter
|
||||||
|
LGPlayer choosen;
|
||||||
|
WrappedDataWatcherObject customNameVisible = new WrappedDataWatcherObject(3, WrappedDataWatcher.Registry.get(Boolean.class));
|
||||||
|
WrappedDataWatcherObject customName = new WrappedDataWatcherObject(2, WrappedDataWatcher.Registry.get(IChatBaseComponent.class));
|
||||||
|
WrappedDataWatcherObject item = new WrappedDataWatcherObject(7, WrappedDataWatcher.Registry.get(net.minecraft.server.v1_15_R1.ItemStack.class));
|
||||||
|
private int timeout;
|
||||||
|
private Runnable callback;
|
||||||
|
@Getter
|
||||||
|
private List<LGPlayer> participants, viewers;
|
||||||
|
private int votesSize = 0;
|
||||||
|
private LGPlayer mayor;
|
||||||
|
private ArrayList<LGPlayer> latestTop = new ArrayList<>(), blacklisted = new ArrayList<>();
|
||||||
|
@Getter
|
||||||
|
private boolean mayorVote;
|
||||||
|
private boolean ended;
|
||||||
|
|
||||||
|
public LGVote(int timeout, int littleTimeout, LGGame game, boolean positiveVote, boolean randomIfEqual, TextGenerator generator) {
|
||||||
|
this.littleTimeout = littleTimeout;
|
||||||
|
this.initialTimeout = timeout;
|
||||||
|
this.timeout = timeout;
|
||||||
|
this.game = game;
|
||||||
|
this.generator = generator;
|
||||||
|
this.randomIfEqual = randomIfEqual;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void start(List<LGPlayer> participants, List<LGPlayer> viewers, Runnable callback) {
|
||||||
|
this.callback = callback;
|
||||||
|
this.participants = participants;
|
||||||
|
this.viewers = viewers;
|
||||||
|
game.wait(timeout, this::end, generator);
|
||||||
|
for (LGPlayer player : participants)
|
||||||
|
player.choose(getChooseCallback(player));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void start(List<LGPlayer> participants, List<LGPlayer> viewers, Runnable callback, ArrayList<LGPlayer> blacklisted) {
|
||||||
|
this.callback = callback;
|
||||||
|
this.participants = participants;
|
||||||
|
this.viewers = viewers;
|
||||||
|
game.wait(timeout, this::end, generator);
|
||||||
|
for (LGPlayer player : participants)
|
||||||
|
player.choose(getChooseCallback(player));
|
||||||
|
this.blacklisted = blacklisted;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void start(List<LGPlayer> participants, List<LGPlayer> viewers, Runnable callback, LGPlayer mayor) {
|
||||||
|
this.callback = callback;
|
||||||
|
this.participants = participants;
|
||||||
|
this.viewers = viewers;
|
||||||
|
this.mayor = mayor;
|
||||||
|
game.wait(timeout, this::end, generator);
|
||||||
|
for (LGPlayer player : participants)
|
||||||
|
player.choose(getChooseCallback(player));
|
||||||
|
}
|
||||||
|
|
||||||
private void end() {
|
private void end() {
|
||||||
ended = true;
|
ended = true;
|
||||||
for(LGPlayer lgp : viewers)
|
for (LGPlayer lgp : viewers)
|
||||||
showVoting(lgp, null);
|
showVoting(lgp, null);
|
||||||
for(LGPlayer lgp : votes.keySet())
|
for (LGPlayer lgp : votes.keySet())
|
||||||
updateVotes(lgp, true);
|
updateVotes(lgp, true);
|
||||||
int max = 0;
|
int max = 0;
|
||||||
boolean equal = false;
|
boolean equal = false;
|
||||||
for(Entry<LGPlayer, List<LGPlayer>> entry : votes.entrySet())
|
for (Entry<LGPlayer, List<LGPlayer>> entry : votes.entrySet())
|
||||||
if(entry.getValue().size() > max) {
|
if (entry.getValue().size() > max) {
|
||||||
equal = false;
|
equal = false;
|
||||||
max = entry.getValue().size();
|
max = entry.getValue().size();
|
||||||
choosen = entry.getKey();
|
choosen = entry.getKey();
|
||||||
}else if(entry.getValue().size() == max)
|
} else if (entry.getValue().size() == max)
|
||||||
equal = true;
|
equal = true;
|
||||||
for(LGPlayer player : participants) {
|
for (LGPlayer player : participants) {
|
||||||
player.getCache().remove("vote");
|
player.getCache().remove("vote");
|
||||||
player.stopChoosing();
|
player.stopChoosing();
|
||||||
}
|
}
|
||||||
if(equal)
|
if (equal)
|
||||||
choosen = null;
|
choosen = null;
|
||||||
if(equal && mayor == null && randomIfEqual) {
|
if (equal && mayor == null && randomIfEqual) {
|
||||||
ArrayList<LGPlayer> choosable = new ArrayList<>();
|
ArrayList<LGPlayer> choosable = new ArrayList<>();
|
||||||
for(Entry<LGPlayer, List<LGPlayer>> entry : votes.entrySet())
|
for (Entry<LGPlayer, List<LGPlayer>> entry : votes.entrySet())
|
||||||
if(entry.getValue().size() == max)
|
if (entry.getValue().size() == max)
|
||||||
choosable.add(entry.getKey());
|
choosable.add(entry.getKey());
|
||||||
choosen = choosable.get(game.getRandom().nextInt(choosable.size()));
|
choosen = choosable.get(game.getRandom().nextInt(choosable.size()));
|
||||||
}
|
}
|
||||||
|
|
||||||
if(equal && mayor != null && max != 0) {
|
if (equal && mayor != null && max != 0) {
|
||||||
for(LGPlayer player : viewers)
|
for (LGPlayer player : viewers)
|
||||||
player.sendMessage("§9Égalité, le §5§lCapitaine§9 va départager les votes.");
|
player.sendMessage("§9Égalité, le §5§lCapitaine§9 va départager les votes.");
|
||||||
mayor.sendMessage("§6Tu dois choisir qui va mourir.");
|
mayor.sendMessage("§6Tu dois choisir qui va mourir.");
|
||||||
|
|
||||||
ArrayList<LGPlayer> choosable = new ArrayList<>();
|
ArrayList<LGPlayer> choosable = new ArrayList<>();
|
||||||
for(Entry<LGPlayer, List<LGPlayer>> entry : votes.entrySet())
|
for (Entry<LGPlayer, List<LGPlayer>> entry : votes.entrySet())
|
||||||
if(entry.getValue().size() == max)
|
if (entry.getValue().size() == max)
|
||||||
choosable.add(entry.getKey());
|
choosable.add(entry.getKey());
|
||||||
|
|
||||||
for(int i = 0;i<choosable.size();i++) {
|
for (int i = 0; i < choosable.size(); i++) {
|
||||||
LGPlayer lgp = choosable.get(i);
|
LGPlayer lgp = choosable.get(i);
|
||||||
showArrow(mayor, lgp, -mayor.getPlayer().getEntityId()-i);
|
showArrow(mayor, lgp, -mayor.getPlayer().getEntityId() - i);
|
||||||
}
|
}
|
||||||
|
|
||||||
StringJoiner sj = new StringJoiner(", ");
|
StringJoiner sj = new StringJoiner(", ");
|
||||||
for(int i = 0;i<choosable.size()-1;i++)
|
for (int i = 0; i < choosable.size() - 1; i++)
|
||||||
sj.add(choosable.get(0).getName());
|
sj.add(choosable.get(0).getName());
|
||||||
//mayor.sendTitle("§6C'est à vous de délibérer", "Faut-il tuer "+sj+" ou "+choosable.get(choosable.size()-1).getName()+" ?", 100);
|
//mayor.sendTitle("§6C'est à vous de délibérer", "Faut-il tuer "+sj+" ou "+choosable.get(choosable.size()-1).getName()+" ?", 100);
|
||||||
ArrayList<LGPlayer> blackListed = new ArrayList<>();
|
ArrayList<LGPlayer> blackListed = new ArrayList<>();
|
||||||
for(LGPlayer player : participants)
|
for (LGPlayer player : participants)
|
||||||
if(!choosable.contains(player))
|
if (!choosable.contains(player))
|
||||||
blackListed.add(player);
|
blackListed.add(player);
|
||||||
else {
|
else {
|
||||||
VariousUtils.setWarning(player.getPlayer(), true);
|
VariousUtils.setWarning(player.getPlayer(), true);
|
||||||
|
@ -163,34 +168,34 @@ public class LGVote {
|
||||||
//player.sendTitle("§4§lDéfendez vous !", "§cVous êtes l'un des principaux suspects", 100);
|
//player.sendTitle("§4§lDéfendez vous !", "§cVous êtes l'un des principaux suspects", 100);
|
||||||
}
|
}
|
||||||
mayorVote = true;
|
mayorVote = true;
|
||||||
game.wait(30, ()->{
|
game.wait(30, () -> {
|
||||||
for(LGPlayer player : participants)
|
for (LGPlayer player : participants)
|
||||||
if(choosable.contains(player))
|
if (choosable.contains(player))
|
||||||
VariousUtils.setWarning(player.getPlayer(), false);
|
VariousUtils.setWarning(player.getPlayer(), false);
|
||||||
|
|
||||||
for(int i = 0;i<choosable.size();i++) {
|
for (int i = 0; i < choosable.size(); i++) {
|
||||||
LGPlayer lgp = choosable.get(i);
|
LGPlayer lgp = choosable.get(i);
|
||||||
showArrow(mayor, null, -mayor.getPlayer().getEntityId()-i);
|
showArrow(mayor, null, -mayor.getPlayer().getEntityId() - i);
|
||||||
}
|
}
|
||||||
//Choix au hasard d'un joueur si personne n'a été désigné
|
//Choix au hasard d'un joueur si personne n'a été désigné
|
||||||
choosen = choosable.get(game.getRandom().nextInt(choosable.size()));
|
choosen = choosable.get(game.getRandom().nextInt(choosable.size()));
|
||||||
callback.run();
|
callback.run();
|
||||||
}, (player, secondsLeft)->{
|
}, (player, secondsLeft) -> {
|
||||||
timeout = secondsLeft;
|
timeout = secondsLeft;
|
||||||
return mayor == player ? "§6Il te reste §e"+secondsLeft+" seconde"+(secondsLeft > 1 ? "s" : "")+"§6 pour délibérer" : "§6Le §5§lCapitaine§6 délibère (§e"+secondsLeft+" s§6)";
|
return mayor == player ? "§6Il te reste §e" + secondsLeft + " seconde" + (secondsLeft > 1 ? "s" : "") + "§6 pour délibérer" : "§6Le §5§lCapitaine§6 délibère (§e" + secondsLeft + " s§6)";
|
||||||
});
|
});
|
||||||
mayor.choose(choosen -> {
|
mayor.choose(choosen -> {
|
||||||
if(choosen != null) {
|
if (choosen != null) {
|
||||||
if(blackListed.contains(choosen))
|
if (blackListed.contains(choosen))
|
||||||
mayor.sendMessage("§4§oCe joueur n'est pas concerné par le choix.");
|
mayor.sendMessage("§4§oCe joueur n'est pas concerné par le choix.");
|
||||||
else {
|
else {
|
||||||
for(LGPlayer player : participants)
|
for (LGPlayer player : participants)
|
||||||
if(choosable.contains(player))
|
if (choosable.contains(player))
|
||||||
VariousUtils.setWarning(player.getPlayer(), false);
|
VariousUtils.setWarning(player.getPlayer(), false);
|
||||||
|
|
||||||
for(int i = 0;i<choosable.size();i++) {
|
for (int i = 0; i < choosable.size(); i++) {
|
||||||
LGPlayer lgp = choosable.get(i);
|
LGPlayer lgp = choosable.get(i);
|
||||||
showArrow(mayor, null, -mayor.getPlayer().getEntityId()-i);
|
showArrow(mayor, null, -mayor.getPlayer().getEntityId() - i);
|
||||||
}
|
}
|
||||||
game.cancelWait();
|
game.cancelWait();
|
||||||
LGVote.this.choosen = choosen;
|
LGVote.this.choosen = choosen;
|
||||||
|
@ -204,38 +209,40 @@ public class LGVote {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public LGChooseCallback getChooseCallback(LGPlayer who) {
|
public LGChooseCallback getChooseCallback(LGPlayer who) {
|
||||||
return choosen -> {
|
return choosen -> {
|
||||||
if(choosen != null)
|
if (choosen != null)
|
||||||
vote(who, choosen);
|
vote(who, choosen);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public void vote(LGPlayer voter, LGPlayer voted) {
|
public void vote(LGPlayer voter, LGPlayer voted) {
|
||||||
if(blacklisted.contains(voted)) {
|
if (blacklisted.contains(voted)) {
|
||||||
voter.sendMessage("§cVous ne pouvez pas votre pour §7§l"+voted.getName()+"§c.");
|
voter.sendMessage("§cVous ne pouvez pas votre pour §7§l" + voted.getName() + "§c.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(voted == voter.getCache().get("vote"))
|
if (voted == voter.getCache().get("vote"))
|
||||||
voted = null;
|
voted = null;
|
||||||
|
|
||||||
if(voted != null && voter.getPlayer() != null)
|
if (voted != null && voter.getPlayer() != null)
|
||||||
votesSize++;
|
votesSize++;
|
||||||
if(voter.getCache().has("vote"))
|
if (voter.getCache().has("vote"))
|
||||||
votesSize--;
|
votesSize--;
|
||||||
|
|
||||||
if(votesSize == participants.size() && game.getWaitTicks() > littleTimeout*20) {
|
if (votesSize == participants.size() && game.getWaitTicks() > littleTimeout * 20) {
|
||||||
votesSize = 999;
|
votesSize = 999;
|
||||||
game.wait(littleTimeout, initialTimeout, this::end, generator);
|
game.wait(littleTimeout, initialTimeout, this::end, generator);
|
||||||
}
|
}
|
||||||
String italic = game.isDay() ? "" : "§o";
|
String italic = game.isDay() ? "" : "§o";
|
||||||
boolean changeVote = false;
|
boolean changeVote = false;
|
||||||
if(voter.getCache().has("vote")) {//On enlève l'ancien vote
|
if (voter.getCache().has("vote")) {//On enlève l'ancien vote
|
||||||
LGPlayer devoted = voter.getCache().get("vote");
|
LGPlayer devoted = voter.getCache().get("vote");
|
||||||
if(votes.containsKey(devoted)) {
|
if (votes.containsKey(devoted)) {
|
||||||
List<LGPlayer> voters = votes.get(devoted);
|
List<LGPlayer> voters = votes.get(devoted);
|
||||||
if(voters != null) {
|
if (voters != null) {
|
||||||
voters.remove(voter);
|
voters.remove(voter);
|
||||||
if(voters.size() == 0)
|
if (voters.size() == 0)
|
||||||
votes.remove(devoted);
|
votes.remove(devoted);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -244,9 +251,9 @@ public class LGVote {
|
||||||
changeVote = true;
|
changeVote = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(voted != null) {//Si il vient de voter, on ajoute le nouveau vote
|
if (voted != null) {//Si il vient de voter, on ajoute le nouveau vote
|
||||||
//voter.sendTitle("", "§7Tu as voté pour §7§l"+voted.getName(), 40);
|
//voter.sendTitle("", "§7Tu as voté pour §7§l"+voted.getName(), 40);
|
||||||
if(votes.containsKey(voted))
|
if (votes.containsKey(voted))
|
||||||
votes.get(voted).add(voter);
|
votes.get(voted).add(voter);
|
||||||
else
|
else
|
||||||
votes.put(voted, new ArrayList<>(Collections.singletonList(voter)));
|
votes.put(voted, new ArrayList<>(Collections.singletonList(voter)));
|
||||||
|
@ -254,56 +261,57 @@ public class LGVote {
|
||||||
updateVotes(voted);
|
updateVotes(voted);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(voter.getPlayer() != null) {
|
if (voter.getPlayer() != null) {
|
||||||
showVoting(voter, voted);
|
showVoting(voter, voted);
|
||||||
String message;
|
String message;
|
||||||
if(voted != null) {
|
if (voted != null) {
|
||||||
if(changeVote) {
|
if (changeVote) {
|
||||||
message = "§7§l"+voter.getName()+"§6 a changé son vote pour §7§l"+voted.getName()+"§6.";
|
message = "§7§l" + voter.getName() + "§6 a changé son vote pour §7§l" + voted.getName() + "§6.";
|
||||||
voter.sendMessage("§6Tu as changé de vote pour §7§l"+voted.getName()+"§6.");
|
voter.sendMessage("§6Tu as changé de vote pour §7§l" + voted.getName() + "§6.");
|
||||||
} else {
|
} else {
|
||||||
message = "§7§l"+voter.getName()+"§6 a voté pour §7§l"+voted.getName()+"§6.";
|
message = "§7§l" + voter.getName() + "§6 a voté pour §7§l" + voted.getName() + "§6.";
|
||||||
voter.sendMessage("§6Tu as voté pour §7§l"+voted.getName()+"§6.");
|
voter.sendMessage("§6Tu as voté pour §7§l" + voted.getName() + "§6.");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
message = "§7§l"+voter.getName()+"§6 a annulé son vote.";
|
message = "§7§l" + voter.getName() + "§6 a annulé son vote.";
|
||||||
voter.sendMessage("§6Tu as annulé ton vote.");
|
voter.sendMessage("§6Tu as annulé ton vote.");
|
||||||
}
|
}
|
||||||
|
|
||||||
for(LGPlayer player : viewers)
|
for (LGPlayer player : viewers)
|
||||||
if(player != voter)
|
if (player != voter)
|
||||||
player.sendMessage(message);
|
player.sendMessage(message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<LGPlayer> getVotes(LGPlayer voted){
|
public List<LGPlayer> getVotes(LGPlayer voted) {
|
||||||
return votes.containsKey(voted) ? votes.get(voted) : new ArrayList<>(0);
|
return votes.containsKey(voted) ? votes.get(voted) : new ArrayList<>(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateVotes(LGPlayer voted) {
|
private void updateVotes(LGPlayer voted) {
|
||||||
updateVotes(voted, false);
|
updateVotes(voted, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateVotes(LGPlayer voted, boolean kill) {
|
private void updateVotes(LGPlayer voted, boolean kill) {
|
||||||
int entityId = Integer.MIN_VALUE+voted.getPlayer().getEntityId();
|
int entityId = Integer.MIN_VALUE + voted.getPlayer().getEntityId();
|
||||||
WrapperPlayServerEntityDestroy destroy = new WrapperPlayServerEntityDestroy();
|
WrapperPlayServerEntityDestroy destroy = new WrapperPlayServerEntityDestroy();
|
||||||
destroy.setEntityIds(new int[] {entityId});
|
destroy.setEntityIds(new int[]{entityId});
|
||||||
for(LGPlayer lgp : viewers)
|
for (LGPlayer lgp : viewers)
|
||||||
destroy.sendPacket(lgp.getPlayer());
|
destroy.sendPacket(lgp.getPlayer());
|
||||||
|
|
||||||
if(!kill) {
|
if (!kill) {
|
||||||
int max = 0;
|
int max = 0;
|
||||||
for(Entry<LGPlayer, List<LGPlayer>> entry : votes.entrySet())
|
for (Entry<LGPlayer, List<LGPlayer>> entry : votes.entrySet())
|
||||||
if(entry.getValue().size() > max)
|
if (entry.getValue().size() > max)
|
||||||
max = entry.getValue().size();
|
max = entry.getValue().size();
|
||||||
ArrayList<LGPlayer> last = latestTop;
|
ArrayList<LGPlayer> last = latestTop;
|
||||||
latestTop = new ArrayList<>();
|
latestTop = new ArrayList<>();
|
||||||
for(Entry<LGPlayer, List<LGPlayer>> entry : votes.entrySet())
|
for (Entry<LGPlayer, List<LGPlayer>> entry : votes.entrySet())
|
||||||
if(entry.getValue().size() == max)
|
if (entry.getValue().size() == max)
|
||||||
latestTop.add(entry.getKey());
|
latestTop.add(entry.getKey());
|
||||||
Bukkit.getPluginManager().callEvent(new LGVoteLeaderChange(game, this, last, latestTop));
|
Bukkit.getPluginManager().callEvent(new LGVoteLeaderChange(game, this, last, latestTop));
|
||||||
}
|
}
|
||||||
|
|
||||||
if(votes.containsKey(voted) && !kill) {
|
if (votes.containsKey(voted) && !kill) {
|
||||||
Location loc = voted.getPlayer().getLocation();
|
Location loc = voted.getPlayer().getLocation();
|
||||||
|
|
||||||
WrapperPlayServerSpawnEntityLiving spawn = new WrapperPlayServerSpawnEntityLiving();
|
WrapperPlayServerSpawnEntityLiving spawn = new WrapperPlayServerSpawnEntityLiving();
|
||||||
|
@ -311,12 +319,12 @@ public class LGVote {
|
||||||
spawn.setType(EntityType.DROPPED_ITEM);
|
spawn.setType(EntityType.DROPPED_ITEM);
|
||||||
//spawn.setMetadata(new WrappedDataWatcher(Arrays.asList(new WrappedWatchableObject(0, (byte)0x20), new WrappedWatchableObject(5, true))));
|
//spawn.setMetadata(new WrappedDataWatcher(Arrays.asList(new WrappedWatchableObject(0, (byte)0x20), new WrappedWatchableObject(5, true))));
|
||||||
spawn.setX(loc.getX());
|
spawn.setX(loc.getX());
|
||||||
spawn.setY(loc.getY()+0.3);
|
spawn.setY(loc.getY() + 0.3);
|
||||||
spawn.setZ(loc.getZ());
|
spawn.setZ(loc.getZ());
|
||||||
|
|
||||||
int votesNbr = votes.get(voted).size();
|
int votesNbr = votes.get(voted).size();
|
||||||
final int numberOfParticipants = participants.size();
|
final int numberOfParticipants = participants.size();
|
||||||
final double votePercentage = ((double)votesNbr / numberOfParticipants) * 100;
|
final double votePercentage = ((double) votesNbr / numberOfParticipants) * 100;
|
||||||
final String votePercentageFormated = String.format("%.0f%%", votePercentage);
|
final String votePercentageFormated = String.format("%.0f%%", votePercentage);
|
||||||
final String voteContent = "§6§l" + votesNbr + " / " + numberOfParticipants + "§e vote" + (votesNbr > 1 ? "s" : "") + " (§6§l" + votePercentageFormated + "§e)";
|
final String voteContent = "§6§l" + votesNbr + " / " + numberOfParticipants + "§e vote" + (votesNbr > 1 ? "s" : "") + " (§6§l" + votePercentageFormated + "§e)";
|
||||||
|
|
||||||
|
@ -325,14 +333,14 @@ public class LGVote {
|
||||||
meta.setMetadata(Arrays.asList(new WrappedWatchableObject(invisible, (byte)0x20), new WrappedWatchableObject(noGravity, true), new WrappedWatchableObject(customNameVisible, true), new WrappedWatchableObject(customName, IChatBaseComponent.ChatSerializer.b("§6§l"+votesNbr+"§e vote"+(votesNbr > 1 ? "s" : "")))));
|
meta.setMetadata(Arrays.asList(new WrappedWatchableObject(invisible, (byte)0x20), new WrappedWatchableObject(noGravity, true), new WrappedWatchableObject(customNameVisible, true), new WrappedWatchableObject(customName, IChatBaseComponent.ChatSerializer.b("§6§l"+votesNbr+"§e vote"+(votesNbr > 1 ? "s" : "")))));
|
||||||
*/
|
*/
|
||||||
DataWatcher datawatcher = new DataWatcher(eas);
|
DataWatcher datawatcher = new DataWatcher(eas);
|
||||||
datawatcher.register(T, (byte)0x20);
|
datawatcher.register(T, (byte) 0x20);
|
||||||
datawatcher.register(az, Optional.ofNullable(IChatBaseComponent.ChatSerializer.a("{\"text\":\"" + voteContent + "\"}")));
|
datawatcher.register(az, Optional.ofNullable(IChatBaseComponent.ChatSerializer.a("{\"text\":\"" + voteContent + "\"}")));
|
||||||
datawatcher.register(aA, true);
|
datawatcher.register(aA, true);
|
||||||
PacketPlayOutEntityMetadata meta = new PacketPlayOutEntityMetadata(entityId, datawatcher, true);
|
PacketPlayOutEntityMetadata meta = new PacketPlayOutEntityMetadata(entityId, datawatcher, true);
|
||||||
|
|
||||||
for(LGPlayer lgp : viewers) {
|
for (LGPlayer lgp : viewers) {
|
||||||
spawn.sendPacket(lgp.getPlayer());
|
spawn.sendPacket(lgp.getPlayer());
|
||||||
((CraftPlayer)lgp.getPlayer()).getHandle().playerConnection.sendPacket(meta);
|
((CraftPlayer) lgp.getPlayer()).getHandle().playerConnection.sendPacket(meta);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -368,37 +376,33 @@ public class LGVote {
|
||||||
// spawn.sendPacket(lgp.getPlayer());
|
// spawn.sendPacket(lgp.getPlayer());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
final WrappedDataWatcherObject invisible = new WrappedDataWatcherObject(0, WrappedDataWatcher.Registry.get(Byte.class));
|
|
||||||
final WrappedDataWatcherObject noGravity = new WrappedDataWatcherObject(5, WrappedDataWatcher.Registry.get(Boolean.class));
|
|
||||||
WrappedDataWatcherObject customNameVisible = new WrappedDataWatcherObject(3, WrappedDataWatcher.Registry.get(Boolean.class));
|
|
||||||
WrappedDataWatcherObject customName = new WrappedDataWatcherObject(2, WrappedDataWatcher.Registry.get(IChatBaseComponent.class));
|
|
||||||
WrappedDataWatcherObject item = new WrappedDataWatcherObject(7, WrappedDataWatcher.Registry.get(net.minecraft.server.v1_15_R1.ItemStack.class));
|
|
||||||
private void showVoting(LGPlayer to, LGPlayer ofWho) {
|
private void showVoting(LGPlayer to, LGPlayer ofWho) {
|
||||||
int entityId = -to.getPlayer().getEntityId();
|
int entityId = -to.getPlayer().getEntityId();
|
||||||
WrapperPlayServerEntityDestroy destroy = new WrapperPlayServerEntityDestroy();
|
WrapperPlayServerEntityDestroy destroy = new WrapperPlayServerEntityDestroy();
|
||||||
destroy.setEntityIds(new int[] {entityId});
|
destroy.setEntityIds(new int[]{entityId});
|
||||||
destroy.sendPacket(to.getPlayer());
|
destroy.sendPacket(to.getPlayer());
|
||||||
if(ofWho != null) {
|
if (ofWho != null) {
|
||||||
WrapperPlayServerSpawnEntityLiving spawn = new WrapperPlayServerSpawnEntityLiving();
|
WrapperPlayServerSpawnEntityLiving spawn = new WrapperPlayServerSpawnEntityLiving();
|
||||||
spawn.setEntityID(entityId);
|
spawn.setEntityID(entityId);
|
||||||
spawn.setType(EntityType.DROPPED_ITEM);
|
spawn.setType(EntityType.DROPPED_ITEM);
|
||||||
//spawn.setMetadata(new WrappedDataWatcher(Arrays.asList(new WrappedWatchableObject(0, (byte)0x20), new WrappedWatchableObject(5, true))));
|
//spawn.setMetadata(new WrappedDataWatcher(Arrays.asList(new WrappedWatchableObject(0, (byte)0x20), new WrappedWatchableObject(5, true))));
|
||||||
Location loc = ofWho.getPlayer().getLocation();
|
Location loc = ofWho.getPlayer().getLocation();
|
||||||
spawn.setX(loc.getX());
|
spawn.setX(loc.getX());
|
||||||
spawn.setY(loc.getY()+1.3);
|
spawn.setY(loc.getY() + 1.3);
|
||||||
spawn.setZ(loc.getZ());
|
spawn.setZ(loc.getZ());
|
||||||
spawn.setHeadPitch(0);
|
spawn.setHeadPitch(0);
|
||||||
Location toLoc = to.getPlayer().getLocation();
|
Location toLoc = to.getPlayer().getLocation();
|
||||||
double diffX = loc.getX()-toLoc.getX(),
|
double diffX = loc.getX() - toLoc.getX(),
|
||||||
diffZ = loc.getZ()-toLoc.getZ();
|
diffZ = loc.getZ() - toLoc.getZ();
|
||||||
float yaw = 180-((float) Math.toDegrees(Math.atan2(diffX, diffZ)));
|
float yaw = 180 - ((float) Math.toDegrees(Math.atan2(diffX, diffZ)));
|
||||||
|
|
||||||
spawn.setYaw(yaw);
|
spawn.setYaw(yaw);
|
||||||
spawn.sendPacket(to.getPlayer());
|
spawn.sendPacket(to.getPlayer());
|
||||||
|
|
||||||
WrapperPlayServerEntityMetadata meta = new WrapperPlayServerEntityMetadata();
|
WrapperPlayServerEntityMetadata meta = new WrapperPlayServerEntityMetadata();
|
||||||
meta.setEntityID(entityId);
|
meta.setEntityID(entityId);
|
||||||
meta.setMetadata(Arrays.asList(new WrappedWatchableObject(invisible, (byte)0x20), new WrappedWatchableObject(noGravity, true)));
|
meta.setMetadata(Arrays.asList(new WrappedWatchableObject(invisible, (byte) 0x20), new WrappedWatchableObject(noGravity, true)));
|
||||||
meta.sendPacket(to.getPlayer());
|
meta.sendPacket(to.getPlayer());
|
||||||
|
|
||||||
WrapperPlayServerEntityLook look = new WrapperPlayServerEntityLook();
|
WrapperPlayServerEntityLook look = new WrapperPlayServerEntityLook();
|
||||||
|
@ -424,29 +428,29 @@ public class LGVote {
|
||||||
|
|
||||||
private void showArrow(LGPlayer to, LGPlayer ofWho, int entityId) {
|
private void showArrow(LGPlayer to, LGPlayer ofWho, int entityId) {
|
||||||
WrapperPlayServerEntityDestroy destroy = new WrapperPlayServerEntityDestroy();
|
WrapperPlayServerEntityDestroy destroy = new WrapperPlayServerEntityDestroy();
|
||||||
destroy.setEntityIds(new int[] {entityId});
|
destroy.setEntityIds(new int[]{entityId});
|
||||||
destroy.sendPacket(to.getPlayer());
|
destroy.sendPacket(to.getPlayer());
|
||||||
if(ofWho != null) {
|
if (ofWho != null) {
|
||||||
WrapperPlayServerSpawnEntityLiving spawn = new WrapperPlayServerSpawnEntityLiving();
|
WrapperPlayServerSpawnEntityLiving spawn = new WrapperPlayServerSpawnEntityLiving();
|
||||||
spawn.setEntityID(entityId);
|
spawn.setEntityID(entityId);
|
||||||
spawn.setType(EntityType.DROPPED_ITEM);
|
spawn.setType(EntityType.DROPPED_ITEM);
|
||||||
//spawn.setMetadata(new WrappedDataWatcher());
|
//spawn.setMetadata(new WrappedDataWatcher());
|
||||||
Location loc = ofWho.getPlayer().getLocation();
|
Location loc = ofWho.getPlayer().getLocation();
|
||||||
spawn.setX(loc.getX());
|
spawn.setX(loc.getX());
|
||||||
spawn.setY(loc.getY()+1.3);
|
spawn.setY(loc.getY() + 1.3);
|
||||||
spawn.setZ(loc.getZ());
|
spawn.setZ(loc.getZ());
|
||||||
spawn.setHeadPitch(0);
|
spawn.setHeadPitch(0);
|
||||||
Location toLoc = to.getPlayer().getLocation();
|
Location toLoc = to.getPlayer().getLocation();
|
||||||
double diffX = loc.getX()-toLoc.getX(),
|
double diffX = loc.getX() - toLoc.getX(),
|
||||||
diffZ = loc.getZ()-toLoc.getZ();
|
diffZ = loc.getZ() - toLoc.getZ();
|
||||||
float yaw = 180-((float) Math.toDegrees(Math.atan2(diffX, diffZ)));
|
float yaw = 180 - ((float) Math.toDegrees(Math.atan2(diffX, diffZ)));
|
||||||
|
|
||||||
spawn.setYaw(yaw);
|
spawn.setYaw(yaw);
|
||||||
spawn.sendPacket(to.getPlayer());
|
spawn.sendPacket(to.getPlayer());
|
||||||
|
|
||||||
WrapperPlayServerEntityMetadata meta = new WrapperPlayServerEntityMetadata();
|
WrapperPlayServerEntityMetadata meta = new WrapperPlayServerEntityMetadata();
|
||||||
meta.setEntityID(entityId);
|
meta.setEntityID(entityId);
|
||||||
meta.setMetadata(Arrays.asList(new WrappedWatchableObject(invisible, (byte)0x20), new WrappedWatchableObject(noGravity, true)));
|
meta.setMetadata(Arrays.asList(new WrappedWatchableObject(invisible, (byte) 0x20), new WrappedWatchableObject(noGravity, true)));
|
||||||
meta.sendPacket(to.getPlayer());
|
meta.sendPacket(to.getPlayer());
|
||||||
|
|
||||||
WrapperPlayServerEntityLook look = new WrapperPlayServerEntityLook();
|
WrapperPlayServerEntityLook look = new WrapperPlayServerEntityLook();
|
||||||
|
@ -469,9 +473,10 @@ public class LGVote {
|
||||||
}.runTaskLater(MainLg.getInstance(), 2);
|
}.runTaskLater(MainLg.getInstance(), 2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void remove(LGPlayer killed) {
|
public void remove(LGPlayer killed) {
|
||||||
participants.remove(killed);
|
participants.remove(killed);
|
||||||
if(!ended) {
|
if (!ended) {
|
||||||
votes.remove(killed);
|
votes.remove(killed);
|
||||||
latestTop.remove(killed);
|
latestTop.remove(killed);
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,5 +17,6 @@ public enum LGWinType {
|
||||||
VAMPIRE("§6§l§oLa partie a été gagnée par les §5§lVampires§6§l§o !"),
|
VAMPIRE("§6§l§oLa partie a été gagnée par les §5§lVampires§6§l§o !"),
|
||||||
NONE("§4Erreur: §cpersonne n'a gagné la partie.");
|
NONE("§4Erreur: §cpersonne n'a gagné la partie.");
|
||||||
|
|
||||||
@Getter private final String message;
|
@Getter
|
||||||
|
private final String message;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,35 +1,41 @@
|
||||||
package fr.leomelki.loupgarou.classes.chat;
|
package fr.leomelki.loupgarou.classes.chat;
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map.Entry;
|
|
||||||
|
|
||||||
import fr.leomelki.loupgarou.classes.LGPlayer;
|
import fr.leomelki.loupgarou.classes.LGPlayer;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public class LGChat {
|
public class LGChat {
|
||||||
@Getter private final HashMap<LGPlayer, LGChatCallback> viewers = new HashMap<>();
|
@Getter
|
||||||
@Getter private final LGChatCallback defaultCallback;
|
private final HashMap<LGPlayer, LGChatCallback> viewers = new HashMap<>();
|
||||||
|
@Getter
|
||||||
public interface LGChatCallback{
|
private final LGChatCallback defaultCallback;
|
||||||
String receive(LGPlayer sender, String message);
|
|
||||||
default String send(LGPlayer sender, String message) {return null;}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void sendMessage(LGPlayer sender, String message) {
|
public void sendMessage(LGPlayer sender, String message) {
|
||||||
String sendMessage = getViewers().get(sender).send(sender, message);
|
String sendMessage = getViewers().get(sender).send(sender, message);
|
||||||
for(Entry<LGPlayer, LGChatCallback> entry : viewers.entrySet())
|
for (Entry<LGPlayer, LGChatCallback> entry : viewers.entrySet())
|
||||||
entry.getKey().sendMessage(sendMessage != null ? sendMessage : entry.getValue().receive(sender, message));
|
entry.getKey().sendMessage(sendMessage != null ? sendMessage : entry.getValue().receive(sender, message));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void join(LGPlayer player, LGChatCallback callback) {
|
public void join(LGPlayer player, LGChatCallback callback) {
|
||||||
if(getViewers().containsKey(player))
|
if (getViewers().containsKey(player))
|
||||||
getViewers().replace(player, callback);
|
getViewers().replace(player, callback);
|
||||||
else
|
else
|
||||||
getViewers().put(player, callback);
|
getViewers().put(player, callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void leave(LGPlayer player) {
|
public void leave(LGPlayer player) {
|
||||||
getViewers().remove(player);
|
getViewers().remove(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public interface LGChatCallback {
|
||||||
|
String receive(LGPlayer sender, String message);
|
||||||
|
|
||||||
|
default String send(LGPlayer sender, String message) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,16 +2,18 @@ package fr.leomelki.loupgarou.classes.chat;
|
||||||
|
|
||||||
import fr.leomelki.loupgarou.classes.LGPlayer;
|
import fr.leomelki.loupgarou.classes.LGPlayer;
|
||||||
|
|
||||||
public class LGNoChat extends LGChat{
|
public class LGNoChat extends LGChat {
|
||||||
public LGNoChat() {
|
public LGNoChat() {
|
||||||
super(null);
|
super(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sendMessage(LGPlayer sender, String message) {}
|
public void sendMessage(LGPlayer sender, String message) {
|
||||||
|
}
|
||||||
|
|
||||||
public void join(LGPlayer player, LGChatCallback callback) {
|
public void join(LGPlayer player, LGChatCallback callback) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void leave(LGPlayer player) {
|
public void leave(LGPlayer player) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,14 +1,16 @@
|
||||||
package fr.leomelki.loupgarou.events;
|
package fr.leomelki.loupgarou.events;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import fr.leomelki.loupgarou.classes.LGGame;
|
import fr.leomelki.loupgarou.classes.LGGame;
|
||||||
import fr.leomelki.loupgarou.classes.LGPlayer;
|
import fr.leomelki.loupgarou.classes.LGPlayer;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class LGCustomItemChangeEvent extends LGEvent {
|
public class LGCustomItemChangeEvent extends LGEvent {
|
||||||
@Getter private final LGPlayer player;
|
@Getter
|
||||||
@Getter private final List<String> constraints;
|
private final LGPlayer player;
|
||||||
|
@Getter
|
||||||
|
private final List<String> constraints;
|
||||||
|
|
||||||
public LGCustomItemChangeEvent(LGGame game, LGPlayer player, List<String> constraints) {
|
public LGCustomItemChangeEvent(LGGame game, LGPlayer player, List<String> constraints) {
|
||||||
super(game);
|
super(game);
|
||||||
|
|
|
@ -2,7 +2,7 @@ package fr.leomelki.loupgarou.events;
|
||||||
|
|
||||||
import fr.leomelki.loupgarou.classes.LGGame;
|
import fr.leomelki.loupgarou.classes.LGGame;
|
||||||
|
|
||||||
public class LGDayEndEvent extends LGEvent{
|
public class LGDayEndEvent extends LGEvent {
|
||||||
public LGDayEndEvent(LGGame game) {
|
public LGDayEndEvent(LGGame game) {
|
||||||
super(game);
|
super(game);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,15 +1,16 @@
|
||||||
package fr.leomelki.loupgarou.events;
|
package fr.leomelki.loupgarou.events;
|
||||||
|
|
||||||
import org.bukkit.event.Cancellable;
|
|
||||||
|
|
||||||
import fr.leomelki.loupgarou.classes.LGGame;
|
import fr.leomelki.loupgarou.classes.LGGame;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
|
import org.bukkit.event.Cancellable;
|
||||||
|
|
||||||
|
public class LGDayStartEvent extends LGEvent implements Cancellable {
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
private boolean cancelled;
|
||||||
|
|
||||||
public class LGDayStartEvent extends LGEvent implements Cancellable{
|
|
||||||
public LGDayStartEvent(LGGame game) {
|
public LGDayStartEvent(LGGame game) {
|
||||||
super(game);
|
super(game);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Getter @Setter private boolean cancelled;
|
|
||||||
}
|
}
|
|
@ -5,11 +5,13 @@ import fr.leomelki.loupgarou.classes.LGWinType;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
|
|
||||||
public class LGEndCheckEvent extends LGEvent{
|
public class LGEndCheckEvent extends LGEvent {
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
private LGWinType winType;
|
||||||
|
|
||||||
public LGEndCheckEvent(LGGame game, LGWinType winType) {
|
public LGEndCheckEvent(LGGame game, LGWinType winType) {
|
||||||
super(game);
|
super(game);
|
||||||
this.winType = winType;
|
this.winType = winType;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Getter @Setter private LGWinType winType;
|
|
||||||
}
|
}
|
|
@ -1,22 +1,23 @@
|
||||||
package fr.leomelki.loupgarou.events;
|
package fr.leomelki.loupgarou.events;
|
||||||
|
|
||||||
import org.bukkit.event.Event;
|
|
||||||
import org.bukkit.event.HandlerList;
|
|
||||||
|
|
||||||
import fr.leomelki.loupgarou.classes.LGGame;
|
import fr.leomelki.loupgarou.classes.LGGame;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.bukkit.event.Event;
|
||||||
|
import org.bukkit.event.HandlerList;
|
||||||
|
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public class LGEvent extends Event{
|
public class LGEvent extends Event {
|
||||||
@Getter final LGGame game;
|
|
||||||
|
|
||||||
private static final HandlerList handlers = new HandlerList();
|
private static final HandlerList handlers = new HandlerList();
|
||||||
|
@Getter
|
||||||
|
final LGGame game;
|
||||||
|
|
||||||
|
public static HandlerList getHandlerList() {
|
||||||
|
return handlers;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public HandlerList getHandlers() {
|
public HandlerList getHandlers() {
|
||||||
return handlers;
|
return handlers;
|
||||||
}
|
}
|
||||||
public static HandlerList getHandlerList() {
|
|
||||||
return handlers;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,19 +1,23 @@
|
||||||
package fr.leomelki.loupgarou.events;
|
package fr.leomelki.loupgarou.events;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.bukkit.event.Cancellable;
|
|
||||||
|
|
||||||
import fr.leomelki.loupgarou.classes.LGGame;
|
import fr.leomelki.loupgarou.classes.LGGame;
|
||||||
import fr.leomelki.loupgarou.classes.LGPlayer;
|
import fr.leomelki.loupgarou.classes.LGPlayer;
|
||||||
import fr.leomelki.loupgarou.classes.LGWinType;
|
import fr.leomelki.loupgarou.classes.LGWinType;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
|
import org.bukkit.event.Cancellable;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class LGGameEndEvent extends LGEvent implements Cancellable {
|
||||||
|
@Getter
|
||||||
|
private final LGWinType winType;
|
||||||
|
@Getter
|
||||||
|
private final List<LGPlayer> winners;
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
private boolean cancelled;
|
||||||
|
|
||||||
public class LGGameEndEvent extends LGEvent implements Cancellable{
|
|
||||||
@Getter @Setter private boolean cancelled;
|
|
||||||
@Getter private final LGWinType winType;
|
|
||||||
@Getter private final List<LGPlayer> winners;
|
|
||||||
public LGGameEndEvent(LGGame game, LGWinType winType, List<LGPlayer> winners) {
|
public LGGameEndEvent(LGGame game, LGWinType winType, List<LGPlayer> winners) {
|
||||||
super(game);
|
super(game);
|
||||||
this.winType = winType;
|
this.winType = winType;
|
||||||
|
|
|
@ -4,12 +4,12 @@ import fr.leomelki.loupgarou.classes.LGGame;
|
||||||
import fr.leomelki.loupgarou.classes.LGPlayer;
|
import fr.leomelki.loupgarou.classes.LGPlayer;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
|
||||||
public class LGGameJoinEvent extends LGEvent{
|
public class LGGameJoinEvent extends LGEvent {
|
||||||
|
@Getter
|
||||||
|
final LGPlayer player;
|
||||||
|
|
||||||
public LGGameJoinEvent(LGGame game, LGPlayer player) {
|
public LGGameJoinEvent(LGGame game, LGPlayer player) {
|
||||||
super(game);
|
super(game);
|
||||||
this.player = player;
|
this.player = player;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Getter
|
|
||||||
final LGPlayer player;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,15 +1,16 @@
|
||||||
package fr.leomelki.loupgarou.events;
|
package fr.leomelki.loupgarou.events;
|
||||||
|
|
||||||
import org.bukkit.event.Cancellable;
|
|
||||||
|
|
||||||
import fr.leomelki.loupgarou.classes.LGGame;
|
import fr.leomelki.loupgarou.classes.LGGame;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
|
import org.bukkit.event.Cancellable;
|
||||||
|
|
||||||
|
public class LGMayorVoteEvent extends LGEvent implements Cancellable {
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
private boolean cancelled;
|
||||||
|
|
||||||
public class LGMayorVoteEvent extends LGEvent implements Cancellable{
|
|
||||||
public LGMayorVoteEvent(LGGame game) {
|
public LGMayorVoteEvent(LGGame game) {
|
||||||
super(game);
|
super(game);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Getter @Setter private boolean cancelled;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,15 +1,16 @@
|
||||||
package fr.leomelki.loupgarou.events;
|
package fr.leomelki.loupgarou.events;
|
||||||
|
|
||||||
import org.bukkit.event.Cancellable;
|
|
||||||
|
|
||||||
import fr.leomelki.loupgarou.classes.LGGame;
|
import fr.leomelki.loupgarou.classes.LGGame;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
|
import org.bukkit.event.Cancellable;
|
||||||
|
|
||||||
|
public class LGNightEndEvent extends LGEvent implements Cancellable {
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
private boolean cancelled;
|
||||||
|
|
||||||
public class LGNightEndEvent extends LGEvent implements Cancellable{
|
|
||||||
public LGNightEndEvent(LGGame game) {
|
public LGNightEndEvent(LGGame game) {
|
||||||
super(game);
|
super(game);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Getter @Setter private boolean cancelled;
|
|
||||||
}
|
}
|
|
@ -1,23 +1,25 @@
|
||||||
package fr.leomelki.loupgarou.events;
|
package fr.leomelki.loupgarou.events;
|
||||||
|
|
||||||
import org.bukkit.event.Cancellable;
|
|
||||||
|
|
||||||
import fr.leomelki.loupgarou.classes.LGGame;
|
import fr.leomelki.loupgarou.classes.LGGame;
|
||||||
import fr.leomelki.loupgarou.classes.LGPlayer;
|
import fr.leomelki.loupgarou.classes.LGPlayer;
|
||||||
import fr.leomelki.loupgarou.events.LGPlayerKilledEvent.Reason;
|
import fr.leomelki.loupgarou.events.LGPlayerKilledEvent.Reason;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
|
import org.bukkit.event.Cancellable;
|
||||||
|
|
||||||
public class LGNightPlayerPreKilledEvent extends LGEvent implements Cancellable{
|
public class LGNightPlayerPreKilledEvent extends LGEvent implements Cancellable {
|
||||||
|
@Getter
|
||||||
|
private final LGPlayer killed;
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
boolean cancelled;
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
private Reason reason;
|
||||||
public LGNightPlayerPreKilledEvent(LGGame game, LGPlayer killed, Reason reason) {
|
public LGNightPlayerPreKilledEvent(LGGame game, LGPlayer killed, Reason reason) {
|
||||||
super(game);
|
super(game);
|
||||||
this.killed = killed;
|
this.killed = killed;
|
||||||
this.reason = reason;
|
this.reason = reason;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Getter @Setter boolean cancelled;
|
|
||||||
|
|
||||||
@Getter private final LGPlayer killed;
|
|
||||||
@Getter @Setter private Reason reason;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,17 +1,18 @@
|
||||||
package fr.leomelki.loupgarou.events;
|
package fr.leomelki.loupgarou.events;
|
||||||
|
|
||||||
import org.bukkit.event.Cancellable;
|
|
||||||
|
|
||||||
import fr.leomelki.loupgarou.classes.LGGame;
|
import fr.leomelki.loupgarou.classes.LGGame;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
|
import org.bukkit.event.Cancellable;
|
||||||
|
|
||||||
public class LGNightStart extends LGEvent implements Cancellable{
|
public class LGNightStart extends LGEvent implements Cancellable {
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
boolean cancelled;
|
||||||
|
|
||||||
public LGNightStart(LGGame game) {
|
public LGNightStart(LGGame game) {
|
||||||
super(game);
|
super(game);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Getter @Setter boolean cancelled;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,12 @@ import fr.leomelki.loupgarou.events.LGPlayerKilledEvent.Reason;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
|
||||||
public class LGPlayerGotKilledEvent extends LGEvent {
|
public class LGPlayerGotKilledEvent extends LGEvent {
|
||||||
|
@Getter
|
||||||
|
private final boolean endGame;
|
||||||
|
@Getter
|
||||||
|
private final LGPlayer killed;
|
||||||
|
@Getter
|
||||||
|
private final Reason reason;
|
||||||
public LGPlayerGotKilledEvent(LGGame game, LGPlayer killed, Reason reason, boolean endGame) {
|
public LGPlayerGotKilledEvent(LGGame game, LGPlayer killed, Reason reason, boolean endGame) {
|
||||||
super(game);
|
super(game);
|
||||||
this.killed = killed;
|
this.killed = killed;
|
||||||
|
@ -13,8 +19,4 @@ public class LGPlayerGotKilledEvent extends LGEvent {
|
||||||
this.endGame = endGame;
|
this.endGame = endGame;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Getter private final boolean endGame;
|
|
||||||
@Getter private final LGPlayer killed;
|
|
||||||
@Getter private final Reason reason;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,27 +1,30 @@
|
||||||
package fr.leomelki.loupgarou.events;
|
package fr.leomelki.loupgarou.events;
|
||||||
|
|
||||||
import org.bukkit.event.Cancellable;
|
|
||||||
|
|
||||||
import fr.leomelki.loupgarou.classes.LGGame;
|
import fr.leomelki.loupgarou.classes.LGGame;
|
||||||
import fr.leomelki.loupgarou.classes.LGPlayer;
|
import fr.leomelki.loupgarou.classes.LGPlayer;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
|
import org.bukkit.event.Cancellable;
|
||||||
|
|
||||||
public class LGPlayerKilledEvent extends LGEvent implements Cancellable{
|
public class LGPlayerKilledEvent extends LGEvent implements Cancellable {
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
boolean cancelled;
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
private LGPlayer killed;
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
private Reason reason;
|
||||||
public LGPlayerKilledEvent(LGGame game, LGPlayer killed, Reason reason) {
|
public LGPlayerKilledEvent(LGGame game, LGPlayer killed, Reason reason) {
|
||||||
super(game);
|
super(game);
|
||||||
this.killed = killed;
|
this.killed = killed;
|
||||||
this.reason = reason;
|
this.reason = reason;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Getter @Setter boolean cancelled;
|
|
||||||
|
|
||||||
@Getter @Setter private LGPlayer killed;
|
|
||||||
@Getter @Setter private Reason reason;
|
|
||||||
|
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public enum Reason{
|
public enum Reason {
|
||||||
LOUP_GAROU("§7§l%s§4 est mort pendant la nuit"),
|
LOUP_GAROU("§7§l%s§4 est mort pendant la nuit"),
|
||||||
GM_LOUP_GAROU("§7§l%s§4 est mort pendant la nuit"),
|
GM_LOUP_GAROU("§7§l%s§4 est mort pendant la nuit"),
|
||||||
LOUP_BLANC(LOUP_GAROU.getMessage()),
|
LOUP_BLANC(LOUP_GAROU.getMessage()),
|
||||||
|
@ -41,7 +44,8 @@ public class LGPlayerKilledEvent extends LGEvent implements Cancellable{
|
||||||
|
|
||||||
DONT_DIE("§7§l%s§4 est mort pour rien");
|
DONT_DIE("§7§l%s§4 est mort pour rien");
|
||||||
|
|
||||||
@Getter private final String message;
|
@Getter
|
||||||
|
private final String message;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,15 +1,16 @@
|
||||||
package fr.leomelki.loupgarou.events;
|
package fr.leomelki.loupgarou.events;
|
||||||
|
|
||||||
import org.bukkit.event.Cancellable;
|
|
||||||
|
|
||||||
import fr.leomelki.loupgarou.classes.LGGame;
|
import fr.leomelki.loupgarou.classes.LGGame;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
|
import org.bukkit.event.Cancellable;
|
||||||
|
|
||||||
|
public class LGPreDayStartEvent extends LGEvent implements Cancellable {
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
private boolean cancelled;
|
||||||
|
|
||||||
public class LGPreDayStartEvent extends LGEvent implements Cancellable{
|
|
||||||
public LGPreDayStartEvent(LGGame game) {
|
public LGPreDayStartEvent(LGGame game) {
|
||||||
super(game);
|
super(game);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Getter @Setter private boolean cancelled;
|
|
||||||
}
|
}
|
|
@ -1,18 +1,20 @@
|
||||||
package fr.leomelki.loupgarou.events;
|
package fr.leomelki.loupgarou.events;
|
||||||
|
|
||||||
import org.bukkit.event.Cancellable;
|
|
||||||
|
|
||||||
import fr.leomelki.loupgarou.classes.LGGame;
|
import fr.leomelki.loupgarou.classes.LGGame;
|
||||||
import fr.leomelki.loupgarou.classes.LGPlayer;
|
import fr.leomelki.loupgarou.classes.LGPlayer;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
|
import org.bukkit.event.Cancellable;
|
||||||
|
|
||||||
public class LGPyromaneGasoilEvent extends LGEvent implements Cancellable{
|
public class LGPyromaneGasoilEvent extends LGEvent implements Cancellable {
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
private boolean cancelled;
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
private LGPlayer player;
|
||||||
public LGPyromaneGasoilEvent(LGGame game, LGPlayer player) {
|
public LGPyromaneGasoilEvent(LGGame game, LGPlayer player) {
|
||||||
super(game);
|
super(game);
|
||||||
this.player = player;
|
this.player = player;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Getter @Setter private boolean cancelled;
|
|
||||||
@Getter @Setter private LGPlayer player;
|
|
||||||
}
|
}
|
|
@ -4,12 +4,13 @@ import fr.leomelki.loupgarou.classes.LGGame;
|
||||||
import fr.leomelki.loupgarou.roles.Role;
|
import fr.leomelki.loupgarou.roles.Role;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
|
||||||
public class LGRoleTurnEndEvent extends LGEvent{
|
public class LGRoleTurnEndEvent extends LGEvent {
|
||||||
|
@Getter
|
||||||
|
private final Role newRole, previousRole;
|
||||||
|
|
||||||
public LGRoleTurnEndEvent(LGGame game, Role newRole, Role previousRole) {
|
public LGRoleTurnEndEvent(LGGame game, Role newRole, Role previousRole) {
|
||||||
super(game);
|
super(game);
|
||||||
this.newRole = newRole;
|
this.newRole = newRole;
|
||||||
this.previousRole = previousRole;
|
this.previousRole = previousRole;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Getter private final Role newRole, previousRole;
|
|
||||||
}
|
}
|
|
@ -1,7 +1,6 @@
|
||||||
package fr.leomelki.loupgarou.events;
|
package fr.leomelki.loupgarou.events;
|
||||||
|
|
||||||
import com.comphenix.protocol.wrappers.WrappedGameProfile;
|
import com.comphenix.protocol.wrappers.WrappedGameProfile;
|
||||||
|
|
||||||
import fr.leomelki.loupgarou.classes.LGGame;
|
import fr.leomelki.loupgarou.classes.LGGame;
|
||||||
import fr.leomelki.loupgarou.classes.LGPlayer;
|
import fr.leomelki.loupgarou.classes.LGPlayer;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
@ -9,8 +8,12 @@ import lombok.Setter;
|
||||||
|
|
||||||
public class LGSkinLoadEvent extends LGEvent {
|
public class LGSkinLoadEvent extends LGEvent {
|
||||||
|
|
||||||
@Getter private final LGPlayer player, to;
|
@Getter
|
||||||
@Getter @Setter private WrappedGameProfile profile;
|
private final LGPlayer player, to;
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
private WrappedGameProfile profile;
|
||||||
|
|
||||||
public LGSkinLoadEvent(LGGame game, LGPlayer player, LGPlayer to, WrappedGameProfile profile) {
|
public LGSkinLoadEvent(LGGame game, LGPlayer player, LGPlayer to, WrappedGameProfile profile) {
|
||||||
super(game);
|
super(game);
|
||||||
this.player = player;
|
this.player = player;
|
||||||
|
|
|
@ -6,8 +6,12 @@ import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
|
|
||||||
public class LGUpdatePrefixEvent extends LGEvent {
|
public class LGUpdatePrefixEvent extends LGEvent {
|
||||||
@Getter @Setter private String prefix;
|
@Getter
|
||||||
@Getter private final LGPlayer player, to;
|
private final LGPlayer player, to;
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
private String prefix;
|
||||||
|
|
||||||
public LGUpdatePrefixEvent(LGGame game, LGPlayer player, LGPlayer to, String prefix) {
|
public LGUpdatePrefixEvent(LGGame game, LGPlayer player, LGPlayer to, String prefix) {
|
||||||
super(game);
|
super(game);
|
||||||
this.player = player;
|
this.player = player;
|
||||||
|
|
|
@ -5,12 +5,15 @@ import fr.leomelki.loupgarou.classes.LGPlayer;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
|
|
||||||
public class LGVampiredEvent extends LGEvent{
|
public class LGVampiredEvent extends LGEvent {
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
private boolean immuned, protect;
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
private LGPlayer player;
|
||||||
public LGVampiredEvent(LGGame game, LGPlayer player) {
|
public LGVampiredEvent(LGGame game, LGPlayer player) {
|
||||||
super(game);
|
super(game);
|
||||||
this.player = player;
|
this.player = player;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Getter @Setter private boolean immuned, protect;
|
|
||||||
@Getter @Setter private LGPlayer player;
|
|
||||||
}
|
}
|
|
@ -1,15 +1,16 @@
|
||||||
package fr.leomelki.loupgarou.events;
|
package fr.leomelki.loupgarou.events;
|
||||||
|
|
||||||
import org.bukkit.event.Cancellable;
|
|
||||||
|
|
||||||
import fr.leomelki.loupgarou.classes.LGGame;
|
import fr.leomelki.loupgarou.classes.LGGame;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
|
import org.bukkit.event.Cancellable;
|
||||||
|
|
||||||
|
public class LGVoteEvent extends LGEvent implements Cancellable {
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
private boolean cancelled;
|
||||||
|
|
||||||
public class LGVoteEvent extends LGEvent implements Cancellable{
|
|
||||||
public LGVoteEvent(LGGame game) {
|
public LGVoteEvent(LGGame game) {
|
||||||
super(game);
|
super(game);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Getter @Setter private boolean cancelled;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,20 +1,13 @@
|
||||||
package fr.leomelki.loupgarou.events;
|
package fr.leomelki.loupgarou.events;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
import fr.leomelki.loupgarou.classes.LGGame;
|
import fr.leomelki.loupgarou.classes.LGGame;
|
||||||
import fr.leomelki.loupgarou.classes.LGPlayer;
|
import fr.leomelki.loupgarou.classes.LGPlayer;
|
||||||
import fr.leomelki.loupgarou.classes.LGVote;
|
import fr.leomelki.loupgarou.classes.LGVote;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
|
||||||
public class LGVoteLeaderChange extends LGEvent{
|
import java.util.ArrayList;
|
||||||
|
|
||||||
public LGVoteLeaderChange(LGGame game, LGVote vote, ArrayList<LGPlayer> latest, ArrayList<LGPlayer> now) {
|
public class LGVoteLeaderChange extends LGEvent {
|
||||||
super(game);
|
|
||||||
this.latest = latest;
|
|
||||||
this.now = now;
|
|
||||||
this.vote = vote;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
final ArrayList<LGPlayer> latest;
|
final ArrayList<LGPlayer> latest;
|
||||||
|
@ -22,5 +15,11 @@ public class LGVoteLeaderChange extends LGEvent{
|
||||||
final ArrayList<LGPlayer> now;
|
final ArrayList<LGPlayer> now;
|
||||||
@Getter
|
@Getter
|
||||||
final LGVote vote;
|
final LGVote vote;
|
||||||
|
public LGVoteLeaderChange(LGGame game, LGVote vote, ArrayList<LGPlayer> latest, ArrayList<LGPlayer> now) {
|
||||||
|
super(game);
|
||||||
|
this.latest = latest;
|
||||||
|
this.now = now;
|
||||||
|
this.vote = vote;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package fr.leomelki.loupgarou.listeners;
|
package fr.leomelki.loupgarou.listeners;
|
||||||
|
|
||||||
import fr.leomelki.loupgarou.MainLg;
|
import fr.leomelki.loupgarou.MainLg;
|
||||||
|
import fr.leomelki.loupgarou.classes.LGPlayer;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
|
@ -15,42 +16,47 @@ import org.bukkit.event.player.PlayerRespawnEvent;
|
||||||
import org.bukkit.event.player.PlayerSwapHandItemsEvent;
|
import org.bukkit.event.player.PlayerSwapHandItemsEvent;
|
||||||
import org.bukkit.event.weather.WeatherChangeEvent;
|
import org.bukkit.event.weather.WeatherChangeEvent;
|
||||||
|
|
||||||
import fr.leomelki.loupgarou.classes.LGPlayer;
|
public class CancelListener implements Listener {
|
||||||
|
|
||||||
public class CancelListener implements Listener{
|
|
||||||
private final MainLg plugin;
|
private final MainLg plugin;
|
||||||
|
|
||||||
public CancelListener (MainLg mainLg) {
|
public CancelListener(MainLg mainLg) {
|
||||||
this.plugin = mainLg;
|
this.plugin = mainLg;
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPluie(WeatherChangeEvent e) {
|
public void onPluie(WeatherChangeEvent e) {
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onMove(PlayerMoveEvent e) {
|
public void onMove(PlayerMoveEvent e) {
|
||||||
LGPlayer lgp = LGPlayer.thePlayer(plugin, e.getPlayer());
|
LGPlayer lgp = LGPlayer.thePlayer(plugin, e.getPlayer());
|
||||||
if(lgp.getGame() != null && lgp.getGame().isStarted() && e.getFrom().distanceSquared(e.getTo()) > 0.001)
|
if (lgp.getGame() != null && lgp.getGame().isStarted() && e.getFrom().distanceSquared(e.getTo()) > 0.001)
|
||||||
e.setTo(e.getFrom());
|
e.setTo(e.getFrom());
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onDamage(EntityDamageEvent e) {
|
public void onDamage(EntityDamageEvent e) {
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onFood(FoodLevelChangeEvent e) {
|
public void onFood(FoodLevelChangeEvent e) {
|
||||||
e.setFoodLevel(6);
|
e.setFoodLevel(6);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onRespawn(PlayerRespawnEvent e) {
|
public void onRespawn(PlayerRespawnEvent e) {
|
||||||
e.setRespawnLocation(e.getPlayer().getLocation());
|
e.setRespawnLocation(e.getPlayer().getLocation());
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onRespawn(PlayerDeathEvent e) {
|
public void onRespawn(PlayerDeathEvent e) {
|
||||||
e.setDeathMessage("");
|
e.setDeathMessage("");
|
||||||
e.setKeepInventory(true);
|
e.setKeepInventory(true);
|
||||||
}
|
}
|
||||||
/* @EventHandler
|
|
||||||
|
/* @EventHandler
|
||||||
public void onAchievement(PlayerAchievementAwardedEvent e) {
|
public void onAchievement(PlayerAchievementAwardedEvent e) {
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
}*/
|
}*/
|
||||||
|
@ -58,18 +64,21 @@ public class CancelListener implements Listener{
|
||||||
public void onEntitySpawn(EntitySpawnEvent e) {
|
public void onEntitySpawn(EntitySpawnEvent e) {
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onDrop(PlayerDropItemEvent e) {
|
public void onDrop(PlayerDropItemEvent e) {
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onClickInventory(InventoryClickEvent e) {
|
public void onClickInventory(InventoryClickEvent e) {
|
||||||
if(LGPlayer.thePlayer(plugin, (Player)e.getWhoClicked()).getGame() != null)
|
if (LGPlayer.thePlayer(plugin, (Player) e.getWhoClicked()).getGame() != null)
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onClickInventory(PlayerSwapHandItemsEvent e) {
|
public void onClickInventory(PlayerSwapHandItemsEvent e) {
|
||||||
if(LGPlayer.thePlayer(plugin, e.getPlayer()).getGame() != null)
|
if (LGPlayer.thePlayer(plugin, e.getPlayer()).getGame() != null)
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,14 +1,13 @@
|
||||||
package fr.leomelki.loupgarou.listeners;
|
package fr.leomelki.loupgarou.listeners;
|
||||||
|
|
||||||
import fr.leomelki.loupgarou.MainLg;
|
import fr.leomelki.loupgarou.MainLg;
|
||||||
|
import fr.leomelki.loupgarou.classes.LGPlayer;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||||
|
|
||||||
import fr.leomelki.loupgarou.classes.LGPlayer;
|
public class ChatListener implements Listener {
|
||||||
|
|
||||||
public class ChatListener implements Listener{
|
|
||||||
|
|
||||||
private final MainLg plugin;
|
private final MainLg plugin;
|
||||||
|
|
||||||
|
@ -18,7 +17,7 @@ public class ChatListener implements Listener{
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST)
|
@EventHandler(priority = EventPriority.HIGHEST)
|
||||||
public void onChat(AsyncPlayerChatEvent e) {
|
public void onChat(AsyncPlayerChatEvent e) {
|
||||||
if(!e.isCancelled()) {
|
if (!e.isCancelled()) {
|
||||||
LGPlayer player = LGPlayer.thePlayer(plugin, e.getPlayer());
|
LGPlayer player = LGPlayer.thePlayer(plugin, e.getPlayer());
|
||||||
player.onChat(e.getMessage());
|
player.onChat(e.getMessage());
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
|
|
|
@ -1,7 +1,10 @@
|
||||||
package fr.leomelki.loupgarou.listeners;
|
package fr.leomelki.loupgarou.listeners;
|
||||||
|
|
||||||
import java.util.Collections;
|
import com.comphenix.protocol.wrappers.WrappedChatComponent;
|
||||||
|
import fr.leomelki.com.comphenix.packetwrapper.WrapperPlayServerScoreboardTeam;
|
||||||
|
import fr.leomelki.loupgarou.MainLg;
|
||||||
|
import fr.leomelki.loupgarou.classes.LGPlayer;
|
||||||
|
import fr.leomelki.loupgarou.events.LGPlayerKilledEvent.Reason;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.GameMode;
|
import org.bukkit.GameMode;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
@ -13,14 +16,9 @@ import org.bukkit.event.player.PlayerResourcePackStatusEvent;
|
||||||
import org.bukkit.event.player.PlayerResourcePackStatusEvent.Status;
|
import org.bukkit.event.player.PlayerResourcePackStatusEvent.Status;
|
||||||
import org.bukkit.potion.PotionEffectType;
|
import org.bukkit.potion.PotionEffectType;
|
||||||
|
|
||||||
import com.comphenix.protocol.wrappers.WrappedChatComponent;
|
import java.util.Collections;
|
||||||
|
|
||||||
import fr.leomelki.com.comphenix.packetwrapper.WrapperPlayServerScoreboardTeam;
|
public class JoinListener implements Listener {
|
||||||
import fr.leomelki.loupgarou.MainLg;
|
|
||||||
import fr.leomelki.loupgarou.classes.LGPlayer;
|
|
||||||
import fr.leomelki.loupgarou.events.LGPlayerKilledEvent.Reason;
|
|
||||||
|
|
||||||
public class JoinListener implements Listener{
|
|
||||||
private final MainLg plugin;
|
private final MainLg plugin;
|
||||||
|
|
||||||
public JoinListener(MainLg mainLg) {
|
public JoinListener(MainLg mainLg) {
|
||||||
|
@ -58,13 +56,14 @@ public class JoinListener implements Listener{
|
||||||
lgp.showView();
|
lgp.showView();
|
||||||
lgp.join(MainLg.getInstance().getCurrentGame());
|
lgp.join(MainLg.getInstance().getCurrentGame());
|
||||||
}
|
}
|
||||||
if(noSpec)
|
if (noSpec)
|
||||||
p.setGameMode(GameMode.ADVENTURE);
|
p.setGameMode(GameMode.ADVENTURE);
|
||||||
e.setJoinMessage("");
|
e.setJoinMessage("");
|
||||||
p.removePotionEffect(PotionEffectType.JUMP);
|
p.removePotionEffect(PotionEffectType.JUMP);
|
||||||
p.removePotionEffect(PotionEffectType.INVISIBILITY);
|
p.removePotionEffect(PotionEffectType.INVISIBILITY);
|
||||||
p.setWalkSpeed(0.2f);
|
p.setWalkSpeed(0.2f);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onResoucePack(PlayerResourcePackStatusEvent e) {
|
public void onResoucePack(PlayerResourcePackStatusEvent e) {
|
||||||
if (e.getStatus() == Status.SUCCESSFULLY_LOADED) {
|
if (e.getStatus() == Status.SUCCESSFULLY_LOADED) {
|
||||||
|
@ -72,16 +71,17 @@ public class JoinListener implements Listener{
|
||||||
LGPlayer lgp = LGPlayer.thePlayer(plugin, p);
|
LGPlayer lgp = LGPlayer.thePlayer(plugin, p);
|
||||||
lgp.showView();
|
lgp.showView();
|
||||||
lgp.join(MainLg.getInstance().getCurrentGame());
|
lgp.join(MainLg.getInstance().getCurrentGame());
|
||||||
} else if(e.getStatus() == Status.DECLINED || e.getStatus() == Status.FAILED_DOWNLOAD)
|
} else if (e.getStatus() == Status.DECLINED || e.getStatus() == Status.FAILED_DOWNLOAD)
|
||||||
e.getPlayer().kickPlayer(MainLg.getPrefix()+"§cIl vous faut le resourcepack pour jouer ! ("+e.getStatus()+")");
|
e.getPlayer().kickPlayer(MainLg.getPrefix() + "§cIl vous faut le resourcepack pour jouer ! (" + e.getStatus() + ")");
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onLeave(PlayerQuitEvent e) {
|
public void onLeave(PlayerQuitEvent e) {
|
||||||
Player p = e.getPlayer();
|
Player p = e.getPlayer();
|
||||||
LGPlayer lgp = LGPlayer.thePlayer(plugin, p);
|
LGPlayer lgp = LGPlayer.thePlayer(plugin, p);
|
||||||
if(lgp.getGame() != null) {
|
if (lgp.getGame() != null) {
|
||||||
lgp.leaveChat();
|
lgp.leaveChat();
|
||||||
if(lgp.getRole() != null && !lgp.isDead())
|
if (lgp.getRole() != null && !lgp.isDead())
|
||||||
lgp.getGame().kill(lgp, Reason.DISCONNECTED, true);
|
lgp.getGame().kill(lgp, Reason.DISCONNECTED, true);
|
||||||
lgp.getGame().getInGame().remove(lgp);
|
lgp.getGame().getInGame().remove(lgp);
|
||||||
lgp.getGame().checkLeave();
|
lgp.getGame().checkLeave();
|
||||||
|
|
|
@ -1,13 +1,11 @@
|
||||||
package fr.leomelki.loupgarou.listeners;
|
package fr.leomelki.loupgarou.listeners;
|
||||||
|
|
||||||
import org.bukkit.event.EventHandler;
|
|
||||||
import org.bukkit.event.Listener;
|
|
||||||
|
|
||||||
import com.comphenix.protocol.wrappers.EnumWrappers.ScoreboardAction;
|
import com.comphenix.protocol.wrappers.EnumWrappers.ScoreboardAction;
|
||||||
|
|
||||||
import fr.leomelki.com.comphenix.packetwrapper.WrapperPlayServerScoreboardScore;
|
import fr.leomelki.com.comphenix.packetwrapper.WrapperPlayServerScoreboardScore;
|
||||||
import fr.leomelki.com.comphenix.packetwrapper.WrapperPlayServerScoreboardTeam;
|
import fr.leomelki.com.comphenix.packetwrapper.WrapperPlayServerScoreboardTeam;
|
||||||
import fr.leomelki.loupgarou.events.LGGameJoinEvent;
|
import fr.leomelki.loupgarou.events.LGGameJoinEvent;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
|
||||||
public class LoupGarouListener implements Listener {
|
public class LoupGarouListener implements Listener {
|
||||||
@EventHandler
|
@EventHandler
|
||||||
|
|
|
@ -1,25 +1,26 @@
|
||||||
package fr.leomelki.loupgarou.listeners;
|
package fr.leomelki.loupgarou.listeners;
|
||||||
|
|
||||||
import fr.leomelki.loupgarou.MainLg;
|
import fr.leomelki.loupgarou.MainLg;
|
||||||
|
import fr.leomelki.loupgarou.classes.LGPlayer;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.block.BlockBreakEvent;
|
import org.bukkit.event.block.BlockBreakEvent;
|
||||||
import org.bukkit.event.player.PlayerAnimationEvent;
|
import org.bukkit.event.player.PlayerAnimationEvent;
|
||||||
import org.bukkit.event.player.PlayerAnimationType;
|
import org.bukkit.event.player.PlayerAnimationType;
|
||||||
|
|
||||||
import fr.leomelki.loupgarou.classes.LGPlayer;
|
public class VoteListener implements Listener {
|
||||||
|
|
||||||
public class VoteListener implements Listener{
|
|
||||||
private final MainLg plugin;
|
private final MainLg plugin;
|
||||||
|
|
||||||
public VoteListener(MainLg mainLg) {
|
public VoteListener(MainLg mainLg) {
|
||||||
this.plugin = mainLg;
|
this.plugin = mainLg;
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onClick(PlayerAnimationEvent e) {
|
public void onClick(PlayerAnimationEvent e) {
|
||||||
if(e.getAnimationType() == PlayerAnimationType.ARM_SWING)
|
if (e.getAnimationType() == PlayerAnimationType.ARM_SWING)
|
||||||
LGPlayer.thePlayer(plugin, e.getPlayer()).chooseAction();
|
LGPlayer.thePlayer(plugin, e.getPlayer()).chooseAction();
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onBreak(BlockBreakEvent e) {
|
public void onBreak(BlockBreakEvent e) {
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
|
|
|
@ -1,85 +1,94 @@
|
||||||
package fr.leomelki.loupgarou.roles;
|
package fr.leomelki.loupgarou.roles;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
import org.bukkit.event.EventHandler;
|
|
||||||
|
|
||||||
import fr.leomelki.loupgarou.classes.LGGame;
|
import fr.leomelki.loupgarou.classes.LGGame;
|
||||||
import fr.leomelki.loupgarou.classes.LGPlayer;
|
import fr.leomelki.loupgarou.classes.LGPlayer;
|
||||||
import fr.leomelki.loupgarou.classes.LGWinType;
|
import fr.leomelki.loupgarou.classes.LGWinType;
|
||||||
import fr.leomelki.loupgarou.events.LGDayEndEvent;
|
import fr.leomelki.loupgarou.events.*;
|
||||||
import fr.leomelki.loupgarou.events.LGEndCheckEvent;
|
|
||||||
import fr.leomelki.loupgarou.events.LGGameEndEvent;
|
|
||||||
import fr.leomelki.loupgarou.events.LGPlayerGotKilledEvent;
|
|
||||||
import fr.leomelki.loupgarou.events.LGVoteEvent;
|
|
||||||
import fr.leomelki.loupgarou.events.LGPlayerKilledEvent.Reason;
|
import fr.leomelki.loupgarou.events.LGPlayerKilledEvent.Reason;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
public class RAnge extends Role {
|
||||||
|
final ArrayList<LGPlayer> winners = new ArrayList<>();
|
||||||
|
boolean vote;
|
||||||
|
int night = 1;
|
||||||
|
|
||||||
public class RAnge extends Role{
|
|
||||||
public RAnge(LGGame game) {
|
public RAnge(LGGame game) {
|
||||||
super(game);
|
super(game);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public RoleType getType() {
|
public RoleType getType() {
|
||||||
return RoleType.NEUTRAL;
|
return RoleType.NEUTRAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public RoleWinType getWinType() {
|
public RoleWinType getWinType() {
|
||||||
return RoleWinType.VILLAGE;
|
return RoleWinType.VILLAGE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return "§d§lAnge";
|
return "§d§lAnge";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getFriendlyName() {
|
public String getFriendlyName() {
|
||||||
return "de l'"+getName();
|
return "de l'" + getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getShortDescription() {
|
public String getShortDescription() {
|
||||||
return "Tu gagnes si tu remplis ton objectif";
|
return "Tu gagnes si tu remplis ton objectif";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getDescription() {
|
public String getDescription() {
|
||||||
return "Tu es §d§lNeutre§f et tu gagnes si tu remplis ton objectif. Ton objectif est d'être éliminé par le village lors du premier vote de jour. Si tu réussis, tu gagnes la partie. Sinon, tu deviens un §a§lVillageois§f.";
|
return "Tu es §d§lNeutre§f et tu gagnes si tu remplis ton objectif. Ton objectif est d'être éliminé par le village lors du premier vote de jour. Si tu réussis, tu gagnes la partie. Sinon, tu deviens un §a§lVillageois§f.";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getTask() {
|
public String getTask() {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getBroadcastedTask() {
|
public String getBroadcastedTask() {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getTimeout() {
|
public int getTimeout() {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onVoteStart(LGVoteEvent e) {
|
public void onVoteStart(LGVoteEvent e) {
|
||||||
if(e.getGame() == getGame()) {
|
if (e.getGame() == getGame()) {
|
||||||
night = getGame().getNight();
|
night = getGame().getNight();
|
||||||
vote = true;
|
vote = true;
|
||||||
for(LGPlayer lgp : getPlayers())
|
for (LGPlayer lgp : getPlayers())
|
||||||
if(!lgp.isDead() && lgp.isRoleActive())
|
if (!lgp.isDead() && lgp.isRoleActive())
|
||||||
lgp.sendMessage("§9§oFais en sorte que les autres votent contre toi !");
|
lgp.sendMessage("§9§oFais en sorte que les autres votent contre toi !");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
boolean vote;
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onDayEnd(LGDayEndEvent e) {
|
public void onDayEnd(LGDayEndEvent e) {
|
||||||
if(e.getGame() == getGame()) {
|
if (e.getGame() == getGame()) {
|
||||||
if(getPlayers().size() > 0 && getGame().getNight() == night+1 && vote) {
|
if (getPlayers().size() > 0 && getGame().getNight() == night + 1 && vote) {
|
||||||
Role villageois = null;
|
Role villageois = null;
|
||||||
for(Role role : getGame().getRoles()) {
|
for (Role role : getGame().getRoles()) {
|
||||||
if(role instanceof RVillageois)
|
if (role instanceof RVillageois)
|
||||||
villageois = role;
|
villageois = role;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(villageois == null)
|
if (villageois == null)
|
||||||
getGame().getRoles().add(villageois = new RVillageois(getGame()));
|
getGame().getRoles().add(villageois = new RVillageois(getGame()));
|
||||||
|
|
||||||
for(LGPlayer lgp : getPlayers()) {
|
for (LGPlayer lgp : getPlayers()) {
|
||||||
if(lgp.isRoleActive())
|
if (lgp.isRoleActive())
|
||||||
lgp.sendMessage("§4§oTu as échoué, tu deviens §a§l§oVillageois§4§o...");
|
lgp.sendMessage("§4§oTu as échoué, tu deviens §a§l§oVillageois§4§o...");
|
||||||
lgp.setRole(villageois);
|
lgp.setRole(villageois);
|
||||||
villageois.join(lgp);
|
villageois.join(lgp);
|
||||||
|
@ -91,26 +100,25 @@ public class RAnge extends Role{
|
||||||
vote = false;
|
vote = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
final ArrayList<LGPlayer> winners = new ArrayList<>();
|
|
||||||
int night = 1;
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onDeath(LGPlayerGotKilledEvent e) {
|
public void onDeath(LGPlayerGotKilledEvent e) {
|
||||||
if(e.getGame() == getGame())
|
if (e.getGame() == getGame())
|
||||||
if(e.getReason() == Reason.VOTE && e.getKilled().getRole() == this && getGame().getNight() == night && e.getKilled().isRoleActive())
|
if (e.getReason() == Reason.VOTE && e.getKilled().getRole() == this && getGame().getNight() == night && e.getKilled().isRoleActive())
|
||||||
winners.add(e.getKilled());
|
winners.add(e.getKilled());
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onWinCheck(LGEndCheckEvent e) {
|
public void onWinCheck(LGEndCheckEvent e) {
|
||||||
if(e.getGame() == getGame())
|
if (e.getGame() == getGame())
|
||||||
if(winners.size() > 0)
|
if (winners.size() > 0)
|
||||||
e.setWinType(winners.size() == 1 && winners.get(0).getCache().has("inlove") ? LGWinType.COUPLE : LGWinType.ANGE);
|
e.setWinType(winners.size() == 1 && winners.get(0).getCache().has("inlove") ? LGWinType.COUPLE : LGWinType.ANGE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onWin(LGGameEndEvent e) {
|
public void onWin(LGGameEndEvent e) {
|
||||||
if(e.getGame() == getGame())
|
if (e.getGame() == getGame())
|
||||||
if(e.getWinType() == LGWinType.ANGE)
|
if (e.getWinType() == LGWinType.ANGE)
|
||||||
e.getWinners().addAll(winners);
|
e.getWinners().addAll(winners);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,56 +1,58 @@
|
||||||
package fr.leomelki.loupgarou.roles;
|
package fr.leomelki.loupgarou.roles;
|
||||||
|
|
||||||
import org.bukkit.event.EventHandler;
|
|
||||||
import org.bukkit.event.EventPriority;
|
|
||||||
|
|
||||||
import fr.leomelki.loupgarou.classes.LGGame;
|
import fr.leomelki.loupgarou.classes.LGGame;
|
||||||
import fr.leomelki.loupgarou.classes.LGPlayer;
|
import fr.leomelki.loupgarou.classes.LGPlayer;
|
||||||
import fr.leomelki.loupgarou.classes.LGWinType;
|
import fr.leomelki.loupgarou.classes.LGWinType;
|
||||||
import fr.leomelki.loupgarou.events.LGEndCheckEvent;
|
import fr.leomelki.loupgarou.events.*;
|
||||||
import fr.leomelki.loupgarou.events.LGGameEndEvent;
|
|
||||||
import fr.leomelki.loupgarou.events.LGNightEndEvent;
|
|
||||||
import fr.leomelki.loupgarou.events.LGNightPlayerPreKilledEvent;
|
|
||||||
import fr.leomelki.loupgarou.events.LGPlayerKilledEvent.Reason;
|
import fr.leomelki.loupgarou.events.LGPlayerKilledEvent.Reason;
|
||||||
import fr.leomelki.loupgarou.events.LGPyromaneGasoilEvent;
|
import org.bukkit.event.EventHandler;
|
||||||
import fr.leomelki.loupgarou.events.LGRoleTurnEndEvent;
|
import org.bukkit.event.EventPriority;
|
||||||
import fr.leomelki.loupgarou.events.LGVampiredEvent;
|
|
||||||
|
|
||||||
public class RAssassin extends Role{
|
public class RAssassin extends Role {
|
||||||
public RAssassin(LGGame game) {
|
public RAssassin(LGGame game) {
|
||||||
super(game);
|
super(game);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public RoleType getType() {
|
public RoleType getType() {
|
||||||
return RoleType.NEUTRAL;
|
return RoleType.NEUTRAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public RoleWinType getWinType() {
|
public RoleWinType getWinType() {
|
||||||
return RoleWinType.SEUL;
|
return RoleWinType.SEUL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return "§1§lAssassin";
|
return "§1§lAssassin";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getFriendlyName() {
|
public String getFriendlyName() {
|
||||||
return "de l'"+getName();
|
return "de l'" + getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getShortDescription() {
|
public String getShortDescription() {
|
||||||
return "Tu gagnes §7§lSEUL";
|
return "Tu gagnes §7§lSEUL";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getDescription() {
|
public String getDescription() {
|
||||||
return "Tu gagnes §7§lSEUL§f. Chaque nuit, tu peux choisir un joueur à éliminer. Tu es immunisé contre l'attaque des §c§lLoups§f.";
|
return "Tu gagnes §7§lSEUL§f. Chaque nuit, tu peux choisir un joueur à éliminer. Tu es immunisé contre l'attaque des §c§lLoups§f.";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getTask() {
|
public String getTask() {
|
||||||
return "Choisis un joueur à éliminer.";
|
return "Choisis un joueur à éliminer.";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getBroadcastedTask() {
|
public String getBroadcastedTask() {
|
||||||
return "L'"+getName()+"§9 ne controle plus ses pulsions...";
|
return "L'" + getName() + "§9 ne controle plus ses pulsions...";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getTimeout() {
|
public int getTimeout() {
|
||||||
return 15;
|
return 15;
|
||||||
|
@ -61,10 +63,10 @@ public class RAssassin extends Role{
|
||||||
player.showView();
|
player.showView();
|
||||||
|
|
||||||
player.choose(choosen -> {
|
player.choose(choosen -> {
|
||||||
if(choosen != null && choosen != player) {
|
if (choosen != null && choosen != player) {
|
||||||
getGame().kill(choosen, Reason.ASSASSIN);
|
getGame().kill(choosen, Reason.ASSASSIN);
|
||||||
player.sendActionBarMessage("§e§l"+choosen.getName()+"§6 va mourir");
|
player.sendActionBarMessage("§e§l" + choosen.getName() + "§6 va mourir");
|
||||||
player.sendMessage("§6Tu as choisi de tuer §7§l"+choosen.getName()+"§6.");
|
player.sendMessage("§6Tu as choisi de tuer §7§l" + choosen.getName() + "§6.");
|
||||||
player.stopChoosing();
|
player.stopChoosing();
|
||||||
player.hideView();
|
player.hideView();
|
||||||
callback.run();
|
callback.run();
|
||||||
|
@ -74,7 +76,7 @@ public class RAssassin extends Role{
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onKill(LGNightPlayerPreKilledEvent e) {
|
public void onKill(LGNightPlayerPreKilledEvent e) {
|
||||||
if(e.getKilled().getRole() == this && e.getReason() == Reason.LOUP_GAROU || e.getReason() == Reason.GM_LOUP_GAROU && e.getKilled().isRoleActive()) {//Les assassins ne peuvent pas mourir la nuit !
|
if (e.getKilled().getRole() == this && e.getReason() == Reason.LOUP_GAROU || e.getReason() == Reason.GM_LOUP_GAROU && e.getKilled().isRoleActive()) {//Les assassins ne peuvent pas mourir la nuit !
|
||||||
e.setReason(Reason.DONT_DIE);
|
e.setReason(Reason.DONT_DIE);
|
||||||
e.getKilled().getCache().set("assassin_protected", true);
|
e.getKilled().getCache().set("assassin_protected", true);
|
||||||
}
|
}
|
||||||
|
@ -82,18 +84,18 @@ public class RAssassin extends Role{
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onTour(LGRoleTurnEndEvent e) {
|
public void onTour(LGRoleTurnEndEvent e) {
|
||||||
if(e.getGame() == getGame()) {
|
if (e.getGame() == getGame()) {
|
||||||
if(e.getPreviousRole() instanceof RLoupGarou) {
|
if (e.getPreviousRole() instanceof RLoupGarou) {
|
||||||
for(LGPlayer lgp : getGame().getAlive())
|
for (LGPlayer lgp : getGame().getAlive())
|
||||||
if(lgp.getCache().getBoolean("assassin_protected")) {
|
if (lgp.getCache().getBoolean("assassin_protected")) {
|
||||||
for(LGPlayer l : getGame().getInGame())
|
for (LGPlayer l : getGame().getInGame())
|
||||||
if(l.getRoleType() == RoleType.LOUP_GAROU)
|
if (l.getRoleType() == RoleType.LOUP_GAROU)
|
||||||
l.sendMessage("§cVotre cible est immunisée.");
|
l.sendMessage("§cVotre cible est immunisée.");
|
||||||
}
|
}
|
||||||
}else if(e.getPreviousRole() instanceof RGrandMechantLoup) {
|
} else if (e.getPreviousRole() instanceof RGrandMechantLoup) {
|
||||||
for(LGPlayer lgp : getGame().getAlive())
|
for (LGPlayer lgp : getGame().getAlive())
|
||||||
if(lgp.getCache().getBoolean("assassin_protected")) {
|
if (lgp.getCache().getBoolean("assassin_protected")) {
|
||||||
for(LGPlayer l : e.getPreviousRole().getPlayers())
|
for (LGPlayer l : e.getPreviousRole().getPlayers())
|
||||||
l.sendMessage("§cVotre cible est immunisée.");
|
l.sendMessage("§cVotre cible est immunisée.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -102,31 +104,32 @@ public class RAssassin extends Role{
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPyroGasoil(LGPyromaneGasoilEvent e) {
|
public void onPyroGasoil(LGPyromaneGasoilEvent e) {
|
||||||
if(e.getPlayer().getRole() == this && e.getPlayer().isRoleActive())
|
if (e.getPlayer().getRole() == this && e.getPlayer().isRoleActive())
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onVampired(LGVampiredEvent e) {
|
public void onVampired(LGVampiredEvent e) {
|
||||||
if(e.getPlayer().getRole() == this && e.getPlayer().isRoleActive())
|
if (e.getPlayer().getRole() == this && e.getPlayer().isRoleActive())
|
||||||
e.setImmuned(true);
|
e.setImmuned(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onDayStart(LGNightEndEvent e) {
|
public void onDayStart(LGNightEndEvent e) {
|
||||||
if(e.getGame() == getGame()) {
|
if (e.getGame() == getGame()) {
|
||||||
for(LGPlayer lgp : getGame().getAlive())
|
for (LGPlayer lgp : getGame().getAlive())
|
||||||
if(lgp.getCache().getBoolean("assassin_protected"))
|
if (lgp.getCache().getBoolean("assassin_protected"))
|
||||||
lgp.getCache().remove("assassin_protected");
|
lgp.getCache().remove("assassin_protected");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onEndgameCheck(LGEndCheckEvent e) {
|
public void onEndgameCheck(LGEndCheckEvent e) {
|
||||||
if(e.getGame() == getGame() && e.getWinType() == LGWinType.SOLO) {
|
if (e.getGame() == getGame() && e.getWinType() == LGWinType.SOLO) {
|
||||||
if(getPlayers().size() > 0) {
|
if (getPlayers().size() > 0) {
|
||||||
if(getPlayers().size() > 1)
|
if (getPlayers().size() > 1)
|
||||||
for(LGPlayer lgp : getPlayers())
|
for (LGPlayer lgp : getPlayers())
|
||||||
if(!lgp.isRoleActive())
|
if (!lgp.isRoleActive())
|
||||||
return;
|
return;
|
||||||
e.setWinType(LGWinType.ASSASSIN);
|
e.setWinType(LGWinType.ASSASSIN);
|
||||||
}
|
}
|
||||||
|
@ -135,7 +138,7 @@ public class RAssassin extends Role{
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST)
|
@EventHandler(priority = EventPriority.HIGHEST)
|
||||||
public void onEndGame(LGGameEndEvent e) {
|
public void onEndGame(LGGameEndEvent e) {
|
||||||
if(e.getWinType() == LGWinType.ASSASSIN) {
|
if (e.getWinType() == LGWinType.ASSASSIN) {
|
||||||
e.getWinners().clear();
|
e.getWinners().clear();
|
||||||
e.getWinners().addAll(getPlayers());
|
e.getWinners().addAll(getPlayers());
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,55 +1,65 @@
|
||||||
package fr.leomelki.loupgarou.roles;
|
package fr.leomelki.loupgarou.roles;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.StringJoiner;
|
|
||||||
|
|
||||||
import org.bukkit.event.EventHandler;
|
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
|
||||||
|
|
||||||
import fr.leomelki.loupgarou.MainLg;
|
import fr.leomelki.loupgarou.MainLg;
|
||||||
import fr.leomelki.loupgarou.classes.LGGame;
|
import fr.leomelki.loupgarou.classes.LGGame;
|
||||||
import fr.leomelki.loupgarou.classes.LGPlayer;
|
import fr.leomelki.loupgarou.classes.LGPlayer;
|
||||||
import fr.leomelki.loupgarou.events.LGGameEndEvent;
|
import fr.leomelki.loupgarou.events.LGGameEndEvent;
|
||||||
import fr.leomelki.loupgarou.events.LGPlayerKilledEvent;
|
import fr.leomelki.loupgarou.events.LGPlayerKilledEvent;
|
||||||
import fr.leomelki.loupgarou.events.LGPlayerKilledEvent.Reason;
|
import fr.leomelki.loupgarou.events.LGPlayerKilledEvent.Reason;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.StringJoiner;
|
||||||
|
|
||||||
|
public class RBouffon extends Role {
|
||||||
|
final ArrayList<LGPlayer> needToPlay = new ArrayList<>();
|
||||||
|
|
||||||
public class RBouffon extends Role{
|
|
||||||
public RBouffon(LGGame game) {
|
public RBouffon(LGGame game) {
|
||||||
super(game);
|
super(game);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public RoleType getType() {
|
public RoleType getType() {
|
||||||
return RoleType.NEUTRAL;
|
return RoleType.NEUTRAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public RoleWinType getWinType() {
|
public RoleWinType getWinType() {
|
||||||
return RoleWinType.NONE;
|
return RoleWinType.NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return "§d§lBouffon";
|
return "§d§lBouffon";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getFriendlyName() {
|
public String getFriendlyName() {
|
||||||
return "du "+getName();
|
return "du " + getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getShortDescription() {
|
public String getShortDescription() {
|
||||||
return "Tu gagnes si tu remplis ton objectif";
|
return "Tu gagnes si tu remplis ton objectif";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getDescription() {
|
public String getDescription() {
|
||||||
return "Tu es §d§lNeutre§f et tu gagnes si tu remplis ton objectif. Ton objectif est d'être éliminé par le village lors de n’importe quel vote de jour. Si tu réussis, tu gagnes la partie, mais celle-ci continue. Tu pourras tuer l'une des personnes qui t'ont condamné.";
|
return "Tu es §d§lNeutre§f et tu gagnes si tu remplis ton objectif. Ton objectif est d'être éliminé par le village lors de n’importe quel vote de jour. Si tu réussis, tu gagnes la partie, mais celle-ci continue. Tu pourras tuer l'une des personnes qui t'ont condamné.";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getTask() {
|
public String getTask() {
|
||||||
return "Choisis quelqu’un à hanter parmi ceux qui ont voté pour ta mort.";
|
return "Choisis quelqu’un à hanter parmi ceux qui ont voté pour ta mort.";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getBroadcastedTask() {
|
public String getBroadcastedTask() {
|
||||||
return "L'esprit vengeur du "+getName()+"§9 rôde sur le village...";
|
return "L'esprit vengeur du " + getName() + "§9 rôde sur le village...";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getTimeout() {
|
public int getTimeout() {
|
||||||
return 15;
|
return 15;
|
||||||
|
@ -62,24 +72,26 @@ public class RBouffon extends Role{
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
getGame().cancelWait();
|
getGame().cancelWait();
|
||||||
if(players.size() == 0) {
|
if (players.size() == 0) {
|
||||||
onTurnFinish(callback);
|
onTurnFinish(callback);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
LGPlayer player = players.remove(0);
|
LGPlayer player = players.remove(0);
|
||||||
getGame().wait(getTimeout(), ()->{RBouffon.this.onNightTurnTimeout(player);this.run();}, (currentPlayer, secondsLeft)-> currentPlayer == player ? "§9§lC'est à ton tour !" : "§6C'est au tour "+getFriendlyName()+" §6(§e"+secondsLeft+" s§6)");
|
getGame().wait(getTimeout(), () -> {
|
||||||
player.sendMessage("§6"+getTask());
|
RBouffon.this.onNightTurnTimeout(player);
|
||||||
|
this.run();
|
||||||
|
}, (currentPlayer, secondsLeft) -> currentPlayer == player ? "§9§lC'est à ton tour !" : "§6C'est au tour " + getFriendlyName() + " §6(§e" + secondsLeft + " s§6)");
|
||||||
|
player.sendMessage("§6" + getTask());
|
||||||
// player.sendTitle("§6C'est à vous de jouer", "§a"+getTask(), 100);
|
// player.sendTitle("§6C'est à vous de jouer", "§a"+getTask(), 100);
|
||||||
onNightTurn(player, this);
|
onNightTurn(player, this);
|
||||||
}
|
}
|
||||||
}.run();
|
}.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasPlayersLeft() {
|
public boolean hasPlayersLeft() {
|
||||||
return needToPlay.size() > 0;
|
return needToPlay.size() > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onNightTurn(LGPlayer player, Runnable callback) {
|
protected void onNightTurn(LGPlayer player, Runnable callback) {
|
||||||
needToPlay.remove(player);
|
needToPlay.remove(player);
|
||||||
|
@ -87,25 +99,25 @@ public class RBouffon extends Role{
|
||||||
player.getCache().set("bouffon_win", true);
|
player.getCache().set("bouffon_win", true);
|
||||||
List<LGPlayer> choosable = getGame().getVote().getVotes(player);
|
List<LGPlayer> choosable = getGame().getVote().getVotes(player);
|
||||||
StringJoiner sj = new StringJoiner("§6§o, §6§o§l");
|
StringJoiner sj = new StringJoiner("§6§o, §6§o§l");
|
||||||
for(LGPlayer lgp : choosable)
|
for (LGPlayer lgp : choosable)
|
||||||
if(lgp.getPlayer() != null && lgp != player)
|
if (lgp.getPlayer() != null && lgp != player)
|
||||||
sj.add(lgp.getName());
|
sj.add(lgp.getName());
|
||||||
|
|
||||||
String toPut = sj.toString();
|
String toPut = sj.toString();
|
||||||
if(toPut.length() == 0)
|
if (toPut.length() == 0)
|
||||||
player.sendMessage("§6§o§lPersonne§6§o n'a voté pour toi.");
|
player.sendMessage("§6§o§lPersonne§6§o n'a voté pour toi.");
|
||||||
else
|
else
|
||||||
player.sendMessage("§6§o§l"+toPut+"§6§o "+(toPut.contains(",") ? "ont" : "a")+" voté pour toi.");
|
player.sendMessage("§6§o§l" + toPut + "§6§o " + (toPut.contains(",") ? "ont" : "a") + " voté pour toi.");
|
||||||
|
|
||||||
player.choose((choosen)->{
|
player.choose((choosen) -> {
|
||||||
if(choosen != null) {
|
if (choosen != null) {
|
||||||
if(!choosable.contains(choosen))
|
if (!choosable.contains(choosen))
|
||||||
player.sendMessage("§7§l"+choosen.getName()+"§4 n'a pas voté pour vous.");
|
player.sendMessage("§7§l" + choosen.getName() + "§4 n'a pas voté pour vous.");
|
||||||
else if(choosen.isDead())
|
else if (choosen.isDead())
|
||||||
player.sendMessage("§7§l"+choosen.getName()+"§4 est mort.");//fix
|
player.sendMessage("§7§l" + choosen.getName() + "§4 est mort.");//fix
|
||||||
else {
|
else {
|
||||||
player.stopChoosing();
|
player.stopChoosing();
|
||||||
player.sendMessage("§6Ton fantôme va hanter l'esprit de §7§l"+choosen.getName()+"§6.");
|
player.sendMessage("§6Ton fantôme va hanter l'esprit de §7§l" + choosen.getName() + "§6.");
|
||||||
getGame().kill(choosen, Reason.BOUFFON);
|
getGame().kill(choosen, Reason.BOUFFON);
|
||||||
player.hideView();
|
player.hideView();
|
||||||
callback.run();
|
callback.run();
|
||||||
|
@ -119,28 +131,26 @@ public class RBouffon extends Role{
|
||||||
player.stopChoosing();
|
player.stopChoosing();
|
||||||
}
|
}
|
||||||
|
|
||||||
final ArrayList<LGPlayer> needToPlay = new ArrayList<>();
|
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlayerKill(LGPlayerKilledEvent e) {
|
public void onPlayerKill(LGPlayerKilledEvent e) {
|
||||||
if(e.getKilled().getRole() == this && e.getReason() == Reason.VOTE && e.getKilled().isRoleActive()) {
|
if (e.getKilled().getRole() == this && e.getReason() == Reason.VOTE && e.getKilled().isRoleActive()) {
|
||||||
needToPlay.add(e.getKilled());
|
needToPlay.add(e.getKilled());
|
||||||
getGame().broadcastMessage("§9§oQuelle erreur, le "+getName()+"§9§o aura droit à sa vengeance...");
|
getGame().broadcastMessage("§9§oQuelle erreur, le " + getName() + "§9§o aura droit à sa vengeance...");
|
||||||
e.getKilled().sendMessage("§6Tu as rempli ta mission, l'heure de la vengeance a sonné.");
|
e.getKilled().sendMessage("§6Tu as rempli ta mission, l'heure de la vengeance a sonné.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onWin(LGGameEndEvent e) {
|
public void onWin(LGGameEndEvent e) {
|
||||||
if(e.getGame() == getGame())
|
if (e.getGame() == getGame())
|
||||||
for(LGPlayer lgp : getGame().getInGame())
|
for (LGPlayer lgp : getGame().getInGame())
|
||||||
if(lgp.getRole() == this && lgp.getCache().getBoolean("bouffon_win")) {
|
if (lgp.getRole() == this && lgp.getCache().getBoolean("bouffon_win")) {
|
||||||
e.getWinners().add(lgp);
|
e.getWinners().add(lgp);
|
||||||
new BukkitRunnable() {
|
new BukkitRunnable() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
getGame().broadcastMessage("§6§oLe "+getName()+"§6§o a rempli son objectif.");
|
getGame().broadcastMessage("§6§oLe " + getName() + "§6§o a rempli son objectif.");
|
||||||
}
|
}
|
||||||
}.runTaskAsynchronously(MainLg.getInstance());
|
}.runTaskAsynchronously(MainLg.getInstance());
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,51 +1,59 @@
|
||||||
package fr.leomelki.loupgarou.roles;
|
package fr.leomelki.loupgarou.roles;
|
||||||
|
|
||||||
import org.bukkit.event.EventHandler;
|
|
||||||
import org.bukkit.event.EventPriority;
|
|
||||||
|
|
||||||
import fr.leomelki.loupgarou.classes.LGGame;
|
import fr.leomelki.loupgarou.classes.LGGame;
|
||||||
import fr.leomelki.loupgarou.classes.LGPlayer;
|
import fr.leomelki.loupgarou.classes.LGPlayer;
|
||||||
import fr.leomelki.loupgarou.events.LGNightEndEvent;
|
import fr.leomelki.loupgarou.events.LGNightEndEvent;
|
||||||
import fr.leomelki.loupgarou.events.LGNightPlayerPreKilledEvent;
|
import fr.leomelki.loupgarou.events.LGNightPlayerPreKilledEvent;
|
||||||
import fr.leomelki.loupgarou.events.LGPlayerKilledEvent.Reason;
|
import fr.leomelki.loupgarou.events.LGPlayerKilledEvent.Reason;
|
||||||
import fr.leomelki.loupgarou.events.LGRoleTurnEndEvent;
|
import fr.leomelki.loupgarou.events.LGRoleTurnEndEvent;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.EventPriority;
|
||||||
|
|
||||||
public class RChaperonRouge extends Role{
|
public class RChaperonRouge extends Role {
|
||||||
public RChaperonRouge(LGGame game) {
|
public RChaperonRouge(LGGame game) {
|
||||||
super(game);
|
super(game);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public RoleType getType() {
|
public RoleType getType() {
|
||||||
return RoleType.VILLAGER;
|
return RoleType.VILLAGER;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public RoleWinType getWinType() {
|
public RoleWinType getWinType() {
|
||||||
return RoleWinType.VILLAGE;
|
return RoleWinType.VILLAGE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return "§a§lChaperon Rouge";
|
return "§a§lChaperon Rouge";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getFriendlyName() {
|
public String getFriendlyName() {
|
||||||
return "du "+getName();
|
return "du " + getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getShortDescription() {
|
public String getShortDescription() {
|
||||||
return "Tu gagnes avec le §a§lVillage";
|
return "Tu gagnes avec le §a§lVillage";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getDescription() {
|
public String getDescription() {
|
||||||
return "Tu gagnes avec le §a§lVillage§f. Tant que le §a§lChasseur§f est en vie, tu ne peux pas te faire tuer par les §c§lLoups§f pendant la nuit.";
|
return "Tu gagnes avec le §a§lVillage§f. Tant que le §a§lChasseur§f est en vie, tu ne peux pas te faire tuer par les §c§lLoups§f pendant la nuit.";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getTask() {
|
public String getTask() {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getBroadcastedTask() {
|
public String getBroadcastedTask() {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getTimeout() {
|
public int getTimeout() {
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -53,40 +61,42 @@ public class RChaperonRouge extends Role{
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.LOWEST)
|
@EventHandler(priority = EventPriority.LOWEST)
|
||||||
public void onKill(LGNightPlayerPreKilledEvent e) {
|
public void onKill(LGNightPlayerPreKilledEvent e) {
|
||||||
if(e.getKilled().getRole() == this && e.getReason() == Reason.LOUP_GAROU || e.getReason() == Reason.GM_LOUP_GAROU && e.getKilled().isRoleActive()) {
|
if (e.getKilled().getRole() == this && e.getReason() == Reason.LOUP_GAROU || e.getReason() == Reason.GM_LOUP_GAROU && e.getKilled().isRoleActive()) {
|
||||||
for(Role role : getGame().getRoles())
|
for (Role role : getGame().getRoles())
|
||||||
if(role instanceof RChasseur)
|
if (role instanceof RChasseur)
|
||||||
if(role.getPlayers().size() > 0){
|
if (role.getPlayers().size() > 0) {
|
||||||
e.getKilled().getCache().set("chaperon_kill", true);
|
e.getKilled().getCache().set("chaperon_kill", true);
|
||||||
e.setReason(Reason.DONT_DIE);
|
e.setReason(Reason.DONT_DIE);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onTour(LGRoleTurnEndEvent e) {
|
public void onTour(LGRoleTurnEndEvent e) {
|
||||||
if(e.getGame() == getGame()) {
|
if (e.getGame() == getGame()) {
|
||||||
if(e.getPreviousRole() instanceof RLoupGarou) {
|
if (e.getPreviousRole() instanceof RLoupGarou) {
|
||||||
for(LGPlayer lgp : getGame().getAlive())
|
for (LGPlayer lgp : getGame().getAlive())
|
||||||
if(lgp.getCache().getBoolean("chaperon_kill") && lgp.isRoleActive()) {
|
if (lgp.getCache().getBoolean("chaperon_kill") && lgp.isRoleActive()) {
|
||||||
for(LGPlayer l : getGame().getInGame())
|
for (LGPlayer l : getGame().getInGame())
|
||||||
if(l.getRoleType() == RoleType.LOUP_GAROU)
|
if (l.getRoleType() == RoleType.LOUP_GAROU)
|
||||||
l.sendMessage("§cVotre cible est immunisée.");
|
l.sendMessage("§cVotre cible est immunisée.");
|
||||||
}
|
}
|
||||||
}else if(e.getPreviousRole() instanceof RGrandMechantLoup) {
|
} else if (e.getPreviousRole() instanceof RGrandMechantLoup) {
|
||||||
for(LGPlayer lgp : getGame().getAlive())
|
for (LGPlayer lgp : getGame().getAlive())
|
||||||
if(lgp.getCache().getBoolean("chaperon_kill") && lgp.isRoleActive()) {
|
if (lgp.getCache().getBoolean("chaperon_kill") && lgp.isRoleActive()) {
|
||||||
for(LGPlayer l : e.getPreviousRole().getPlayers())
|
for (LGPlayer l : e.getPreviousRole().getPlayers())
|
||||||
l.sendMessage("§cVotre cible est immunisée.");
|
l.sendMessage("§cVotre cible est immunisée.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST)
|
@EventHandler(priority = EventPriority.HIGHEST)
|
||||||
public void onDayStart(LGNightEndEvent e) {
|
public void onDayStart(LGNightEndEvent e) {
|
||||||
if(e.getGame() == getGame()) {
|
if (e.getGame() == getGame()) {
|
||||||
for(LGPlayer lgp : getPlayers())
|
for (LGPlayer lgp : getPlayers())
|
||||||
if(lgp.getCache().getBoolean("chaperon_kill")) {
|
if (lgp.getCache().getBoolean("chaperon_kill")) {
|
||||||
lgp.getCache().remove("chaperon_kill");
|
lgp.getCache().remove("chaperon_kill");
|
||||||
lgp.sendMessage("§9§oTu as été attaqué cette nuit.");
|
lgp.sendMessage("§9§oTu as été attaqué cette nuit.");
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,5 @@
|
||||||
package fr.leomelki.loupgarou.roles;
|
package fr.leomelki.loupgarou.roles;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.event.EventHandler;
|
|
||||||
|
|
||||||
import fr.leomelki.loupgarou.classes.LGGame;
|
import fr.leomelki.loupgarou.classes.LGGame;
|
||||||
import fr.leomelki.loupgarou.classes.LGPlayer;
|
import fr.leomelki.loupgarou.classes.LGPlayer;
|
||||||
import fr.leomelki.loupgarou.events.LGDayStartEvent;
|
import fr.leomelki.loupgarou.events.LGDayStartEvent;
|
||||||
|
@ -12,43 +7,58 @@ import fr.leomelki.loupgarou.events.LGGameEndEvent;
|
||||||
import fr.leomelki.loupgarou.events.LGNightStart;
|
import fr.leomelki.loupgarou.events.LGNightStart;
|
||||||
import fr.leomelki.loupgarou.events.LGPlayerKilledEvent;
|
import fr.leomelki.loupgarou.events.LGPlayerKilledEvent;
|
||||||
import fr.leomelki.loupgarou.events.LGPlayerKilledEvent.Reason;
|
import fr.leomelki.loupgarou.events.LGPlayerKilledEvent.Reason;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
public class RChasseur extends Role {
|
||||||
|
final ArrayList<LGPlayer> needToPlay = new ArrayList<>();
|
||||||
|
|
||||||
public class RChasseur extends Role{
|
|
||||||
public RChasseur(LGGame game) {
|
public RChasseur(LGGame game) {
|
||||||
super(game);
|
super(game);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public RoleType getType() {
|
public RoleType getType() {
|
||||||
return RoleType.VILLAGER;
|
return RoleType.VILLAGER;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public RoleWinType getWinType() {
|
public RoleWinType getWinType() {
|
||||||
return RoleWinType.VILLAGE;
|
return RoleWinType.VILLAGE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return "§a§lChasseur";
|
return "§a§lChasseur";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getFriendlyName() {
|
public String getFriendlyName() {
|
||||||
return "du "+getName();
|
return "du " + getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getShortDescription() {
|
public String getShortDescription() {
|
||||||
return "Tu gagnes avec le §a§lVillage";
|
return "Tu gagnes avec le §a§lVillage";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getDescription() {
|
public String getDescription() {
|
||||||
return "Tu gagnes avec le §a§lVillage§f. À ta mort, tu dois éliminer un joueur en utilisant ta dernière balle.";
|
return "Tu gagnes avec le §a§lVillage§f. À ta mort, tu dois éliminer un joueur en utilisant ta dernière balle.";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getTask() {
|
public String getTask() {
|
||||||
return "Tu dois choisir qui va mourir avec toi.";
|
return "Tu dois choisir qui va mourir avec toi.";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getBroadcastedTask() {
|
public String getBroadcastedTask() {
|
||||||
return "Le "+getName()+"§9 choisit qui il va emporter avec lui.";
|
return "Le " + getName() + "§9 choisit qui il va emporter avec lui.";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getTimeout() {
|
public int getTimeout() {
|
||||||
return 15;
|
return 15;
|
||||||
|
@ -56,23 +66,23 @@ public class RChasseur extends Role{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onNightTurn(LGPlayer player, Runnable callback) {
|
protected void onNightTurn(LGPlayer player, Runnable callback) {
|
||||||
getGame().wait(getTimeout(), ()->{
|
getGame().wait(getTimeout(), () -> {
|
||||||
this.onNightTurnTimeout(player);
|
this.onNightTurnTimeout(player);
|
||||||
callback.run();
|
callback.run();
|
||||||
}, (currentPlayer, secondsLeft)-> currentPlayer == player ? "§9§lC'est à ton tour !" : "§6Le Chasseur choisit sa cible (§e"+secondsLeft+" s§6)");
|
}, (currentPlayer, secondsLeft) -> currentPlayer == player ? "§9§lC'est à ton tour !" : "§6Le Chasseur choisit sa cible (§e" + secondsLeft + " s§6)");
|
||||||
getGame().broadcastMessage("§9"+getBroadcastedTask());
|
getGame().broadcastMessage("§9" + getBroadcastedTask());
|
||||||
player.sendMessage("§6"+getTask());
|
player.sendMessage("§6" + getTask());
|
||||||
//player.sendTitle("§6C'est à vous de jouer", "§a"+getTask(), 60);
|
//player.sendTitle("§6C'est à vous de jouer", "§a"+getTask(), 60);
|
||||||
player.choose((choosen)->{
|
player.choose((choosen) -> {
|
||||||
if(choosen != null) {
|
if (choosen != null) {
|
||||||
player.stopChoosing();
|
player.stopChoosing();
|
||||||
getGame().cancelWait();
|
getGame().cancelWait();
|
||||||
LGPlayerKilledEvent killEvent = new LGPlayerKilledEvent(getGame(), choosen, Reason.CHASSEUR);
|
LGPlayerKilledEvent killEvent = new LGPlayerKilledEvent(getGame(), choosen, Reason.CHASSEUR);
|
||||||
Bukkit.getPluginManager().callEvent(killEvent);
|
Bukkit.getPluginManager().callEvent(killEvent);
|
||||||
if(killEvent.isCancelled())
|
if (killEvent.isCancelled())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if(getGame().kill(killEvent.getKilled(), killEvent.getReason(), true))
|
if (getGame().kill(killEvent.getKilled(), killEvent.getReason(), true))
|
||||||
return;
|
return;
|
||||||
callback.run();
|
callback.run();
|
||||||
}
|
}
|
||||||
|
@ -85,24 +95,23 @@ public class RChasseur extends Role{
|
||||||
player.stopChoosing();
|
player.stopChoosing();
|
||||||
}
|
}
|
||||||
|
|
||||||
final ArrayList<LGPlayer> needToPlay = new ArrayList<>();
|
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlayerKill(LGPlayerKilledEvent e) {
|
public void onPlayerKill(LGPlayerKilledEvent e) {
|
||||||
if(e.getKilled().getRole() == this && e.getReason() != Reason.DISCONNECTED && e.getKilled().isRoleActive())
|
if (e.getKilled().getRole() == this && e.getReason() != Reason.DISCONNECTED && e.getKilled().isRoleActive())
|
||||||
needToPlay.add(e.getKilled());
|
needToPlay.add(e.getKilled());
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onDayStart(LGDayStartEvent e) {
|
public void onDayStart(LGDayStartEvent e) {
|
||||||
if(e.getGame() != getGame())return;
|
if (e.getGame() != getGame()) return;
|
||||||
|
|
||||||
if(needToPlay.size() > 0)
|
if (needToPlay.size() > 0)
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
|
|
||||||
if(!e.isCancelled())return;
|
if (!e.isCancelled()) return;
|
||||||
new Runnable() {
|
new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
if(needToPlay.size() == 0) {
|
if (needToPlay.size() == 0) {
|
||||||
e.getGame().startDay();
|
e.getGame().startDay();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -114,15 +123,15 @@ public class RChasseur extends Role{
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onEndGame(LGGameEndEvent e) {
|
public void onEndGame(LGGameEndEvent e) {
|
||||||
if(e.getGame() != getGame())return;
|
if (e.getGame() != getGame()) return;
|
||||||
|
|
||||||
if(needToPlay.size() > 0)
|
if (needToPlay.size() > 0)
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
|
|
||||||
if(!e.isCancelled())return;
|
if (!e.isCancelled()) return;
|
||||||
new Runnable() {
|
new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
if(needToPlay.size() == 0) {
|
if (needToPlay.size() == 0) {
|
||||||
e.getGame().checkEndGame(true);
|
e.getGame().checkEndGame(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -155,12 +164,12 @@ public class RChasseur extends Role{
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onNight(LGNightStart e) {
|
public void onNight(LGNightStart e) {
|
||||||
if(e.getGame() == getGame() && !e.isCancelled()) {
|
if (e.getGame() == getGame() && !e.isCancelled()) {
|
||||||
if(needToPlay.size() > 0) {
|
if (needToPlay.size() > 0) {
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
new Runnable() {
|
new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
if(needToPlay.size() == 0) {
|
if (needToPlay.size() == 0) {
|
||||||
e.getGame().nextNight();
|
e.getGame().nextNight();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,50 +4,60 @@ import fr.leomelki.loupgarou.classes.LGGame;
|
||||||
import fr.leomelki.loupgarou.classes.LGPlayer;
|
import fr.leomelki.loupgarou.classes.LGPlayer;
|
||||||
import fr.leomelki.loupgarou.events.LGPlayerKilledEvent.Reason;
|
import fr.leomelki.loupgarou.events.LGPlayerKilledEvent.Reason;
|
||||||
|
|
||||||
public class RChasseurDeVampire extends Role{
|
public class RChasseurDeVampire extends Role {
|
||||||
public RChasseurDeVampire(LGGame game) {
|
public RChasseurDeVampire(LGGame game) {
|
||||||
super(game);
|
super(game);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public RoleType getType() {
|
public RoleType getType() {
|
||||||
return RoleType.VILLAGER;
|
return RoleType.VILLAGER;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public RoleWinType getWinType() {
|
public RoleWinType getWinType() {
|
||||||
return RoleWinType.VILLAGE;
|
return RoleWinType.VILLAGE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return "§a§lChasseur de Vampires";
|
return "§a§lChasseur de Vampires";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getFriendlyName() {
|
public String getFriendlyName() {
|
||||||
return "du "+getName();
|
return "du " + getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getShortDescription() {
|
public String getShortDescription() {
|
||||||
return "Tu gagnes avec le §a§lVillage";
|
return "Tu gagnes avec le §a§lVillage";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getDescription() {
|
public String getDescription() {
|
||||||
return "Tu gagnes avec le §a§lVillage§f. Chaque nuit, tu peux traquer un joueur pour découvrir s'il s'agit d'un Vampire. Si c'est le cas, tu le tueras dans son sommeil. Si les §5§lVampires§f te prennent pour cible, tu seras immunisé contre leur attaque, et tu tueras le plus jeune d'entre eux.";
|
return "Tu gagnes avec le §a§lVillage§f. Chaque nuit, tu peux traquer un joueur pour découvrir s'il s'agit d'un Vampire. Si c'est le cas, tu le tueras dans son sommeil. Si les §5§lVampires§f te prennent pour cible, tu seras immunisé contre leur attaque, et tu tueras le plus jeune d'entre eux.";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getTask() {
|
public String getTask() {
|
||||||
return "Choisis un joueur à pister.";
|
return "Choisis un joueur à pister.";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getBroadcastedTask() {
|
public String getBroadcastedTask() {
|
||||||
return "Le "+getName()+"§9 traque ses proies...";
|
return "Le " + getName() + "§9 traque ses proies...";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getTimeout() {
|
public int getTimeout() {
|
||||||
return 15;
|
return 15;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasPlayersLeft() {
|
public boolean hasPlayersLeft() {
|
||||||
for(LGPlayer lgp : getGame().getAlive())
|
for (LGPlayer lgp : getGame().getAlive())
|
||||||
if(lgp.getRoleType() == RoleType.VAMPIRE)
|
if (lgp.getRoleType() == RoleType.VAMPIRE)
|
||||||
return super.hasPlayersLeft();
|
return super.hasPlayersLeft();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -57,15 +67,15 @@ public class RChasseurDeVampire extends Role{
|
||||||
player.showView();
|
player.showView();
|
||||||
|
|
||||||
player.choose(choosen -> {
|
player.choose(choosen -> {
|
||||||
if(choosen != null && choosen != player) {
|
if (choosen != null && choosen != player) {
|
||||||
// player.sendMessage("§6Tu as choisi de rendre visite à §7§l"+choosen.getName()+"§6.");
|
// player.sendMessage("§6Tu as choisi de rendre visite à §7§l"+choosen.getName()+"§6.");
|
||||||
if(choosen.getCache().getBoolean("vampire") || choosen.getRole() instanceof RVampire) {
|
if (choosen.getCache().getBoolean("vampire") || choosen.getRole() instanceof RVampire) {
|
||||||
getGame().kill(choosen, Reason.CHASSEUR_DE_VAMPIRE);
|
getGame().kill(choosen, Reason.CHASSEUR_DE_VAMPIRE);
|
||||||
player.sendMessage("§7§l"+choosen.getName()+"§6 est un §5§lVampire§6, à l'attaque.");
|
player.sendMessage("§7§l" + choosen.getName() + "§6 est un §5§lVampire§6, à l'attaque.");
|
||||||
player.sendActionBarMessage("§e§l"+choosen.getName()+"§6 va mourir");
|
player.sendActionBarMessage("§e§l" + choosen.getName() + "§6 va mourir");
|
||||||
} else {
|
} else {
|
||||||
player.sendMessage("§7§l"+choosen.getName()+"§6 n'est pas un §5§lVampire§6...");
|
player.sendMessage("§7§l" + choosen.getName() + "§6 n'est pas un §5§lVampire§6...");
|
||||||
player.sendActionBarMessage("§e§l"+choosen.getName()+"§6 n'est pas un §5§lVampire");
|
player.sendActionBarMessage("§e§l" + choosen.getName() + "§6 n'est pas un §5§lVampire");
|
||||||
}
|
}
|
||||||
|
|
||||||
player.stopChoosing();
|
player.stopChoosing();
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
package fr.leomelki.loupgarou.roles;
|
package fr.leomelki.loupgarou.roles;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import fr.leomelki.loupgarou.MainLg;
|
||||||
import java.util.Collections;
|
import fr.leomelki.loupgarou.classes.LGGame;
|
||||||
|
import fr.leomelki.loupgarou.classes.LGPlayer;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.craftbukkit.v1_15_R1.inventory.CraftInventoryCustom;
|
import org.bukkit.craftbukkit.v1_15_R1.inventory.CraftInventoryCustom;
|
||||||
|
@ -15,12 +15,12 @@ import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.inventory.meta.ItemMeta;
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
|
||||||
import fr.leomelki.loupgarou.MainLg;
|
import java.util.Arrays;
|
||||||
import fr.leomelki.loupgarou.classes.LGGame;
|
import java.util.Collections;
|
||||||
import fr.leomelki.loupgarou.classes.LGPlayer;
|
|
||||||
|
|
||||||
public class RChienLoup extends Role{
|
public class RChienLoup extends Role {
|
||||||
static final ItemStack[] items = new ItemStack[9];
|
static final ItemStack[] items = new ItemStack[9];
|
||||||
|
|
||||||
static {
|
static {
|
||||||
items[3] = new ItemStack(Material.GOLDEN_APPLE);
|
items[3] = new ItemStack(Material.GOLDEN_APPLE);
|
||||||
ItemMeta meta = items[3].getItemMeta();
|
ItemMeta meta = items[3].getItemMeta();
|
||||||
|
@ -35,6 +35,10 @@ public class RChienLoup extends Role{
|
||||||
items[5].setItemMeta(meta);
|
items[5].setItemMeta(meta);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Runnable callback;
|
||||||
|
boolean already;
|
||||||
|
boolean inMenu;
|
||||||
|
|
||||||
public RChienLoup(LGGame game) {
|
public RChienLoup(LGGame game) {
|
||||||
super(game);
|
super(game);
|
||||||
}
|
}
|
||||||
|
@ -46,7 +50,7 @@ public class RChienLoup extends Role{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getFriendlyName() {
|
public String getFriendlyName() {
|
||||||
return "du "+getName();
|
return "du " + getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -66,12 +70,14 @@ public class RChienLoup extends Role{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getBroadcastedTask() {
|
public String getBroadcastedTask() {
|
||||||
return "Le "+getName()+"§9 pourrait trouver de nouveaux amis...";
|
return "Le " + getName() + "§9 pourrait trouver de nouveaux amis...";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public RoleType getType() {
|
public RoleType getType() {
|
||||||
return RoleType.VILLAGER;
|
return RoleType.VILLAGER;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public RoleWinType getWinType() {
|
public RoleWinType getWinType() {
|
||||||
return RoleWinType.VILLAGE;
|
return RoleWinType.VILLAGE;
|
||||||
|
@ -87,9 +93,6 @@ public class RChienLoup extends Role{
|
||||||
return super.hasPlayersLeft() && !already;
|
return super.hasPlayersLeft() && !already;
|
||||||
}
|
}
|
||||||
|
|
||||||
Runnable callback;
|
|
||||||
boolean already;
|
|
||||||
|
|
||||||
public void openInventory(Player player) {
|
public void openInventory(Player player) {
|
||||||
inMenu = true;
|
inMenu = true;
|
||||||
Inventory inventory = Bukkit.createInventory(null, 9, "§7Choisis ton camp.");
|
Inventory inventory = Bukkit.createInventory(null, 9, "§7Choisis ton camp.");
|
||||||
|
@ -97,6 +100,7 @@ public class RChienLoup extends Role{
|
||||||
player.closeInventory();
|
player.closeInventory();
|
||||||
player.openInventory(inventory);
|
player.openInventory(inventory);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onNightTurn(LGPlayer player, Runnable callback) {
|
protected void onNightTurn(LGPlayer player, Runnable callback) {
|
||||||
already = true;
|
already = true;
|
||||||
|
@ -104,6 +108,7 @@ public class RChienLoup extends Role{
|
||||||
this.callback = callback;
|
this.callback = callback;
|
||||||
openInventory(player.getPlayer());
|
openInventory(player.getPlayer());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onNightTurnTimeout(LGPlayer player) {
|
protected void onNightTurnTimeout(LGPlayer player) {
|
||||||
closeInventory(player.getPlayer());
|
closeInventory(player.getPlayer());
|
||||||
|
@ -113,28 +118,27 @@ public class RChienLoup extends Role{
|
||||||
player.sendMessage("§6Tu rejoins le §a§lVillage.");
|
player.sendMessage("§6Tu rejoins le §a§lVillage.");
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean inMenu;
|
|
||||||
|
|
||||||
private void closeInventory(Player p) {
|
private void closeInventory(Player p) {
|
||||||
inMenu = false;
|
inMenu = false;
|
||||||
p.closeInventory();
|
p.closeInventory();
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onInventoryClick(InventoryClickEvent e) {
|
public void onInventoryClick(InventoryClickEvent e) {
|
||||||
ItemStack item = e.getCurrentItem();
|
ItemStack item = e.getCurrentItem();
|
||||||
Player player = (Player)e.getWhoClicked();
|
Player player = (Player) e.getWhoClicked();
|
||||||
LGPlayer lgp = LGPlayer.thePlayer(getGame().getPlugin(), player);
|
LGPlayer lgp = LGPlayer.thePlayer(getGame().getPlugin(), player);
|
||||||
|
|
||||||
if(lgp.getRole() != this || item == null || item.getItemMeta() == null)return;
|
if (lgp.getRole() != this || item == null || item.getItemMeta() == null) return;
|
||||||
|
|
||||||
if(item.getItemMeta().getDisplayName().equals(items[3].getItemMeta().getDisplayName())) {
|
if (item.getItemMeta().getDisplayName().equals(items[3].getItemMeta().getDisplayName())) {
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
closeInventory(player);
|
closeInventory(player);
|
||||||
lgp.sendActionBarMessage("§6Tu resteras fidèle au §a§lVillage§6.");
|
lgp.sendActionBarMessage("§6Tu resteras fidèle au §a§lVillage§6.");
|
||||||
lgp.sendMessage("§6Tu resteras fidèle au §a§lVillage§6.");
|
lgp.sendMessage("§6Tu resteras fidèle au §a§lVillage§6.");
|
||||||
lgp.hideView();
|
lgp.hideView();
|
||||||
callback.run();
|
callback.run();
|
||||||
}else if(item.getItemMeta().getDisplayName().equals(items[5].getItemMeta().getDisplayName())) {
|
} else if (item.getItemMeta().getDisplayName().equals(items[5].getItemMeta().getDisplayName())) {
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
closeInventory(player);
|
closeInventory(player);
|
||||||
|
|
||||||
|
@ -143,11 +147,11 @@ public class RChienLoup extends Role{
|
||||||
|
|
||||||
//On le fait aussi rejoindre le camp des loups pour le tour pendant la nuit.
|
//On le fait aussi rejoindre le camp des loups pour le tour pendant la nuit.
|
||||||
RChienLoupLG lgChienLoup = null;
|
RChienLoupLG lgChienLoup = null;
|
||||||
for(Role role : getGame().getRoles())
|
for (Role role : getGame().getRoles())
|
||||||
if(role instanceof RChienLoupLG)
|
if (role instanceof RChienLoupLG)
|
||||||
lgChienLoup = (RChienLoupLG)role;
|
lgChienLoup = (RChienLoupLG) role;
|
||||||
|
|
||||||
if(lgChienLoup == null)
|
if (lgChienLoup == null)
|
||||||
getGame().getRoles().add(lgChienLoup = new RChienLoupLG(getGame()));
|
getGame().getRoles().add(lgChienLoup = new RChienLoupLG(getGame()));
|
||||||
|
|
||||||
lgChienLoup.join(lgp, false);
|
lgChienLoup.join(lgp, false);
|
||||||
|
@ -160,9 +164,9 @@ public class RChienLoup extends Role{
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onQuitInventory(InventoryCloseEvent e) {
|
public void onQuitInventory(InventoryCloseEvent e) {
|
||||||
if(e.getInventory() instanceof CraftInventoryCustom) {
|
if (e.getInventory() instanceof CraftInventoryCustom) {
|
||||||
LGPlayer player = LGPlayer.thePlayer(getGame().getPlugin(), (Player)e.getPlayer());
|
LGPlayer player = LGPlayer.thePlayer(getGame().getPlugin(), (Player) e.getPlayer());
|
||||||
if(player.getRole() == this && inMenu) {
|
if (player.getRole() == this && inMenu) {
|
||||||
new BukkitRunnable() {
|
new BukkitRunnable() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -1,26 +1,26 @@
|
||||||
package fr.leomelki.loupgarou.roles;
|
package fr.leomelki.loupgarou.roles;
|
||||||
|
|
||||||
import org.bukkit.potion.PotionEffectType;
|
|
||||||
|
|
||||||
import fr.leomelki.loupgarou.classes.LGCustomItems;
|
import fr.leomelki.loupgarou.classes.LGCustomItems;
|
||||||
import fr.leomelki.loupgarou.classes.LGGame;
|
import fr.leomelki.loupgarou.classes.LGGame;
|
||||||
import fr.leomelki.loupgarou.classes.LGPlayer;
|
import fr.leomelki.loupgarou.classes.LGPlayer;
|
||||||
|
import org.bukkit.potion.PotionEffectType;
|
||||||
|
|
||||||
public class RChienLoupLG extends Role{
|
public class RChienLoupLG extends Role {
|
||||||
public RChienLoupLG(LGGame game) {
|
public RChienLoupLG(LGGame game) {
|
||||||
super(game);
|
super(game);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
for(LGPlayer lgp : getPlayers())
|
for (LGPlayer lgp : getPlayers())
|
||||||
if(lgp.getPlayer() != null && lgp.getPlayer().hasPotionEffect(PotionEffectType.INVISIBILITY))
|
if (lgp.getPlayer() != null && lgp.getPlayer().hasPotionEffect(PotionEffectType.INVISIBILITY))
|
||||||
return "§c§lChien-Loup";
|
return "§c§lChien-Loup";
|
||||||
return (getPlayers().size() > 0 ? "§a" : "§c")+"§lChien-Loup";
|
return (getPlayers().size() > 0 ? "§a" : "§c") + "§lChien-Loup";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getFriendlyName() {
|
public String getFriendlyName() {
|
||||||
return "du "+getName();
|
return "du " + getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -40,12 +40,14 @@ public class RChienLoupLG extends Role{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getBroadcastedTask() {
|
public String getBroadcastedTask() {
|
||||||
return "Le "+getName()+"§9 pourrait trouver de nouveaux amis...";
|
return "Le " + getName() + "§9 pourrait trouver de nouveaux amis...";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public RoleType getType() {
|
public RoleType getType() {
|
||||||
return RoleType.LOUP_GAROU;
|
return RoleType.LOUP_GAROU;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public RoleWinType getWinType() {
|
public RoleWinType getWinType() {
|
||||||
return RoleWinType.LOUP_GAROU;
|
return RoleWinType.LOUP_GAROU;
|
||||||
|
@ -61,12 +63,12 @@ public class RChienLoupLG extends Role{
|
||||||
super.join(player, sendMessage);
|
super.join(player, sendMessage);
|
||||||
player.setRole(this);
|
player.setRole(this);
|
||||||
LGCustomItems.updateItem(player);
|
LGCustomItems.updateItem(player);
|
||||||
for(Role role : getGame().getRoles())
|
for (Role role : getGame().getRoles())
|
||||||
if(role instanceof RLoupGarou) {
|
if (role instanceof RLoupGarou) {
|
||||||
role.join(player, false);
|
role.join(player, false);
|
||||||
for(LGPlayer lgp : role.getPlayers())
|
for (LGPlayer lgp : role.getPlayers())
|
||||||
if(lgp != player)
|
if (lgp != player)
|
||||||
lgp.sendMessage("§7§l"+player.getName()+"§6 a rejoint les §c§lLoups-Garous§6.");
|
lgp.sendMessage("§7§l" + player.getName() + "§6 a rejoint les §c§lLoups-Garous§6.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,50 +1,58 @@
|
||||||
package fr.leomelki.loupgarou.roles;
|
package fr.leomelki.loupgarou.roles;
|
||||||
|
|
||||||
import org.bukkit.event.EventHandler;
|
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
|
||||||
|
|
||||||
import fr.leomelki.loupgarou.MainLg;
|
import fr.leomelki.loupgarou.MainLg;
|
||||||
import fr.leomelki.loupgarou.classes.LGGame;
|
import fr.leomelki.loupgarou.classes.LGGame;
|
||||||
import fr.leomelki.loupgarou.classes.LGPlayer;
|
import fr.leomelki.loupgarou.classes.LGPlayer;
|
||||||
import fr.leomelki.loupgarou.events.LGDayEndEvent;
|
import fr.leomelki.loupgarou.events.LGDayEndEvent;
|
||||||
import fr.leomelki.loupgarou.events.LGVoteEvent;
|
import fr.leomelki.loupgarou.events.LGVoteEvent;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
|
||||||
public class RCorbeau extends Role{
|
public class RCorbeau extends Role {
|
||||||
public RCorbeau(LGGame game) {
|
public RCorbeau(LGGame game) {
|
||||||
super(game);
|
super(game);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public RoleType getType() {
|
public RoleType getType() {
|
||||||
return RoleType.VILLAGER;
|
return RoleType.VILLAGER;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public RoleWinType getWinType() {
|
public RoleWinType getWinType() {
|
||||||
return RoleWinType.VILLAGE;
|
return RoleWinType.VILLAGE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return "§a§lCorbeau";
|
return "§a§lCorbeau";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getFriendlyName() {
|
public String getFriendlyName() {
|
||||||
return "du "+getName();
|
return "du " + getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getShortDescription() {
|
public String getShortDescription() {
|
||||||
return "Tu gagnes avec le §a§lVillage";
|
return "Tu gagnes avec le §a§lVillage";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getDescription() {
|
public String getDescription() {
|
||||||
return "Tu gagnes avec le §a§lVillage§f. Chaque nuit, tu peux désigner un joueur qui se retrouvera le lendemain avec deux voix contre lui au vote.";
|
return "Tu gagnes avec le §a§lVillage§f. Chaque nuit, tu peux désigner un joueur qui se retrouvera le lendemain avec deux voix contre lui au vote.";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getTask() {
|
public String getTask() {
|
||||||
return "Tu peux choisir un joueur qui aura deux votes contre lui.";
|
return "Tu peux choisir un joueur qui aura deux votes contre lui.";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getBroadcastedTask() {
|
public String getBroadcastedTask() {
|
||||||
return "Le "+getName()+"§9 s'apprête à diffamer quelqu'un...";
|
return "Le " + getName() + "§9 s'apprête à diffamer quelqu'un...";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getTimeout() {
|
public int getTimeout() {
|
||||||
return 15;
|
return 15;
|
||||||
|
@ -55,13 +63,13 @@ public class RCorbeau extends Role{
|
||||||
player.showView();
|
player.showView();
|
||||||
|
|
||||||
player.choose(choosen -> {
|
player.choose(choosen -> {
|
||||||
if(choosen != null && choosen != player) {
|
if (choosen != null && choosen != player) {
|
||||||
//player.sendTitle("§6Vous avez regardé un rôle", "§e§l"+choosen.getName()+"§6§l est §e§l"+choosen.getRole().getName(), 5*20);
|
//player.sendTitle("§6Vous avez regardé un rôle", "§e§l"+choosen.getName()+"§6§l est §e§l"+choosen.getRole().getName(), 5*20);
|
||||||
|
|
||||||
choosen.getCache().set("corbeau_selected", true);
|
choosen.getCache().set("corbeau_selected", true);
|
||||||
|
|
||||||
player.sendActionBarMessage("§e§l"+choosen.getName()+"§6 aura deux votes contre lui");
|
player.sendActionBarMessage("§e§l" + choosen.getName() + "§6 aura deux votes contre lui");
|
||||||
player.sendMessage("§6Tu nuis à la réputation de §7§l"+choosen.getName()+"§6.");
|
player.sendMessage("§6Tu nuis à la réputation de §7§l" + choosen.getName() + "§6.");
|
||||||
player.stopChoosing();
|
player.stopChoosing();
|
||||||
player.hideView();
|
player.hideView();
|
||||||
callback.run();
|
callback.run();
|
||||||
|
@ -71,16 +79,16 @@ public class RCorbeau extends Role{
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onNightStart(LGDayEndEvent e) {
|
public void onNightStart(LGDayEndEvent e) {
|
||||||
if(e.getGame() == getGame())
|
if (e.getGame() == getGame())
|
||||||
for(LGPlayer lgp : getGame().getAlive())
|
for (LGPlayer lgp : getGame().getAlive())
|
||||||
lgp.getCache().remove("corbeau_selected");
|
lgp.getCache().remove("corbeau_selected");
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onVoteStart(LGVoteEvent e) {
|
public void onVoteStart(LGVoteEvent e) {
|
||||||
if(e.getGame() == getGame())
|
if (e.getGame() == getGame())
|
||||||
for(LGPlayer lgp : getGame().getAlive())
|
for (LGPlayer lgp : getGame().getAlive())
|
||||||
if(lgp.getCache().getBoolean("corbeau_selected")) {
|
if (lgp.getCache().getBoolean("corbeau_selected")) {
|
||||||
lgp.getCache().remove("corbeau_selected");
|
lgp.getCache().remove("corbeau_selected");
|
||||||
new BukkitRunnable() {
|
new BukkitRunnable() {
|
||||||
|
|
||||||
|
@ -89,7 +97,7 @@ public class RCorbeau extends Role{
|
||||||
MainLg plugin = getGame().getPlugin();
|
MainLg plugin = getGame().getPlugin();
|
||||||
getGame().getVote().vote(new LGPlayer(plugin, "§a§lLe corbeau"), lgp);
|
getGame().getVote().vote(new LGPlayer(plugin, "§a§lLe corbeau"), lgp);
|
||||||
getGame().getVote().vote(new LGPlayer(plugin, "§a§lLe corbeau"), lgp);//fix
|
getGame().getVote().vote(new LGPlayer(plugin, "§a§lLe corbeau"), lgp);//fix
|
||||||
getGame().broadcastMessage("§7§l"+ lgp.getName()+"§6 a reçu la visite du "+getName()+"§6.");
|
getGame().broadcastMessage("§7§l" + lgp.getName() + "§6 a reçu la visite du " + getName() + "§6.");
|
||||||
}
|
}
|
||||||
}.runTask(MainLg.getInstance());
|
}.runTask(MainLg.getInstance());
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,16 @@
|
||||||
package fr.leomelki.loupgarou.roles;
|
package fr.leomelki.loupgarou.roles;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import com.comphenix.protocol.wrappers.EnumWrappers.ItemSlot;
|
||||||
import java.util.Arrays;
|
import com.comphenix.protocol.wrappers.WrappedDataWatcher;
|
||||||
|
import com.comphenix.protocol.wrappers.WrappedDataWatcher.WrappedDataWatcherObject;
|
||||||
|
import com.comphenix.protocol.wrappers.WrappedWatchableObject;
|
||||||
|
import fr.leomelki.com.comphenix.packetwrapper.*;
|
||||||
|
import fr.leomelki.loupgarou.MainLg;
|
||||||
|
import fr.leomelki.loupgarou.classes.LGGame;
|
||||||
|
import fr.leomelki.loupgarou.classes.LGPlayer;
|
||||||
|
import fr.leomelki.loupgarou.classes.LGWinType;
|
||||||
|
import fr.leomelki.loupgarou.events.*;
|
||||||
|
import fr.leomelki.loupgarou.events.LGPlayerKilledEvent.Reason;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
|
@ -13,68 +21,62 @@ import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
|
||||||
import com.comphenix.protocol.wrappers.EnumWrappers.ItemSlot;
|
import java.util.ArrayList;
|
||||||
import com.comphenix.protocol.wrappers.WrappedDataWatcher;
|
import java.util.Arrays;
|
||||||
import com.comphenix.protocol.wrappers.WrappedDataWatcher.WrappedDataWatcherObject;
|
|
||||||
import com.comphenix.protocol.wrappers.WrappedWatchableObject;
|
|
||||||
|
|
||||||
import fr.leomelki.com.comphenix.packetwrapper.WrapperPlayServerEntityDestroy;
|
public class RCupidon extends Role {
|
||||||
import fr.leomelki.com.comphenix.packetwrapper.WrapperPlayServerEntityEquipment;
|
final WrappedDataWatcherObject invisible = new WrappedDataWatcherObject(0, WrappedDataWatcher.Registry.get(Byte.class));
|
||||||
import fr.leomelki.com.comphenix.packetwrapper.WrapperPlayServerEntityLook;
|
final WrappedDataWatcherObject noGravity = new WrappedDataWatcherObject(5, WrappedDataWatcher.Registry.get(Boolean.class));
|
||||||
import fr.leomelki.com.comphenix.packetwrapper.WrapperPlayServerEntityMetadata;
|
|
||||||
import fr.leomelki.com.comphenix.packetwrapper.WrapperPlayServerSpawnEntityLiving;
|
|
||||||
import fr.leomelki.loupgarou.MainLg;
|
|
||||||
import fr.leomelki.loupgarou.classes.LGGame;
|
|
||||||
import fr.leomelki.loupgarou.classes.LGPlayer;
|
|
||||||
import fr.leomelki.loupgarou.classes.LGWinType;
|
|
||||||
import fr.leomelki.loupgarou.events.LGEndCheckEvent;
|
|
||||||
import fr.leomelki.loupgarou.events.LGGameEndEvent;
|
|
||||||
import fr.leomelki.loupgarou.events.LGPlayerGotKilledEvent;
|
|
||||||
import fr.leomelki.loupgarou.events.LGPlayerKilledEvent;
|
|
||||||
import fr.leomelki.loupgarou.events.LGPlayerKilledEvent.Reason;
|
|
||||||
import fr.leomelki.loupgarou.events.LGUpdatePrefixEvent;
|
|
||||||
|
|
||||||
public class RCupidon extends Role{
|
|
||||||
public RCupidon(LGGame game) {
|
public RCupidon(LGGame game) {
|
||||||
super(game);
|
super(game);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public RoleType getType() {
|
public RoleType getType() {
|
||||||
return RoleType.VILLAGER;
|
return RoleType.VILLAGER;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public RoleWinType getWinType() {
|
public RoleWinType getWinType() {
|
||||||
return RoleWinType.VILLAGE;
|
return RoleWinType.VILLAGE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return "§a§lCupidon";
|
return "§a§lCupidon";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getFriendlyName() {
|
public String getFriendlyName() {
|
||||||
return "de "+getName();
|
return "de " + getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getShortDescription() {
|
public String getShortDescription() {
|
||||||
return "Tu gagnes avec le §a§lVillage";
|
return "Tu gagnes avec le §a§lVillage";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getDescription() {
|
public String getDescription() {
|
||||||
return "Tu gagnes avec le §a§lVillage§f. Dès le début de la partie, tu dois former un couple de deux joueurs. Leur objectif sera de survivre ensemble, car si l'un d'eux meurt, l'autre se suicidera.";
|
return "Tu gagnes avec le §a§lVillage§f. Dès le début de la partie, tu dois former un couple de deux joueurs. Leur objectif sera de survivre ensemble, car si l'un d'eux meurt, l'autre se suicidera.";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getTask() {
|
public String getTask() {
|
||||||
return "Choisis deux joueurs à mettre en couple.";
|
return "Choisis deux joueurs à mettre en couple.";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getBroadcastedTask() {
|
public String getBroadcastedTask() {
|
||||||
return getName()+"§9 choisit deux âmes à unir.";
|
return getName() + "§9 choisit deux âmes à unir.";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getTimeout() {
|
public int getTimeout() {
|
||||||
return 15;
|
return 15;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasPlayersLeft() {
|
public boolean hasPlayersLeft() {
|
||||||
return getGame().getNight() == 1;
|
return getGame().getNight() == 1;
|
||||||
|
@ -85,23 +87,23 @@ public class RCupidon extends Role{
|
||||||
player.showView();
|
player.showView();
|
||||||
|
|
||||||
player.choose(choosen -> {
|
player.choose(choosen -> {
|
||||||
if(choosen != null) {
|
if (choosen != null) {
|
||||||
if(player.getCache().has("cupidon_first")) {
|
if (player.getCache().has("cupidon_first")) {
|
||||||
LGPlayer first = player.getCache().remove("cupidon_first");
|
LGPlayer first = player.getCache().remove("cupidon_first");
|
||||||
if(first == choosen) {
|
if (first == choosen) {
|
||||||
int entityId = Integer.MAX_VALUE-choosen.getPlayer().getEntityId();
|
int entityId = Integer.MAX_VALUE - choosen.getPlayer().getEntityId();
|
||||||
WrapperPlayServerEntityDestroy destroy = new WrapperPlayServerEntityDestroy();
|
WrapperPlayServerEntityDestroy destroy = new WrapperPlayServerEntityDestroy();
|
||||||
destroy.setEntityIds(new int[] {entityId});
|
destroy.setEntityIds(new int[]{entityId});
|
||||||
destroy.sendPacket(player.getPlayer());
|
destroy.sendPacket(player.getPlayer());
|
||||||
} else {
|
} else {
|
||||||
// sendHead(player, choosen);
|
// sendHead(player, choosen);
|
||||||
int entityId = Integer.MAX_VALUE-first.getPlayer().getEntityId();
|
int entityId = Integer.MAX_VALUE - first.getPlayer().getEntityId();
|
||||||
WrapperPlayServerEntityDestroy destroy = new WrapperPlayServerEntityDestroy();
|
WrapperPlayServerEntityDestroy destroy = new WrapperPlayServerEntityDestroy();
|
||||||
destroy.setEntityIds(new int[] {entityId});
|
destroy.setEntityIds(new int[]{entityId});
|
||||||
destroy.sendPacket(player.getPlayer());
|
destroy.sendPacket(player.getPlayer());
|
||||||
|
|
||||||
setInLove(first, choosen);
|
setInLove(first, choosen);
|
||||||
player.sendMessage("§7§l"+first.getName()+"§9 et §7§l"+choosen.getName()+"§9 sont désormais follement amoureux.");
|
player.sendMessage("§7§l" + first.getName() + "§9 et §7§l" + choosen.getName() + "§9 sont désormais follement amoureux.");
|
||||||
player.stopChoosing();
|
player.stopChoosing();
|
||||||
player.hideView();
|
player.hideView();
|
||||||
callback.run();
|
callback.run();
|
||||||
|
@ -113,13 +115,14 @@ public class RCupidon extends Role{
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void setInLove(LGPlayer player1, LGPlayer player2) {
|
protected void setInLove(LGPlayer player1, LGPlayer player2) {
|
||||||
player1.getCache().set("inlove", player2);
|
player1.getCache().set("inlove", player2);
|
||||||
player1.sendMessage("§9Tu tombes amoureux de §7§l"+player2.getName()+"§9, il est "+player2.getRole().getName());
|
player1.sendMessage("§9Tu tombes amoureux de §7§l" + player2.getName() + "§9, il est " + player2.getRole().getName());
|
||||||
player1.sendMessage("§9§oTu peux lui parler en mettant un §e!§9 devant ton message.");
|
player1.sendMessage("§9§oTu peux lui parler en mettant un §e!§9 devant ton message.");
|
||||||
|
|
||||||
player2.getCache().set("inlove", player1);
|
player2.getCache().set("inlove", player1);
|
||||||
player2.sendMessage("§9Tu tombes amoureux de §7§l"+player1.getName()+"§9, il est "+player1.getRole().getName());
|
player2.sendMessage("§9Tu tombes amoureux de §7§l" + player1.getName() + "§9, il est " + player1.getRole().getName());
|
||||||
player2.sendMessage("§9§oTu peux lui parler en mettant un §e!§9 devant ton message.");
|
player2.sendMessage("§9§oTu peux lui parler en mettant un §e!§9 devant ton message.");
|
||||||
|
|
||||||
/* sendHead(player1, player2);
|
/* sendHead(player1, player2);
|
||||||
|
@ -130,23 +133,21 @@ public class RCupidon extends Role{
|
||||||
player2.updatePrefix();
|
player2.updatePrefix();
|
||||||
}
|
}
|
||||||
|
|
||||||
final WrappedDataWatcherObject invisible = new WrappedDataWatcherObject(0, WrappedDataWatcher.Registry.get(Byte.class));
|
|
||||||
final WrappedDataWatcherObject noGravity = new WrappedDataWatcherObject(5, WrappedDataWatcher.Registry.get(Boolean.class));
|
|
||||||
protected void sendHead(LGPlayer to, LGPlayer ofWho) {
|
protected void sendHead(LGPlayer to, LGPlayer ofWho) {
|
||||||
int entityId = Integer.MAX_VALUE-ofWho.getPlayer().getEntityId();
|
int entityId = Integer.MAX_VALUE - ofWho.getPlayer().getEntityId();
|
||||||
WrapperPlayServerSpawnEntityLiving spawn = new WrapperPlayServerSpawnEntityLiving();
|
WrapperPlayServerSpawnEntityLiving spawn = new WrapperPlayServerSpawnEntityLiving();
|
||||||
spawn.setEntityID(entityId);
|
spawn.setEntityID(entityId);
|
||||||
spawn.setType(EntityType.DROPPED_ITEM);
|
spawn.setType(EntityType.DROPPED_ITEM);
|
||||||
//spawn.setMetadata(new WrappedDataWatcher(Arrays.asList(new WrappedWatchableObject(invisible, (byte)0x20), new WrappedWatchableObject(noGravity, true))));
|
//spawn.setMetadata(new WrappedDataWatcher(Arrays.asList(new WrappedWatchableObject(invisible, (byte)0x20), new WrappedWatchableObject(noGravity, true))));
|
||||||
Location loc = ofWho.getPlayer().getLocation();
|
Location loc = ofWho.getPlayer().getLocation();
|
||||||
spawn.setX(loc.getX());
|
spawn.setX(loc.getX());
|
||||||
spawn.setY(loc.getY()+1.9);
|
spawn.setY(loc.getY() + 1.9);
|
||||||
spawn.setZ(loc.getZ());
|
spawn.setZ(loc.getZ());
|
||||||
spawn.setHeadPitch(0);
|
spawn.setHeadPitch(0);
|
||||||
Location toLoc = to.getPlayer().getLocation();
|
Location toLoc = to.getPlayer().getLocation();
|
||||||
double diffX = loc.getX()-toLoc.getX(),
|
double diffX = loc.getX() - toLoc.getX(),
|
||||||
diffZ = loc.getZ()-toLoc.getZ();
|
diffZ = loc.getZ() - toLoc.getZ();
|
||||||
float yaw = 180-((float) Math.toDegrees(Math.atan2(diffX, diffZ)));
|
float yaw = 180 - ((float) Math.toDegrees(Math.atan2(diffX, diffZ)));
|
||||||
|
|
||||||
spawn.setYaw(yaw);
|
spawn.setYaw(yaw);
|
||||||
spawn.sendPacket(to.getPlayer());
|
spawn.sendPacket(to.getPlayer());
|
||||||
|
@ -159,11 +160,10 @@ public class RCupidon extends Role{
|
||||||
|
|
||||||
WrapperPlayServerEntityMetadata meta = new WrapperPlayServerEntityMetadata();
|
WrapperPlayServerEntityMetadata meta = new WrapperPlayServerEntityMetadata();
|
||||||
meta.setEntityID(entityId);
|
meta.setEntityID(entityId);
|
||||||
meta.setMetadata(Arrays.asList(new WrappedWatchableObject(invisible, (byte)0x20), new WrappedWatchableObject(noGravity, true)));
|
meta.setMetadata(Arrays.asList(new WrappedWatchableObject(invisible, (byte) 0x20), new WrappedWatchableObject(noGravity, true)));
|
||||||
meta.sendPacket(to.getPlayer());
|
meta.sendPacket(to.getPlayer());
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
new BukkitRunnable() {
|
new BukkitRunnable() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -190,39 +190,39 @@ public class RCupidon extends Role{
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlayerKill(LGPlayerGotKilledEvent e) {
|
public void onPlayerKill(LGPlayerGotKilledEvent e) {
|
||||||
if(e.getGame() == getGame() && e.getKilled().getCache().has("inlove") && !e.getKilled().getCache().<LGPlayer>get("inlove").isDead()) {
|
if (e.getGame() == getGame() && e.getKilled().getCache().has("inlove") && !e.getKilled().getCache().<LGPlayer>get("inlove").isDead()) {
|
||||||
LGPlayer killed = e.getKilled().getCache().get("inlove");
|
LGPlayer killed = e.getKilled().getCache().get("inlove");
|
||||||
LGPlayerKilledEvent event = new LGPlayerKilledEvent(getGame(), killed, Reason.LOVE);
|
LGPlayerKilledEvent event = new LGPlayerKilledEvent(getGame(), killed, Reason.LOVE);
|
||||||
Bukkit.getPluginManager().callEvent(event);
|
Bukkit.getPluginManager().callEvent(event);
|
||||||
if(!event.isCancelled())
|
if (!event.isCancelled())
|
||||||
getGame().kill(event.getKilled(), event.getReason(), false);
|
getGame().kill(event.getKilled(), event.getReason(), false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGH)
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
public void onGameEnd(LGGameEndEvent e) {
|
public void onGameEnd(LGGameEndEvent e) {
|
||||||
if(e.getGame() == getGame()) {
|
if (e.getGame() == getGame()) {
|
||||||
WrapperPlayServerEntityDestroy destroy = new WrapperPlayServerEntityDestroy();
|
WrapperPlayServerEntityDestroy destroy = new WrapperPlayServerEntityDestroy();
|
||||||
ArrayList<Integer> ids = new ArrayList<>();
|
ArrayList<Integer> ids = new ArrayList<>();
|
||||||
for(LGPlayer lgp : getGame().getInGame())
|
for (LGPlayer lgp : getGame().getInGame())
|
||||||
ids.add(Integer.MAX_VALUE-lgp.getPlayer().getEntityId());
|
ids.add(Integer.MAX_VALUE - lgp.getPlayer().getEntityId());
|
||||||
int[] intList = new int[ids.size()];
|
int[] intList = new int[ids.size()];
|
||||||
for(int i = 0;i<ids.size();i++)
|
for (int i = 0; i < ids.size(); i++)
|
||||||
intList[i] = ids.get(i);
|
intList[i] = ids.get(i);
|
||||||
destroy.setEntityIds(intList);
|
destroy.setEntityIds(intList);
|
||||||
for(LGPlayer lgp : getGame().getInGame())
|
for (LGPlayer lgp : getGame().getInGame())
|
||||||
destroy.sendPacket(lgp.getPlayer());
|
destroy.sendPacket(lgp.getPlayer());
|
||||||
|
|
||||||
for(LGPlayer lgp : getGame().getInGame())
|
for (LGPlayer lgp : getGame().getInGame())
|
||||||
if(lgp.getCache().has("inlove")) {
|
if (lgp.getCache().has("inlove")) {
|
||||||
if(e.getWinType() == LGWinType.COUPLE) {
|
if (e.getWinType() == LGWinType.COUPLE) {
|
||||||
if(!e.getWinners().contains(lgp))
|
if (!e.getWinners().contains(lgp))
|
||||||
e.getWinners().add(lgp);
|
e.getWinners().add(lgp);
|
||||||
} else {
|
} else {
|
||||||
LGPlayer player2 = lgp.getCache().get("inlove");
|
LGPlayer player2 = lgp.getCache().get("inlove");
|
||||||
boolean winEnCouple = (lgp.getRoleType() == RoleType.LOUP_GAROU) != (player2.getRoleType() == RoleType.LOUP_GAROU) || lgp.getRoleWinType() == RoleWinType.SEUL || player2.getRoleWinType() == RoleWinType.SEUL;
|
boolean winEnCouple = (lgp.getRoleType() == RoleType.LOUP_GAROU) != (player2.getRoleType() == RoleType.LOUP_GAROU) || lgp.getRoleWinType() == RoleWinType.SEUL || player2.getRoleWinType() == RoleWinType.SEUL;
|
||||||
if(winEnCouple) {
|
if (winEnCouple) {
|
||||||
System.out.println(lgp.getName()+" ne peut pas gagner car il était en couple !");
|
System.out.println(lgp.getName() + " ne peut pas gagner car il était en couple !");
|
||||||
e.getWinners().remove(lgp);
|
e.getWinners().remove(lgp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -232,16 +232,16 @@ public class RCupidon extends Role{
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onEndCheck(LGEndCheckEvent e) {
|
public void onEndCheck(LGEndCheckEvent e) {
|
||||||
if(e.getGame() == getGame()) {
|
if (e.getGame() == getGame()) {
|
||||||
ArrayList<LGPlayer> winners = new ArrayList<>();
|
ArrayList<LGPlayer> winners = new ArrayList<>();
|
||||||
for(LGPlayer lgp : getGame().getAlive())
|
for (LGPlayer lgp : getGame().getAlive())
|
||||||
if(lgp.getRoleWinType() != RoleWinType.NONE)
|
if (lgp.getRoleWinType() != RoleWinType.NONE)
|
||||||
winners.add(lgp);
|
winners.add(lgp);
|
||||||
if(winners.size() == 2) {
|
if (winners.size() == 2) {
|
||||||
LGPlayer player1 = winners.get(0),
|
LGPlayer player1 = winners.get(0),
|
||||||
player2 = winners.get(1);
|
player2 = winners.get(1);
|
||||||
boolean winEnCouple = (player1.getRoleType() == RoleType.LOUP_GAROU) != (player2.getRoleType() == RoleType.LOUP_GAROU) || player1.getRoleWinType() == RoleWinType.SEUL || player2.getRoleWinType() == RoleWinType.SEUL;
|
boolean winEnCouple = (player1.getRoleType() == RoleType.LOUP_GAROU) != (player2.getRoleType() == RoleType.LOUP_GAROU) || player1.getRoleWinType() == RoleWinType.SEUL || player2.getRoleWinType() == RoleWinType.SEUL;
|
||||||
if(player1.getCache().get("inlove") == player2 && /*player1.isABadGuy() != player2.isABadGuy()*/ (player1.getRoleType() == RoleType.LOUP_GAROU) != (player2.getRoleType() == RoleType.LOUP_GAROU))
|
if (player1.getCache().get("inlove") == player2 && /*player1.isABadGuy() != player2.isABadGuy()*/ (player1.getRoleType() == RoleType.LOUP_GAROU) != (player2.getRoleType() == RoleType.LOUP_GAROU))
|
||||||
e.setWinType(LGWinType.COUPLE);
|
e.setWinType(LGWinType.COUPLE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -250,22 +250,23 @@ public class RCupidon extends Role{
|
||||||
@EventHandler(priority = EventPriority.LOWEST)
|
@EventHandler(priority = EventPriority.LOWEST)
|
||||||
public void onChat(AsyncPlayerChatEvent e) {
|
public void onChat(AsyncPlayerChatEvent e) {
|
||||||
LGPlayer player = LGPlayer.thePlayer(getGame().getPlugin(), e.getPlayer());
|
LGPlayer player = LGPlayer.thePlayer(getGame().getPlugin(), e.getPlayer());
|
||||||
if(player.getGame() == getGame()) {
|
if (player.getGame() == getGame()) {
|
||||||
if(e.getMessage().startsWith("!")) {
|
if (e.getMessage().startsWith("!")) {
|
||||||
if(player.getCache().has("inlove")){
|
if (player.getCache().has("inlove")) {
|
||||||
player.sendMessage("§d\u2764 "+player.getName()+" §6» §f"+e.getMessage().substring(1));
|
player.sendMessage("§d\u2764 " + player.getName() + " §6» §f" + e.getMessage().substring(1));
|
||||||
player.getCache().<LGPlayer>get("inlove").sendMessage("§d\u2764 "+player.getName()+" §6» §f"+e.getMessage().substring(1));
|
player.getCache().<LGPlayer>get("inlove").sendMessage("§d\u2764 " + player.getName() + " §6» §f" + e.getMessage().substring(1));
|
||||||
}else
|
} else
|
||||||
player.sendMessage("§4Erreur : §cVous n'êtes pas en couple !");
|
player.sendMessage("§4Erreur : §cVous n'êtes pas en couple !");
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGH)
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
public void onUpdatePrefix (LGUpdatePrefixEvent e) {
|
public void onUpdatePrefix(LGUpdatePrefixEvent e) {
|
||||||
if(e.getGame() == getGame())
|
if (e.getGame() == getGame())
|
||||||
if(e.getTo().getCache().get("inlove") == e.getPlayer() || ((e.getTo() == e.getPlayer() || e.getTo().getRole() == this) && e.getPlayer().getCache().has("inlove")))
|
if (e.getTo().getCache().get("inlove") == e.getPlayer() || ((e.getTo() == e.getPlayer() || e.getTo().getRole() == this) && e.getPlayer().getCache().has("inlove")))
|
||||||
e.setPrefix("§d\u2764 §f"+e.getPrefix());
|
e.setPrefix("§d\u2764 §f" + e.getPrefix());
|
||||||
}
|
}
|
||||||
|
|
||||||
/* @EventHandler
|
/* @EventHandler
|
||||||
|
|
|
@ -3,66 +3,75 @@ package fr.leomelki.loupgarou.roles;
|
||||||
import fr.leomelki.loupgarou.classes.LGGame;
|
import fr.leomelki.loupgarou.classes.LGGame;
|
||||||
import fr.leomelki.loupgarou.classes.LGPlayer;
|
import fr.leomelki.loupgarou.classes.LGPlayer;
|
||||||
|
|
||||||
public class RDetective extends Role{
|
public class RDetective extends Role {
|
||||||
public RDetective(LGGame game) {
|
public RDetective(LGGame game) {
|
||||||
super(game);
|
super(game);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public RoleType getType() {
|
public RoleType getType() {
|
||||||
return RoleType.VILLAGER;
|
return RoleType.VILLAGER;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public RoleWinType getWinType() {
|
public RoleWinType getWinType() {
|
||||||
return RoleWinType.VILLAGE;
|
return RoleWinType.VILLAGE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return "§a§lDétective";
|
return "§a§lDétective";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getFriendlyName() {
|
public String getFriendlyName() {
|
||||||
return "du "+getName();
|
return "du " + getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getShortDescription() {
|
public String getShortDescription() {
|
||||||
return "Tu gagnes avec le §a§lVillage";
|
return "Tu gagnes avec le §a§lVillage";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getDescription() {
|
public String getDescription() {
|
||||||
return "Tu gagnes avec le §a§lVillage§f. Chaque nuit, tu mènes l'enquête sur deux joueurs pour découvrir s'ils font partie du même camp.";
|
return "Tu gagnes avec le §a§lVillage§f. Chaque nuit, tu mènes l'enquête sur deux joueurs pour découvrir s'ils font partie du même camp.";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getTask() {
|
public String getTask() {
|
||||||
return "Choisis deux joueurs à étudier.";
|
return "Choisis deux joueurs à étudier.";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getBroadcastedTask() {
|
public String getBroadcastedTask() {
|
||||||
return "Le "+getName()+"§9 est sur une enquête...";
|
return "Le " + getName() + "§9 est sur une enquête...";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getTimeout() {
|
public int getTimeout() {
|
||||||
return 15;
|
return 15;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onNightTurn(LGPlayer player, Runnable callback) {
|
protected void onNightTurn(LGPlayer player, Runnable callback) {
|
||||||
player.showView();
|
player.showView();
|
||||||
|
|
||||||
player.choose(choosen -> {
|
player.choose(choosen -> {
|
||||||
if(choosen != null) {
|
if (choosen != null) {
|
||||||
if(choosen == player) {
|
if (choosen == player) {
|
||||||
player.sendMessage("§cVous ne pouvez pas vous sélectionner !");
|
player.sendMessage("§cVous ne pouvez pas vous sélectionner !");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(player.getCache().has("detective_first")) {
|
if (player.getCache().has("detective_first")) {
|
||||||
LGPlayer first = player.getCache().remove("detective_first");
|
LGPlayer first = player.getCache().remove("detective_first");
|
||||||
if(first == choosen) {
|
if (first == choosen) {
|
||||||
player.sendMessage("§cVous ne pouvez pas comparer §7§l"+first.getName()+"§c avec lui même !");
|
player.sendMessage("§cVous ne pouvez pas comparer §7§l" + first.getName() + "§c avec lui même !");
|
||||||
} else {
|
} else {
|
||||||
if((first.getRoleType() == RoleType.NEUTRAL || choosen.getRoleType() == RoleType.NEUTRAL) ? first.getRole().getClass() == choosen.getRole().getClass() : first.getRoleType() == choosen.getRoleType())
|
if ((first.getRoleType() == RoleType.NEUTRAL || choosen.getRoleType() == RoleType.NEUTRAL) ? first.getRole().getClass() == choosen.getRole().getClass() : first.getRoleType() == choosen.getRoleType())
|
||||||
player.sendMessage("§7§l"+first.getName()+"§6 et §7§l"+choosen.getName()+"§6 sont §adu même camp.");
|
player.sendMessage("§7§l" + first.getName() + "§6 et §7§l" + choosen.getName() + "§6 sont §adu même camp.");
|
||||||
else
|
else
|
||||||
player.sendMessage("§7§l"+first.getName()+"§6 et §7§l"+choosen.getName()+"§6 ne sont §cpas du même camp.");
|
player.sendMessage("§7§l" + first.getName() + "§6 et §7§l" + choosen.getName() + "§6 ne sont §cpas du même camp.");
|
||||||
|
|
||||||
player.stopChoosing();
|
player.stopChoosing();
|
||||||
player.hideView();
|
player.hideView();
|
||||||
|
@ -70,7 +79,7 @@ public class RDetective extends Role{
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
player.getCache().set("detective_first", choosen);
|
player.getCache().set("detective_first", choosen);
|
||||||
player.sendMessage("§9Choisis un joueur avec qui tu souhaites comparer le rôle de §7§l"+choosen.getName());
|
player.sendMessage("§9Choisis un joueur avec qui tu souhaites comparer le rôle de §7§l" + choosen.getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,10 +1,14 @@
|
||||||
package fr.leomelki.loupgarou.roles;
|
package fr.leomelki.loupgarou.roles;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import fr.leomelki.com.comphenix.packetwrapper.WrapperPlayServerHeldItemSlot;
|
||||||
import java.util.Arrays;
|
import fr.leomelki.loupgarou.MainLg;
|
||||||
import java.util.Collections;
|
import fr.leomelki.loupgarou.classes.LGGame;
|
||||||
import java.util.Iterator;
|
import fr.leomelki.loupgarou.classes.LGPlayer;
|
||||||
|
import fr.leomelki.loupgarou.events.LGDayEndEvent;
|
||||||
|
import fr.leomelki.loupgarou.events.LGMayorVoteEvent;
|
||||||
|
import fr.leomelki.loupgarou.events.LGPlayerKilledEvent;
|
||||||
|
import fr.leomelki.loupgarou.events.LGPlayerKilledEvent.Reason;
|
||||||
|
import fr.leomelki.loupgarou.events.LGVoteEvent;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.craftbukkit.v1_15_R1.inventory.CraftInventoryCustom;
|
import org.bukkit.craftbukkit.v1_15_R1.inventory.CraftInventoryCustom;
|
||||||
|
@ -19,19 +23,15 @@ import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.inventory.meta.ItemMeta;
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
|
||||||
import fr.leomelki.com.comphenix.packetwrapper.WrapperPlayServerHeldItemSlot;
|
import java.util.ArrayList;
|
||||||
import fr.leomelki.loupgarou.MainLg;
|
import java.util.Arrays;
|
||||||
import fr.leomelki.loupgarou.classes.LGGame;
|
import java.util.Collections;
|
||||||
import fr.leomelki.loupgarou.classes.LGPlayer;
|
import java.util.Iterator;
|
||||||
import fr.leomelki.loupgarou.events.LGDayEndEvent;
|
|
||||||
import fr.leomelki.loupgarou.events.LGMayorVoteEvent;
|
|
||||||
import fr.leomelki.loupgarou.events.LGPlayerKilledEvent;
|
|
||||||
import fr.leomelki.loupgarou.events.LGPlayerKilledEvent.Reason;
|
|
||||||
import fr.leomelki.loupgarou.events.LGVoteEvent;
|
|
||||||
|
|
||||||
public class RDictateur extends Role{
|
public class RDictateur extends Role {
|
||||||
static private final ItemStack[] items = new ItemStack[9];
|
static private final ItemStack[] items = new ItemStack[9];
|
||||||
static private final Inventory inventory;
|
static private final Inventory inventory;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
items[3] = new ItemStack(Material.IRON_NUGGET);
|
items[3] = new ItemStack(Material.IRON_NUGGET);
|
||||||
ItemMeta meta = items[3].getItemMeta();
|
ItemMeta meta = items[3].getItemMeta();
|
||||||
|
@ -51,40 +51,52 @@ public class RDictateur extends Role{
|
||||||
inventory = Bukkit.createInventory(null, 9, "§7Veux-tu faire un coup d'état ?");
|
inventory = Bukkit.createInventory(null, 9, "§7Veux-tu faire un coup d'état ?");
|
||||||
inventory.setContents(items.clone());
|
inventory.setContents(items.clone());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Runnable callback, run;
|
||||||
|
boolean inMenu = false;
|
||||||
|
|
||||||
public RDictateur(LGGame game) {
|
public RDictateur(LGGame game) {
|
||||||
super(game);
|
super(game);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public RoleType getType() {
|
public RoleType getType() {
|
||||||
return RoleType.VILLAGER;
|
return RoleType.VILLAGER;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public RoleWinType getWinType() {
|
public RoleWinType getWinType() {
|
||||||
return RoleWinType.VILLAGE;
|
return RoleWinType.VILLAGE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return "§a§lDictateur";
|
return "§a§lDictateur";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getFriendlyName() {
|
public String getFriendlyName() {
|
||||||
return "du "+getName();
|
return "du " + getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getShortDescription() {
|
public String getShortDescription() {
|
||||||
return "Tu gagnes avec le §a§lVillage";
|
return "Tu gagnes avec le §a§lVillage";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getDescription() {
|
public String getDescription() {
|
||||||
return "Tu gagnes avec le §a§lVillage§f. Une fois dans la partie, tu peux choisir d'effectuer un §e§o§lcoup d'état§f, tu choisiras alors seul qui mourra au jour suivant. Si tu fais le bon choix, tu deviendras §5§lCapitaine§f mais si tu tues un §a§lVillageois§f, tu te suicideras la nuit qui suit.";
|
return "Tu gagnes avec le §a§lVillage§f. Une fois dans la partie, tu peux choisir d'effectuer un §e§o§lcoup d'état§f, tu choisiras alors seul qui mourra au jour suivant. Si tu fais le bon choix, tu deviendras §5§lCapitaine§f mais si tu tues un §a§lVillageois§f, tu te suicideras la nuit qui suit.";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getTask() {
|
public String getTask() {
|
||||||
return "Veux-tu réaliser un coup d'état ?";
|
return "Veux-tu réaliser un coup d'état ?";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getBroadcastedTask() {
|
public String getBroadcastedTask() {
|
||||||
return "Le "+getName()+"§9 décide s'il veut se dévoiler.";
|
return "Le " + getName() + "§9 décide s'il veut se dévoiler.";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -97,13 +109,14 @@ public class RDictateur extends Role{
|
||||||
player.closeInventory();
|
player.closeInventory();
|
||||||
player.openInventory(inventory);
|
player.openInventory(inventory);
|
||||||
}
|
}
|
||||||
Runnable callback, run;
|
|
||||||
@Override
|
@Override
|
||||||
protected void onNightTurn(LGPlayer player, Runnable callback) {
|
protected void onNightTurn(LGPlayer player, Runnable callback) {
|
||||||
player.showView();
|
player.showView();
|
||||||
this.callback = callback;
|
this.callback = callback;
|
||||||
openInventory(player.getPlayer());
|
openInventory(player.getPlayer());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onNightTurnTimeout(LGPlayer player) {
|
protected void onNightTurnTimeout(LGPlayer player) {
|
||||||
player.hideView();
|
player.hideView();
|
||||||
|
@ -113,28 +126,27 @@ public class RDictateur extends Role{
|
||||||
player.sendMessage("§7§oVous aurez de nouveau le choix lors de la prochaine nuit.");*/
|
player.sendMessage("§7§oVous aurez de nouveau le choix lors de la prochaine nuit.");*/
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean inMenu = false;
|
|
||||||
|
|
||||||
private void closeInventory(Player p) {
|
private void closeInventory(Player p) {
|
||||||
inMenu = false;
|
inMenu = false;
|
||||||
p.closeInventory();
|
p.closeInventory();
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onInventoryClick(InventoryClickEvent e) {
|
public void onInventoryClick(InventoryClickEvent e) {
|
||||||
ItemStack item = e.getCurrentItem();
|
ItemStack item = e.getCurrentItem();
|
||||||
Player player = (Player)e.getWhoClicked();
|
Player player = (Player) e.getWhoClicked();
|
||||||
LGPlayer lgp = LGPlayer.thePlayer(getGame().getPlugin(), player);
|
LGPlayer lgp = LGPlayer.thePlayer(getGame().getPlugin(), player);
|
||||||
|
|
||||||
if(lgp.getRole() != this || item == null || item.getItemMeta() == null)return;
|
if (lgp.getRole() != this || item == null || item.getItemMeta() == null) return;
|
||||||
|
|
||||||
if(item.getItemMeta().getDisplayName().equals(items[3].getItemMeta().getDisplayName())) {
|
if (item.getItemMeta().getDisplayName().equals(items[3].getItemMeta().getDisplayName())) {
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
closeInventory(player);
|
closeInventory(player);
|
||||||
/*lgp.sendMessage("§cVous ne faites pas votre coup d'état.");
|
/*lgp.sendMessage("§cVous ne faites pas votre coup d'état.");
|
||||||
lgp.sendMessage("§7§oVous aurez de nouveau le choix lors de la prochaine nuit.");*/
|
lgp.sendMessage("§7§oVous aurez de nouveau le choix lors de la prochaine nuit.");*/
|
||||||
lgp.hideView();
|
lgp.hideView();
|
||||||
callback.run();
|
callback.run();
|
||||||
}else if(item.getItemMeta().getDisplayName().equals(items[5].getItemMeta().getDisplayName())) {
|
} else if (item.getItemMeta().getDisplayName().equals(items[5].getItemMeta().getDisplayName())) {
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
closeInventory(player);
|
closeInventory(player);
|
||||||
lgp.sendActionBarMessage("§9§lTu effectueras un coup d'état");
|
lgp.sendActionBarMessage("§9§lTu effectueras un coup d'état");
|
||||||
|
@ -150,21 +162,21 @@ public class RDictateur extends Role{
|
||||||
public void onClick(PlayerInteractEvent e) {
|
public void onClick(PlayerInteractEvent e) {
|
||||||
Player p = e.getPlayer();
|
Player p = e.getPlayer();
|
||||||
LGPlayer player = LGPlayer.thePlayer(getGame().getPlugin(), p);
|
LGPlayer player = LGPlayer.thePlayer(getGame().getPlugin(), p);
|
||||||
if(e.getItem() != null && e.getItem().getType() == Material.IRON_NUGGET && player.getRole() == this) {
|
if (e.getItem() != null && e.getItem().getType() == Material.IRON_NUGGET && player.getRole() == this) {
|
||||||
getGame().cancelWait();
|
getGame().cancelWait();
|
||||||
player.stopChoosing();
|
player.stopChoosing();
|
||||||
p.getInventory().setItem(8, null);
|
p.getInventory().setItem(8, null);
|
||||||
p.updateInventory();
|
p.updateInventory();
|
||||||
getGame().broadcastMessage("§7§l"+player.getName()+"§9 n'a tué personne.");
|
getGame().broadcastMessage("§7§l" + player.getName() + "§9 n'a tué personne.");
|
||||||
run.run();
|
run.run();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onQuitInventory(InventoryCloseEvent e) {
|
public void onQuitInventory(InventoryCloseEvent e) {
|
||||||
if(e.getInventory() instanceof CraftInventoryCustom) {
|
if (e.getInventory() instanceof CraftInventoryCustom) {
|
||||||
LGPlayer player = LGPlayer.thePlayer(getGame().getPlugin(), (Player)e.getPlayer());
|
LGPlayer player = LGPlayer.thePlayer(getGame().getPlugin(), (Player) e.getPlayer());
|
||||||
if(player.getRole() == this && inMenu) {
|
if (player.getRole() == this && inMenu) {
|
||||||
new BukkitRunnable() {
|
new BukkitRunnable() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -178,33 +190,34 @@ public class RDictateur extends Role{
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onMayorVote(LGMayorVoteEvent e) {
|
public void onMayorVote(LGMayorVoteEvent e) {
|
||||||
if(e.getGame() == getGame())
|
if (e.getGame() == getGame())
|
||||||
onTurn(e);
|
onTurn(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onVote(LGVoteEvent e) {
|
public void onVote(LGVoteEvent e) {
|
||||||
if(e.getGame() == getGame())
|
if (e.getGame() == getGame())
|
||||||
onTurn(e);
|
onTurn(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onTurn(Cancellable e) {
|
public void onTurn(Cancellable e) {
|
||||||
for(LGPlayer lgp : getPlayers())
|
for (LGPlayer lgp : getPlayers())
|
||||||
if(lgp.getCache().getBoolean("just_coup_d_etat") && lgp.isRoleActive())
|
if (lgp.getCache().getBoolean("just_coup_d_etat") && lgp.isRoleActive())
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
|
|
||||||
if(!e.isCancelled())
|
if (!e.isCancelled())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Iterator<LGPlayer> ite = ((ArrayList<LGPlayer>)getPlayers().clone()).iterator();
|
Iterator<LGPlayer> ite = ((ArrayList<LGPlayer>) getPlayers().clone()).iterator();
|
||||||
new Runnable() {
|
new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
run = this;
|
run = this;
|
||||||
if(ite.hasNext()) {
|
if (ite.hasNext()) {
|
||||||
LGPlayer lgp = ite.next();
|
LGPlayer lgp = ite.next();
|
||||||
if(lgp.getCache().getBoolean("just_coup_d_etat")) {
|
if (lgp.getCache().getBoolean("just_coup_d_etat")) {
|
||||||
getPlayers().remove(lgp);
|
getPlayers().remove(lgp);
|
||||||
lgp.getCache().remove("just_coup_d_etat");
|
lgp.getCache().remove("just_coup_d_etat");
|
||||||
getGame().broadcastMessage("§7§l"+lgp.getName()+" §9réalise un coup d'état.");
|
getGame().broadcastMessage("§7§l" + lgp.getName() + " §9réalise un coup d'état.");
|
||||||
//lgp.sendTitle("§6Vous faites votre coup d'état", "§aChoisissez qui tuer", 60);
|
//lgp.sendTitle("§6Vous faites votre coup d'état", "§aChoisissez qui tuer", 60);
|
||||||
|
|
||||||
//On le met sur le slot 0 pour éviter un missclick sur la croix
|
//On le met sur le slot 0 pour éviter un missclick sur la croix
|
||||||
|
@ -213,15 +226,15 @@ public class RDictateur extends Role{
|
||||||
hold.sendPacket(lgp.getPlayer());
|
hold.sendPacket(lgp.getPlayer());
|
||||||
|
|
||||||
lgp.sendMessage("§6Choisis un joueur à exécuter.");
|
lgp.sendMessage("§6Choisis un joueur à exécuter.");
|
||||||
getGame().wait(60, ()->{
|
getGame().wait(60, () -> {
|
||||||
lgp.stopChoosing();
|
lgp.stopChoosing();
|
||||||
getGame().broadcastMessage("§7§l"+lgp.getName()+"§9 n'a tué personne.");
|
getGame().broadcastMessage("§7§l" + lgp.getName() + "§9 n'a tué personne.");
|
||||||
lgp.getPlayer().getInventory().setItem(8, null);
|
lgp.getPlayer().getInventory().setItem(8, null);
|
||||||
lgp.getPlayer().updateInventory();
|
lgp.getPlayer().updateInventory();
|
||||||
this.run();
|
this.run();
|
||||||
}, (player, secondsLeft)-> lgp == player ? "§9§lC'est à ton tour !" : "§6Le Dictateur choisit sa victime (§e"+secondsLeft+" s§6)");
|
}, (player, secondsLeft) -> lgp == player ? "§9§lC'est à ton tour !" : "§6Le Dictateur choisit sa victime (§e" + secondsLeft + " s§6)");
|
||||||
lgp.choose((choosen)->{
|
lgp.choose((choosen) -> {
|
||||||
if(choosen != null) {
|
if (choosen != null) {
|
||||||
getGame().cancelWait();
|
getGame().cancelWait();
|
||||||
lgp.stopChoosing();
|
lgp.stopChoosing();
|
||||||
lgp.getPlayer().getInventory().setItem(8, null);
|
lgp.getPlayer().getInventory().setItem(8, null);
|
||||||
|
@ -232,30 +245,31 @@ public class RDictateur extends Role{
|
||||||
lgp.getPlayer().getInventory().setItem(8, items[3]);
|
lgp.getPlayer().getInventory().setItem(8, items[3]);
|
||||||
lgp.getPlayer().updateInventory();
|
lgp.getPlayer().updateInventory();
|
||||||
}
|
}
|
||||||
}else
|
} else
|
||||||
getGame().nextNight();
|
getGame().nextNight();
|
||||||
}
|
}
|
||||||
}.run();
|
}.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void kill(LGPlayer choosen, LGPlayer dicta, Runnable callback) {
|
protected void kill(LGPlayer choosen, LGPlayer dicta, Runnable callback) {
|
||||||
RoleType roleType = choosen.getRoleType();
|
RoleType roleType = choosen.getRoleType();
|
||||||
|
|
||||||
LGPlayerKilledEvent killEvent = new LGPlayerKilledEvent(getGame(), choosen, Reason.DICTATOR);
|
LGPlayerKilledEvent killEvent = new LGPlayerKilledEvent(getGame(), choosen, Reason.DICTATOR);
|
||||||
Bukkit.getPluginManager().callEvent(killEvent);
|
Bukkit.getPluginManager().callEvent(killEvent);
|
||||||
if(killEvent.isCancelled())return;
|
if (killEvent.isCancelled()) return;
|
||||||
if(getGame().kill(killEvent.getKilled(), killEvent.getReason(), true))
|
if (getGame().kill(killEvent.getKilled(), killEvent.getReason(), true))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if(roleType != RoleType.VILLAGER) {
|
if (roleType != RoleType.VILLAGER) {
|
||||||
getGame().broadcastMessage("§7§l"+dicta.getName()+" §9devient le §5§lCapitaine§9 du village.");
|
getGame().broadcastMessage("§7§l" + dicta.getName() + " §9devient le §5§lCapitaine§9 du village.");
|
||||||
getGame().setMayor(dicta);
|
getGame().setMayor(dicta);
|
||||||
} else {
|
} else {
|
||||||
getGame().kill(dicta, Reason.DICTATOR_SUICIDE);
|
getGame().kill(dicta, Reason.DICTATOR_SUICIDE);
|
||||||
for(LGPlayer lgp : getGame().getInGame()) {
|
for (LGPlayer lgp : getGame().getInGame()) {
|
||||||
if(lgp == dicta)
|
if (lgp == dicta)
|
||||||
lgp.sendMessage("§9§oÇa ne s'est pas passé comme prévu...");
|
lgp.sendMessage("§9§oÇa ne s'est pas passé comme prévu...");
|
||||||
else
|
else
|
||||||
lgp.sendMessage("§9Le "+getName()+"§9 s'est trompé, il mourra la nuit suivante.");
|
lgp.sendMessage("§9Le " + getName() + "§9 s'est trompé, il mourra la nuit suivante.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
callback.run();
|
callback.run();
|
||||||
|
@ -263,9 +277,9 @@ public class RDictateur extends Role{
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onNight(LGDayEndEvent e) {
|
public void onNight(LGDayEndEvent e) {
|
||||||
if(e.getGame() == getGame()) {
|
if (e.getGame() == getGame()) {
|
||||||
LGPlayer lgp = getGame().getDeaths().get(Reason.DICTATOR_SUICIDE);
|
LGPlayer lgp = getGame().getDeaths().get(Reason.DICTATOR_SUICIDE);
|
||||||
if(lgp != null)
|
if (lgp != null)
|
||||||
lgp.sendMessage("§8§oDes pensées sombres hantent ton esprit...");
|
lgp.sendMessage("§8§oDes pensées sombres hantent ton esprit...");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,15 +1,16 @@
|
||||||
package fr.leomelki.loupgarou.roles;
|
package fr.leomelki.loupgarou.roles;
|
||||||
|
|
||||||
import java.util.Random;
|
|
||||||
|
|
||||||
import org.bukkit.event.EventHandler;
|
|
||||||
import org.bukkit.event.EventPriority;
|
|
||||||
|
|
||||||
import fr.leomelki.loupgarou.classes.LGGame;
|
import fr.leomelki.loupgarou.classes.LGGame;
|
||||||
import fr.leomelki.loupgarou.classes.LGPlayer;
|
import fr.leomelki.loupgarou.classes.LGPlayer;
|
||||||
import fr.leomelki.loupgarou.events.LGPlayerKilledEvent;
|
import fr.leomelki.loupgarou.events.LGPlayerKilledEvent;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.EventPriority;
|
||||||
|
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
|
public class REnfantSauvage extends Role {
|
||||||
|
private static final Random random = new Random();
|
||||||
|
|
||||||
public class REnfantSauvage extends Role{
|
|
||||||
public REnfantSauvage(LGGame game) {
|
public REnfantSauvage(LGGame game) {
|
||||||
super(game);
|
super(game);
|
||||||
}
|
}
|
||||||
|
@ -21,7 +22,7 @@ public class REnfantSauvage extends Role{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getFriendlyName() {
|
public String getFriendlyName() {
|
||||||
return "de l'"+getName();
|
return "de l'" + getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -41,12 +42,14 @@ public class REnfantSauvage extends Role{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getBroadcastedTask() {
|
public String getBroadcastedTask() {
|
||||||
return "L'"+getName()+"§9 cherche ses marques...";
|
return "L'" + getName() + "§9 cherche ses marques...";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public RoleType getType() {
|
public RoleType getType() {
|
||||||
return RoleType.VILLAGER;
|
return RoleType.VILLAGER;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public RoleWinType getWinType() {
|
public RoleWinType getWinType() {
|
||||||
return RoleWinType.VILLAGE;
|
return RoleWinType.VILLAGE;
|
||||||
|
@ -62,10 +65,10 @@ public class REnfantSauvage extends Role{
|
||||||
player.showView();
|
player.showView();
|
||||||
player.sendMessage("§6Choisissez votre modèle.");
|
player.sendMessage("§6Choisissez votre modèle.");
|
||||||
player.choose(choosen -> {
|
player.choose(choosen -> {
|
||||||
if(choosen != null) {
|
if (choosen != null) {
|
||||||
player.stopChoosing();
|
player.stopChoosing();
|
||||||
player.sendMessage("§6Si §7§l"+choosen.getName()+"§6 meurt, tu deviendras §c§lLoup-Garou§6.");
|
player.sendMessage("§6Si §7§l" + choosen.getName() + "§6 meurt, tu deviendras §c§lLoup-Garou§6.");
|
||||||
player.sendActionBarMessage("§7§l"+choosen.getName()+"§6 est ton modèle");
|
player.sendActionBarMessage("§7§l" + choosen.getName() + "§6 est ton modèle");
|
||||||
player.getCache().set("enfant_svg", choosen);
|
player.getCache().set("enfant_svg", choosen);
|
||||||
choosen.getCache().set("enfant_svg_d", player);
|
choosen.getCache().set("enfant_svg_d", player);
|
||||||
getPlayers().remove(player);//Pour éviter qu'il puisse avoir plusieurs modèles
|
getPlayers().remove(player);//Pour éviter qu'il puisse avoir plusieurs modèles
|
||||||
|
@ -74,16 +77,16 @@ public class REnfantSauvage extends Role{
|
||||||
}
|
}
|
||||||
}, player);
|
}, player);
|
||||||
}
|
}
|
||||||
private static final Random random = new Random();
|
|
||||||
@Override
|
@Override
|
||||||
protected void onNightTurnTimeout(LGPlayer player) {
|
protected void onNightTurnTimeout(LGPlayer player) {
|
||||||
player.stopChoosing();
|
player.stopChoosing();
|
||||||
player.hideView();
|
player.hideView();
|
||||||
LGPlayer choosen = null;
|
LGPlayer choosen = null;
|
||||||
while(choosen == null || choosen == player)
|
while (choosen == null || choosen == player)
|
||||||
choosen = getGame().getAlive().get(random.nextInt(getGame().getAlive().size()));
|
choosen = getGame().getAlive().get(random.nextInt(getGame().getAlive().size()));
|
||||||
player.sendMessage("§6Si §7§l"+choosen.getName()+"§6 meurt, tu deviendras §c§lLoup-Garou§6.");
|
player.sendMessage("§6Si §7§l" + choosen.getName() + "§6 meurt, tu deviendras §c§lLoup-Garou§6.");
|
||||||
player.sendActionBarMessage("§7§l"+choosen.getName()+"§6 est ton modèle");
|
player.sendActionBarMessage("§7§l" + choosen.getName() + "§6 est ton modèle");
|
||||||
player.getCache().set("enfant_svg", choosen);
|
player.getCache().set("enfant_svg", choosen);
|
||||||
choosen.getCache().set("enfant_svg_d", player);
|
choosen.getCache().set("enfant_svg_d", player);
|
||||||
getPlayers().remove(player);
|
getPlayers().remove(player);
|
||||||
|
@ -91,17 +94,17 @@ public class REnfantSauvage extends Role{
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST)
|
@EventHandler(priority = EventPriority.HIGHEST)
|
||||||
public void onPlayerKilled(LGPlayerKilledEvent e) {
|
public void onPlayerKilled(LGPlayerKilledEvent e) {
|
||||||
if(e.getGame() == getGame())
|
if (e.getGame() == getGame())
|
||||||
if(e.getKilled().getCache().has("enfant_svg_d")) {
|
if (e.getKilled().getCache().has("enfant_svg_d")) {
|
||||||
LGPlayer enfant = e.getKilled().getCache().remove("enfant_svg_d");
|
LGPlayer enfant = e.getKilled().getCache().remove("enfant_svg_d");
|
||||||
if(!enfant.isDead() && enfant.getCache().remove("enfant_svg") == e.getKilled() && enfant.isRoleActive()) {
|
if (!enfant.isDead() && enfant.getCache().remove("enfant_svg") == e.getKilled() && enfant.isRoleActive()) {
|
||||||
enfant.sendMessage("§7§l"+e.getKilled().getName()+"§6 est mort, tu deviens un §c§lLoup-Garou§6.");
|
enfant.sendMessage("§7§l" + e.getKilled().getName() + "§6 est mort, tu deviens un §c§lLoup-Garou§6.");
|
||||||
REnfantSauvageLG lgEnfantSvg = null;
|
REnfantSauvageLG lgEnfantSvg = null;
|
||||||
for(Role role : getGame().getRoles())
|
for (Role role : getGame().getRoles())
|
||||||
if(role instanceof REnfantSauvageLG)
|
if (role instanceof REnfantSauvageLG)
|
||||||
lgEnfantSvg = (REnfantSauvageLG)role;
|
lgEnfantSvg = (REnfantSauvageLG) role;
|
||||||
|
|
||||||
if(lgEnfantSvg == null)
|
if (lgEnfantSvg == null)
|
||||||
getGame().getRoles().add(lgEnfantSvg = new REnfantSauvageLG(getGame()));
|
getGame().getRoles().add(lgEnfantSvg = new REnfantSauvageLG(getGame()));
|
||||||
|
|
||||||
lgEnfantSvg.join(enfant, false);
|
lgEnfantSvg.join(enfant, false);
|
||||||
|
|
|
@ -1,28 +1,28 @@
|
||||||
package fr.leomelki.loupgarou.roles;
|
package fr.leomelki.loupgarou.roles;
|
||||||
|
|
||||||
import org.bukkit.potion.PotionEffectType;
|
|
||||||
|
|
||||||
import fr.leomelki.loupgarou.classes.LGCustomItems;
|
import fr.leomelki.loupgarou.classes.LGCustomItems;
|
||||||
import fr.leomelki.loupgarou.classes.LGGame;
|
import fr.leomelki.loupgarou.classes.LGGame;
|
||||||
import fr.leomelki.loupgarou.classes.LGPlayer;
|
import fr.leomelki.loupgarou.classes.LGPlayer;
|
||||||
|
import org.bukkit.potion.PotionEffectType;
|
||||||
|
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
|
|
||||||
public class REnfantSauvageLG extends Role{
|
public class REnfantSauvageLG extends Role {
|
||||||
public REnfantSauvageLG(LGGame game) {
|
public REnfantSauvageLG(LGGame game) {
|
||||||
super(game);
|
super(game);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
for(LGPlayer lgp : getPlayers())
|
for (LGPlayer lgp : getPlayers())
|
||||||
if(lgp.getPlayer() != null && lgp.getPlayer().hasPotionEffect(PotionEffectType.INVISIBILITY))
|
if (lgp.getPlayer() != null && lgp.getPlayer().hasPotionEffect(PotionEffectType.INVISIBILITY))
|
||||||
return "§c§lEnfant-Sauvage";
|
return "§c§lEnfant-Sauvage";
|
||||||
return (getPlayers().size() > 0 ? "§a" : "§c")+"§lEnfant-Sauvage";
|
return (getPlayers().size() > 0 ? "§a" : "§c") + "§lEnfant-Sauvage";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getFriendlyName() {
|
public String getFriendlyName() {
|
||||||
return "de l'"+getName();
|
return "de l'" + getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -42,12 +42,14 @@ public class REnfantSauvageLG extends Role{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getBroadcastedTask() {
|
public String getBroadcastedTask() {
|
||||||
return "L'"+getName()+"§9 cherche ses marques...";
|
return "L'" + getName() + "§9 cherche ses marques...";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public RoleType getType() {
|
public RoleType getType() {
|
||||||
return RoleType.LOUP_GAROU;
|
return RoleType.LOUP_GAROU;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public RoleWinType getWinType() {
|
public RoleWinType getWinType() {
|
||||||
return RoleWinType.LOUP_GAROU;
|
return RoleWinType.LOUP_GAROU;
|
||||||
|
@ -64,19 +66,19 @@ public class REnfantSauvageLG extends Role{
|
||||||
player.setRole(this);
|
player.setRole(this);
|
||||||
LGCustomItems.updateItem(player);
|
LGCustomItems.updateItem(player);
|
||||||
RLoupGarou lgRole = null;
|
RLoupGarou lgRole = null;
|
||||||
for(Role role : getGame().getRoles())
|
for (Role role : getGame().getRoles())
|
||||||
if(role instanceof RLoupGarou)
|
if (role instanceof RLoupGarou)
|
||||||
lgRole = (RLoupGarou)role;
|
lgRole = (RLoupGarou) role;
|
||||||
|
|
||||||
if(lgRole == null) {
|
if (lgRole == null) {
|
||||||
getGame().getRoles().add(lgRole = new RLoupGarou(getGame()));
|
getGame().getRoles().add(lgRole = new RLoupGarou(getGame()));
|
||||||
|
|
||||||
getGame().getRoles().sort(Comparator.comparingInt(Role::getTurnOrder));
|
getGame().getRoles().sort(Comparator.comparingInt(Role::getTurnOrder));
|
||||||
}
|
}
|
||||||
|
|
||||||
lgRole.join(player, false);
|
lgRole.join(player, false);
|
||||||
for(LGPlayer lgp : lgRole.getPlayers())
|
for (LGPlayer lgp : lgRole.getPlayers())
|
||||||
if(lgp != player)
|
if (lgp != player)
|
||||||
lgp.sendMessage("§7§l"+player.getName()+"§6 a rejoint les §c§lLoups-Garous§6.");
|
lgp.sendMessage("§7§l" + player.getName() + "§6 a rejoint les §c§lLoups-Garous§6.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,66 +1,74 @@
|
||||||
package fr.leomelki.loupgarou.roles;
|
package fr.leomelki.loupgarou.roles;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Random;
|
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.event.EventHandler;
|
|
||||||
import org.bukkit.event.EventPriority;
|
|
||||||
|
|
||||||
import fr.leomelki.loupgarou.MainLg;
|
import fr.leomelki.loupgarou.MainLg;
|
||||||
import fr.leomelki.loupgarou.classes.LGGame;
|
import fr.leomelki.loupgarou.classes.LGGame;
|
||||||
import fr.leomelki.loupgarou.classes.LGPlayer;
|
import fr.leomelki.loupgarou.classes.LGPlayer;
|
||||||
import fr.leomelki.loupgarou.events.LGPlayerKilledEvent;
|
import fr.leomelki.loupgarou.events.LGPlayerKilledEvent;
|
||||||
import fr.leomelki.loupgarou.events.LGPlayerKilledEvent.Reason;
|
import fr.leomelki.loupgarou.events.LGPlayerKilledEvent.Reason;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.EventPriority;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
|
public class RFaucheur extends Role {
|
||||||
|
private static final Random random = new Random();
|
||||||
|
|
||||||
public class RFaucheur extends Role{
|
|
||||||
public RFaucheur(LGGame game) {
|
public RFaucheur(LGGame game) {
|
||||||
super(game);
|
super(game);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public RoleType getType() {
|
public RoleType getType() {
|
||||||
return RoleType.VILLAGER;
|
return RoleType.VILLAGER;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public RoleWinType getWinType() {
|
public RoleWinType getWinType() {
|
||||||
return RoleWinType.VILLAGE;
|
return RoleWinType.VILLAGE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return "§a§lFaucheur";
|
return "§a§lFaucheur";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getFriendlyName() {
|
public String getFriendlyName() {
|
||||||
return "du "+getName();
|
return "du " + getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getShortDescription() {
|
public String getShortDescription() {
|
||||||
return "Tu gagnes avec le §a§lVillage";
|
return "Tu gagnes avec le §a§lVillage";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getDescription() {
|
public String getDescription() {
|
||||||
return "Tu gagnes avec le §a§lVillage§f. Si les §c§lLoups-Garous§f te tuent pendant la nuit, tu emporteras l’un d’entre eux dans ta mort, mais si tu meurs lors du vote du §a§lvillage§f, ce sont tes deux voisins qui en paieront le prix.";
|
return "Tu gagnes avec le §a§lVillage§f. Si les §c§lLoups-Garous§f te tuent pendant la nuit, tu emporteras l’un d’entre eux dans ta mort, mais si tu meurs lors du vote du §a§lvillage§f, ce sont tes deux voisins qui en paieront le prix.";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getTask() {
|
public String getTask() {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getBroadcastedTask() {
|
public String getBroadcastedTask() {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getTimeout() {
|
public int getTimeout() {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final Random random = new Random();
|
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.LOWEST)
|
@EventHandler(priority = EventPriority.LOWEST)
|
||||||
public void onKill(LGPlayerKilledEvent e) {
|
public void onKill(LGPlayerKilledEvent e) {
|
||||||
if (e.getKilled().getRole() == this && e.getKilled().isRoleActive()) {
|
if (e.getKilled().getRole() == this && e.getKilled().isRoleActive()) {
|
||||||
LGPlayer killed = e.getKilled();
|
LGPlayer killed = e.getKilled();
|
||||||
if(killed.getCache().getBoolean("faucheur_did"))//A déjà fait son coup de faucheur !
|
if (killed.getCache().getBoolean("faucheur_did"))//A déjà fait son coup de faucheur !
|
||||||
return;
|
return;
|
||||||
killed.getCache().set("faucheur_did", true);
|
killed.getCache().set("faucheur_did", true);
|
||||||
if (e.getReason() == Reason.LOUP_GAROU || e.getReason() == Reason.GM_LOUP_GAROU) {//car le switch buggait (wtf)
|
if (e.getReason() == Reason.LOUP_GAROU || e.getReason() == Reason.GM_LOUP_GAROU) {//car le switch buggait (wtf)
|
||||||
|
@ -86,7 +94,7 @@ public class RFaucheur extends Role{
|
||||||
int killedPlace = killed.getPlace();
|
int killedPlace = killed.getPlace();
|
||||||
|
|
||||||
LGPlayer droite = null, gauche = null;
|
LGPlayer droite = null, gauche = null;
|
||||||
for (int i = killedPlace + 1;; i++) {
|
for (int i = killedPlace + 1; ; i++) {
|
||||||
if (i == size)
|
if (i == size)
|
||||||
i = 0;
|
i = 0;
|
||||||
LGPlayer lgp = getGame().getPlacements().get(i);
|
LGPlayer lgp = getGame().getPlacements().get(i);
|
||||||
|
@ -97,7 +105,7 @@ public class RFaucheur extends Role{
|
||||||
if (lgp == killed)// Fait un tour complet
|
if (lgp == killed)// Fait un tour complet
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
for (int i = killedPlace - 1;; i--) {
|
for (int i = killedPlace - 1; ; i--) {
|
||||||
if (i == -1)
|
if (i == -1)
|
||||||
i = size - 1;
|
i = size - 1;
|
||||||
LGPlayer lgp = getGame().getPlacements().get(i);
|
LGPlayer lgp = getGame().getPlacements().get(i);
|
||||||
|
|
|
@ -1,52 +1,61 @@
|
||||||
package fr.leomelki.loupgarou.roles;
|
package fr.leomelki.loupgarou.roles;
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.bukkit.event.EventHandler;
|
|
||||||
|
|
||||||
import fr.leomelki.loupgarou.classes.LGGame;
|
import fr.leomelki.loupgarou.classes.LGGame;
|
||||||
import fr.leomelki.loupgarou.classes.LGPlayer;
|
import fr.leomelki.loupgarou.classes.LGPlayer;
|
||||||
import fr.leomelki.loupgarou.events.LGNightPlayerPreKilledEvent;
|
import fr.leomelki.loupgarou.events.LGNightPlayerPreKilledEvent;
|
||||||
import fr.leomelki.loupgarou.events.LGPlayerKilledEvent.Reason;
|
import fr.leomelki.loupgarou.events.LGPlayerKilledEvent.Reason;
|
||||||
import fr.leomelki.loupgarou.events.LGPreDayStartEvent;
|
import fr.leomelki.loupgarou.events.LGPreDayStartEvent;
|
||||||
import fr.leomelki.loupgarou.events.LGVampiredEvent;
|
import fr.leomelki.loupgarou.events.LGVampiredEvent;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class RGarde extends Role {
|
||||||
|
private static final List<Reason> reasonsProtected = Arrays.asList(Reason.LOUP_GAROU, Reason.LOUP_BLANC, Reason.GM_LOUP_GAROU, Reason.ASSASSIN);
|
||||||
|
|
||||||
public class RGarde extends Role{
|
|
||||||
public RGarde(LGGame game) {
|
public RGarde(LGGame game) {
|
||||||
super(game);
|
super(game);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public RoleType getType() {
|
public RoleType getType() {
|
||||||
return RoleType.VILLAGER;
|
return RoleType.VILLAGER;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public RoleWinType getWinType() {
|
public RoleWinType getWinType() {
|
||||||
return RoleWinType.VILLAGE;
|
return RoleWinType.VILLAGE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return "§a§lGarde";
|
return "§a§lGarde";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getFriendlyName() {
|
public String getFriendlyName() {
|
||||||
return "du "+getName();
|
return "du " + getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getShortDescription() {
|
public String getShortDescription() {
|
||||||
return "Tu gagnes avec le §a§lVillage";
|
return "Tu gagnes avec le §a§lVillage";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getDescription() {
|
public String getDescription() {
|
||||||
return "Tu gagnes avec le §a§lVillage§f. Chaque nuit, tu peux te protéger toi ou quelqu'un d'autre des attaques §c§lhostiles§f. Tu ne peux pas protéger deux fois d’affilé la même personne.";
|
return "Tu gagnes avec le §a§lVillage§f. Chaque nuit, tu peux te protéger toi ou quelqu'un d'autre des attaques §c§lhostiles§f. Tu ne peux pas protéger deux fois d’affilé la même personne.";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getTask() {
|
public String getTask() {
|
||||||
return "Choisis un joueur à protéger.";
|
return "Choisis un joueur à protéger.";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getBroadcastedTask() {
|
public String getBroadcastedTask() {
|
||||||
return "Le "+getName()+"§9 choisit un joueur à protéger.";
|
return "Le " + getName() + "§9 choisit un joueur à protéger.";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -59,20 +68,20 @@ public class RGarde extends Role{
|
||||||
player.showView();
|
player.showView();
|
||||||
|
|
||||||
player.choose(choosen -> {
|
player.choose(choosen -> {
|
||||||
if(choosen != null) {
|
if (choosen != null) {
|
||||||
LGPlayer lastProtected = player.getCache().get("garde_lastProtected");
|
LGPlayer lastProtected = player.getCache().get("garde_lastProtected");
|
||||||
if(choosen == lastProtected) {
|
if (choosen == lastProtected) {
|
||||||
if(lastProtected == player)
|
if (lastProtected == player)
|
||||||
player.sendMessage("§4§oTu t'es déjà protégé la nuit dernière.");
|
player.sendMessage("§4§oTu t'es déjà protégé la nuit dernière.");
|
||||||
else
|
else
|
||||||
player.sendMessage("§4§oTu as déjà protégé §7§l§o"+lastProtected.getName()+"§4§o la nuit dernière.");
|
player.sendMessage("§4§oTu as déjà protégé §7§l§o" + lastProtected.getName() + "§4§o la nuit dernière.");
|
||||||
} else {
|
} else {
|
||||||
if(choosen == player) {
|
if (choosen == player) {
|
||||||
player.sendMessage("§6Tu décides de te protéger toi-même cette nuit.");
|
player.sendMessage("§6Tu décides de te protéger toi-même cette nuit.");
|
||||||
player.sendActionBarMessage("§9Tu seras protégé.");
|
player.sendActionBarMessage("§9Tu seras protégé.");
|
||||||
} else {
|
} else {
|
||||||
player.sendMessage("§6Tu vas protéger §7§l"+choosen.getName()+"§6 cette nuit.");
|
player.sendMessage("§6Tu vas protéger §7§l" + choosen.getName() + "§6 cette nuit.");
|
||||||
player.sendActionBarMessage("§7§l"+choosen.getName()+"§9 sera protégé.");
|
player.sendActionBarMessage("§7§l" + choosen.getName() + "§9 sera protégé.");
|
||||||
}
|
}
|
||||||
choosen.getCache().set("garde_protected", true);
|
choosen.getCache().set("garde_protected", true);
|
||||||
player.getCache().set("garde_lastProtected", choosen);
|
player.getCache().set("garde_lastProtected", choosen);
|
||||||
|
@ -83,6 +92,7 @@ public class RGarde extends Role{
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onNightTurnTimeout(LGPlayer player) {
|
protected void onNightTurnTimeout(LGPlayer player) {
|
||||||
player.getCache().remove("garde_lastProtected");
|
player.getCache().remove("garde_lastProtected");
|
||||||
|
@ -92,24 +102,24 @@ public class RGarde extends Role{
|
||||||
//player.sendMessage("§cVous n'avez protégé personne cette nuit.");
|
//player.sendMessage("§cVous n'avez protégé personne cette nuit.");
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final List<Reason> reasonsProtected = Arrays.asList(Reason.LOUP_GAROU, Reason.LOUP_BLANC, Reason.GM_LOUP_GAROU, Reason.ASSASSIN);
|
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlayerKill(LGNightPlayerPreKilledEvent e) {
|
public void onPlayerKill(LGNightPlayerPreKilledEvent e) {
|
||||||
if(e.getGame() == getGame() && reasonsProtected.contains(e.getReason()) && e.getKilled().getCache().getBoolean("garde_protected")) {
|
if (e.getGame() == getGame() && reasonsProtected.contains(e.getReason()) && e.getKilled().getCache().getBoolean("garde_protected")) {
|
||||||
e.getKilled().getCache().remove("garde_protected");
|
e.getKilled().getCache().remove("garde_protected");
|
||||||
e.setReason(Reason.DONT_DIE);
|
e.setReason(Reason.DONT_DIE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onVampired(LGVampiredEvent e) {
|
public void onVampired(LGVampiredEvent e) {
|
||||||
if(e.getGame() == getGame() && e.getPlayer().getCache().getBoolean("garde_protected"))
|
if (e.getGame() == getGame() && e.getPlayer().getCache().getBoolean("garde_protected"))
|
||||||
e.setProtect(true);
|
e.setProtect(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onDayStart(LGPreDayStartEvent e) {
|
public void onDayStart(LGPreDayStartEvent e) {
|
||||||
if(e.getGame() == getGame())
|
if (e.getGame() == getGame())
|
||||||
for(LGPlayer lgp : getGame().getInGame())
|
for (LGPlayer lgp : getGame().getInGame())
|
||||||
lgp.getCache().remove("garde_protected");
|
lgp.getCache().remove("garde_protected");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,13 +1,15 @@
|
||||||
package fr.leomelki.loupgarou.roles;
|
package fr.leomelki.loupgarou.roles;
|
||||||
|
|
||||||
import org.bukkit.event.EventHandler;
|
|
||||||
|
|
||||||
import fr.leomelki.loupgarou.classes.LGGame;
|
import fr.leomelki.loupgarou.classes.LGGame;
|
||||||
import fr.leomelki.loupgarou.classes.LGPlayer;
|
import fr.leomelki.loupgarou.classes.LGPlayer;
|
||||||
import fr.leomelki.loupgarou.events.LGPlayerKilledEvent;
|
import fr.leomelki.loupgarou.events.LGPlayerKilledEvent;
|
||||||
import fr.leomelki.loupgarou.events.LGPlayerKilledEvent.Reason;
|
import fr.leomelki.loupgarou.events.LGPlayerKilledEvent.Reason;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
|
||||||
public class RGrandMechantLoup extends Role{
|
public class RGrandMechantLoup extends Role {
|
||||||
|
|
||||||
|
boolean lgDied;
|
||||||
|
Runnable callback;
|
||||||
|
|
||||||
public RGrandMechantLoup(LGGame game) {
|
public RGrandMechantLoup(LGGame game) {
|
||||||
super(game);
|
super(game);
|
||||||
|
@ -20,7 +22,7 @@ public class RGrandMechantLoup extends Role{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getFriendlyName() {
|
public String getFriendlyName() {
|
||||||
return "du "+getName();
|
return "du " + getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -42,10 +44,12 @@ public class RGrandMechantLoup extends Role{
|
||||||
public String getBroadcastedTask() {
|
public String getBroadcastedTask() {
|
||||||
return "Le §c§lGrand Méchant Loup§9 n'en a pas terminé...";
|
return "Le §c§lGrand Méchant Loup§9 n'en a pas terminé...";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public RoleType getType() {
|
public RoleType getType() {
|
||||||
return RoleType.LOUP_GAROU;
|
return RoleType.LOUP_GAROU;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public RoleWinType getWinType() {
|
public RoleWinType getWinType() {
|
||||||
return RoleWinType.LOUP_GAROU;
|
return RoleWinType.LOUP_GAROU;
|
||||||
|
@ -60,17 +64,16 @@ public class RGrandMechantLoup extends Role{
|
||||||
public boolean hasPlayersLeft() {
|
public boolean hasPlayersLeft() {
|
||||||
return super.hasPlayersLeft() && !lgDied;
|
return super.hasPlayersLeft() && !lgDied;
|
||||||
}
|
}
|
||||||
boolean lgDied;
|
|
||||||
Runnable callback;
|
|
||||||
@Override
|
@Override
|
||||||
protected void onNightTurn(LGPlayer player, Runnable callback) {
|
protected void onNightTurn(LGPlayer player, Runnable callback) {
|
||||||
this.callback = callback;
|
this.callback = callback;
|
||||||
|
|
||||||
player.showView();
|
player.showView();
|
||||||
player.choose(choosen -> {
|
player.choose(choosen -> {
|
||||||
if(choosen != null && choosen != player) {
|
if (choosen != null && choosen != player) {
|
||||||
player.sendActionBarMessage("§e§l"+choosen.getName()+"§6 va mourir cette nuit");
|
player.sendActionBarMessage("§e§l" + choosen.getName() + "§6 va mourir cette nuit");
|
||||||
player.sendMessage("§6Tu as choisi de manger §7§l"+choosen.getName()+"§6.");
|
player.sendMessage("§6Tu as choisi de manger §7§l" + choosen.getName() + "§6.");
|
||||||
getGame().kill(choosen, getGame().getDeaths().containsKey(Reason.LOUP_GAROU) ? Reason.GM_LOUP_GAROU : Reason.LOUP_GAROU);
|
getGame().kill(choosen, getGame().getDeaths().containsKey(Reason.LOUP_GAROU) ? Reason.GM_LOUP_GAROU : Reason.LOUP_GAROU);
|
||||||
player.stopChoosing();
|
player.stopChoosing();
|
||||||
player.hideView();
|
player.hideView();
|
||||||
|
@ -81,13 +84,12 @@ public class RGrandMechantLoup extends Role{
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlayerDie(LGPlayerKilledEvent e) {//Quand un Loup-Garou meurt, les grands méchants loups ne peuvent plus jouer.
|
public void onPlayerDie(LGPlayerKilledEvent e) {//Quand un Loup-Garou meurt, les grands méchants loups ne peuvent plus jouer.
|
||||||
if(e.getGame() == getGame())
|
if (e.getGame() == getGame())
|
||||||
if(e.getKilled().getRoleType() == RoleType.LOUP_GAROU)
|
if (e.getKilled().getRoleType() == RoleType.LOUP_GAROU)
|
||||||
lgDied = true;
|
lgDied = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onNightTurnTimeout(LGPlayer player) {
|
protected void onNightTurnTimeout(LGPlayer player) {
|
||||||
player.stopChoosing();
|
player.stopChoosing();
|
||||||
|
@ -98,8 +100,8 @@ public class RGrandMechantLoup extends Role{
|
||||||
@Override
|
@Override
|
||||||
public void join(LGPlayer player, boolean sendMessage) {
|
public void join(LGPlayer player, boolean sendMessage) {
|
||||||
super.join(player, sendMessage);
|
super.join(player, sendMessage);
|
||||||
for(Role role : getGame().getRoles())
|
for (Role role : getGame().getRoles())
|
||||||
if(role instanceof RLoupGarou)
|
if (role instanceof RLoupGarou)
|
||||||
role.join(player, false);
|
role.join(player, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,28 +1,24 @@
|
||||||
package fr.leomelki.loupgarou.roles;
|
package fr.leomelki.loupgarou.roles;
|
||||||
|
|
||||||
|
import fr.leomelki.com.comphenix.packetwrapper.WrapperPlayServerScoreboardTeam;
|
||||||
|
import fr.leomelki.loupgarou.classes.*;
|
||||||
|
import fr.leomelki.loupgarou.classes.chat.LGChat;
|
||||||
|
import fr.leomelki.loupgarou.events.*;
|
||||||
|
import fr.leomelki.loupgarou.events.LGPlayerKilledEvent.Reason;
|
||||||
|
import lombok.Getter;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.EventPriority;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
import org.bukkit.event.EventHandler;
|
public class RLoupGarou extends Role {
|
||||||
import org.bukkit.event.EventPriority;
|
|
||||||
|
|
||||||
import fr.leomelki.com.comphenix.packetwrapper.WrapperPlayServerScoreboardTeam;
|
@Getter
|
||||||
import fr.leomelki.loupgarou.classes.LGCustomSkin;
|
private final LGChat chat = new LGChat((sender, message) -> "§c" + sender.getName() + " §6» §f" + message);
|
||||||
import fr.leomelki.loupgarou.classes.LGGame;
|
boolean showSkins = false;
|
||||||
import fr.leomelki.loupgarou.classes.LGPlayer;
|
LGVote vote;
|
||||||
import fr.leomelki.loupgarou.classes.LGVote;
|
|
||||||
import fr.leomelki.loupgarou.classes.LGWinType;
|
|
||||||
import fr.leomelki.loupgarou.classes.chat.LGChat;
|
|
||||||
import fr.leomelki.loupgarou.events.LGDayEndEvent;
|
|
||||||
import fr.leomelki.loupgarou.events.LGGameEndEvent;
|
|
||||||
import fr.leomelki.loupgarou.events.LGNightEndEvent;
|
|
||||||
import fr.leomelki.loupgarou.events.LGPlayerKilledEvent.Reason;
|
|
||||||
import fr.leomelki.loupgarou.events.LGSkinLoadEvent;
|
|
||||||
import fr.leomelki.loupgarou.events.LGUpdatePrefixEvent;
|
|
||||||
import lombok.Getter;
|
|
||||||
|
|
||||||
public class RLoupGarou extends Role{
|
|
||||||
|
|
||||||
public RLoupGarou(LGGame game) {
|
public RLoupGarou(LGGame game) {
|
||||||
super(game);
|
super(game);
|
||||||
|
@ -57,10 +53,12 @@ public class RLoupGarou extends Role{
|
||||||
public String getBroadcastedTask() {
|
public String getBroadcastedTask() {
|
||||||
return "Les §c§lLoups-Garous§9 choisissent leur cible.";
|
return "Les §c§lLoups-Garous§9 choisissent leur cible.";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public RoleType getType() {
|
public RoleType getType() {
|
||||||
return RoleType.LOUP_GAROU;
|
return RoleType.LOUP_GAROU;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public RoleWinType getWinType() {
|
public RoleWinType getWinType() {
|
||||||
return RoleWinType.LOUP_GAROU;
|
return RoleWinType.LOUP_GAROU;
|
||||||
|
@ -71,121 +69,120 @@ public class RLoupGarou extends Role{
|
||||||
return 30;
|
return 30;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Getter private final LGChat chat = new LGChat((sender, message) -> "§c"+sender.getName()+" §6» §f"+message);
|
|
||||||
|
|
||||||
boolean showSkins = false;
|
|
||||||
LGVote vote;
|
|
||||||
@Override
|
@Override
|
||||||
public void join(LGPlayer player, boolean sendMessage) {
|
public void join(LGPlayer player, boolean sendMessage) {
|
||||||
super.join(player, sendMessage);
|
super.join(player, sendMessage);
|
||||||
//On peut créer des cheats grâce à ça (qui permettent de savoir qui est lg/inf)
|
//On peut créer des cheats grâce à ça (qui permettent de savoir qui est lg/inf)
|
||||||
for(LGPlayer p : getPlayers())
|
for (LGPlayer p : getPlayers())
|
||||||
p.updatePrefix();
|
p.updatePrefix();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onNightTurn(Runnable callback) {
|
public void onNightTurn(Runnable callback) {
|
||||||
vote = new LGVote(getTimeout(), getTimeout()/3, getGame(), false, false, (player, secondsLeft)-> !getPlayers().contains(player) ? "§6C'est au tour "+getFriendlyName()+" §6(§e"+secondsLeft+" s§6)" : player.getCache().has("vote") ? "§l§9Vous votez contre §c§l"+player.getCache().<LGPlayer>get("vote").getName() : "§6Il vous reste §e"+secondsLeft+" seconde"+(secondsLeft > 1 ? "s" : "")+"§6 pour voter");
|
vote = new LGVote(getTimeout(), getTimeout() / 3, getGame(), false, false, (player, secondsLeft) -> !getPlayers().contains(player) ? "§6C'est au tour " + getFriendlyName() + " §6(§e" + secondsLeft + " s§6)" : player.getCache().has("vote") ? "§l§9Vous votez contre §c§l" + player.getCache().<LGPlayer>get("vote").getName() : "§6Il vous reste §e" + secondsLeft + " seconde" + (secondsLeft > 1 ? "s" : "") + "§6 pour voter");
|
||||||
for(LGPlayer lgp : getGame().getAlive())
|
for (LGPlayer lgp : getGame().getAlive())
|
||||||
if(lgp.getRoleType() == RoleType.LOUP_GAROU)
|
if (lgp.getRoleType() == RoleType.LOUP_GAROU)
|
||||||
lgp.showView();
|
lgp.showView();
|
||||||
for(LGPlayer player : getPlayers()) {
|
for (LGPlayer player : getPlayers()) {
|
||||||
player.sendMessage("§6"+getTask());
|
player.sendMessage("§6" + getTask());
|
||||||
// player.sendTitle("§6C'est à vous de jouer", "§a"+getTask(), 100);
|
// player.sendTitle("§6C'est à vous de jouer", "§a"+getTask(), 100);
|
||||||
player.joinChat(chat);
|
player.joinChat(chat);
|
||||||
}
|
}
|
||||||
vote.start(getPlayers(), getPlayers(), ()->{
|
vote.start(getPlayers(), getPlayers(), () -> {
|
||||||
onNightTurnEnd();
|
onNightTurnEnd();
|
||||||
callback.run();
|
callback.run();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onNightTurnEnd() {
|
private void onNightTurnEnd() {
|
||||||
for(LGPlayer lgp : getGame().getAlive())
|
for (LGPlayer lgp : getGame().getAlive())
|
||||||
if(lgp.getRoleType() == RoleType.LOUP_GAROU)
|
if (lgp.getRoleType() == RoleType.LOUP_GAROU)
|
||||||
lgp.hideView();
|
lgp.hideView();
|
||||||
for(LGPlayer player : getPlayers()) {
|
for (LGPlayer player : getPlayers()) {
|
||||||
player.leaveChat();
|
player.leaveChat();
|
||||||
}
|
}
|
||||||
|
|
||||||
LGPlayer choosen = vote.getChoosen();
|
LGPlayer choosen = vote.getChoosen();
|
||||||
if(choosen == null) {
|
if (choosen == null) {
|
||||||
if(vote.getVotes().size() > 0) {
|
if (vote.getVotes().size() > 0) {
|
||||||
int max = 0;
|
int max = 0;
|
||||||
boolean equal = false;
|
boolean equal = false;
|
||||||
for(Entry<LGPlayer, List<LGPlayer>> entry : vote.getVotes().entrySet())
|
for (Entry<LGPlayer, List<LGPlayer>> entry : vote.getVotes().entrySet())
|
||||||
if(entry.getValue().size() > max) {
|
if (entry.getValue().size() > max) {
|
||||||
equal = false;
|
equal = false;
|
||||||
max = entry.getValue().size();
|
max = entry.getValue().size();
|
||||||
choosen = entry.getKey();
|
choosen = entry.getKey();
|
||||||
}else if(entry.getValue().size() == max)
|
} else if (entry.getValue().size() == max)
|
||||||
equal = true;
|
equal = true;
|
||||||
if(equal) {
|
if (equal) {
|
||||||
choosen = null;
|
choosen = null;
|
||||||
ArrayList<LGPlayer> choosable = new ArrayList<>();
|
ArrayList<LGPlayer> choosable = new ArrayList<>();
|
||||||
for(Entry<LGPlayer, List<LGPlayer>> entry : vote.getVotes().entrySet())
|
for (Entry<LGPlayer, List<LGPlayer>> entry : vote.getVotes().entrySet())
|
||||||
if(entry.getValue().size() == max && entry.getKey().getRoleType() != RoleType.LOUP_GAROU)
|
if (entry.getValue().size() == max && entry.getKey().getRoleType() != RoleType.LOUP_GAROU)
|
||||||
choosable.add(entry.getKey());
|
choosable.add(entry.getKey());
|
||||||
if(choosable.size() > 0)
|
if (choosable.size() > 0)
|
||||||
choosen = choosable.get(getGame().getRandom().nextInt(choosable.size()));
|
choosen = choosable.get(getGame().getRandom().nextInt(choosable.size()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(choosen != null) {
|
if (choosen != null) {
|
||||||
getGame().kill(choosen, Reason.LOUP_GAROU);
|
getGame().kill(choosen, Reason.LOUP_GAROU);
|
||||||
for(LGPlayer player : getPlayers())
|
for (LGPlayer player : getPlayers())
|
||||||
player.sendMessage("§6Les §c§lLoups§6 ont décidé de tuer §7§l"+choosen.getName()+"§6.");
|
player.sendMessage("§6Les §c§lLoups§6 ont décidé de tuer §7§l" + choosen.getName() + "§6.");
|
||||||
}else
|
} else
|
||||||
for(LGPlayer player : getPlayers())
|
for (LGPlayer player : getPlayers())
|
||||||
player.sendMessage("§6Personne n'a été désigné pour mourir.");
|
player.sendMessage("§6Personne n'a été désigné pour mourir.");
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onGameJoin(LGGameEndEvent e) {
|
public void onGameJoin(LGGameEndEvent e) {
|
||||||
if(e.getGame() == getGame()) {
|
if (e.getGame() == getGame()) {
|
||||||
WrapperPlayServerScoreboardTeam teamDelete = new WrapperPlayServerScoreboardTeam();
|
WrapperPlayServerScoreboardTeam teamDelete = new WrapperPlayServerScoreboardTeam();
|
||||||
teamDelete.setMode(1);
|
teamDelete.setMode(1);
|
||||||
teamDelete.setName("loup_garou_list");
|
teamDelete.setName("loup_garou_list");
|
||||||
|
|
||||||
for(LGPlayer lgp : getGame().getInGame())
|
for (LGPlayer lgp : getGame().getInGame())
|
||||||
teamDelete.sendPacket(lgp.getPlayer());
|
teamDelete.sendPacket(lgp.getPlayer());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST)
|
@EventHandler(priority = EventPriority.HIGHEST)
|
||||||
public void onSkinChange(LGSkinLoadEvent e) {
|
public void onSkinChange(LGSkinLoadEvent e) {
|
||||||
if(e.getGame() == getGame())
|
if (e.getGame() == getGame())
|
||||||
if(getPlayers().contains(e.getPlayer()) && getPlayers().contains(e.getTo()) && showSkins) {
|
if (getPlayers().contains(e.getPlayer()) && getPlayers().contains(e.getTo()) && showSkins) {
|
||||||
e.getProfile().getProperties().removeAll("textures");
|
e.getProfile().getProperties().removeAll("textures");
|
||||||
e.getProfile().getProperties().put("textures", LGCustomSkin.WEREWOLF.getProperty());
|
e.getProfile().getProperties().put("textures", LGCustomSkin.WEREWOLF.getProperty());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onGameEnd(LGGameEndEvent e) {
|
public void onGameEnd(LGGameEndEvent e) {
|
||||||
if(e.getGame() == getGame() && e.getWinType() == LGWinType.LOUPGAROU)
|
if (e.getGame() == getGame() && e.getWinType() == LGWinType.LOUPGAROU)
|
||||||
for(LGPlayer lgp : getGame().getInGame())
|
for (LGPlayer lgp : getGame().getInGame())
|
||||||
if(lgp.getRoleWinType() == RoleWinType.LOUP_GAROU)//Changed to wintype
|
if (lgp.getRoleWinType() == RoleWinType.LOUP_GAROU)//Changed to wintype
|
||||||
e.getWinners().add(lgp);
|
e.getWinners().add(lgp);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.LOWEST)
|
@EventHandler(priority = EventPriority.LOWEST)
|
||||||
public void onUpdatePrefix (LGUpdatePrefixEvent e) {
|
public void onUpdatePrefix(LGUpdatePrefixEvent e) {
|
||||||
if(e.getGame() == getGame())
|
if (e.getGame() == getGame())
|
||||||
if(getPlayers().contains(e.getTo()) && getPlayers().contains(e.getPlayer()))
|
if (getPlayers().contains(e.getTo()) && getPlayers().contains(e.getPlayer()))
|
||||||
e.setPrefix(e.getPrefix()+"§c");
|
e.setPrefix(e.getPrefix() + "§c");
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onDay(LGNightEndEvent e) {
|
public void onDay(LGNightEndEvent e) {
|
||||||
if(e.getGame() == getGame()) {
|
if (e.getGame() == getGame()) {
|
||||||
showSkins = false;
|
showSkins = false;
|
||||||
for(LGPlayer player : getPlayers())
|
for (LGPlayer player : getPlayers())
|
||||||
player.updateOwnSkin();
|
player.updateOwnSkin();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onNight(LGDayEndEvent e) {
|
public void onNight(LGDayEndEvent e) {
|
||||||
if(e.getGame() == getGame()) {
|
if (e.getGame() == getGame()) {
|
||||||
showSkins = true;
|
showSkins = true;
|
||||||
for(LGPlayer player : getPlayers())
|
for (LGPlayer player : getPlayers())
|
||||||
player.updateOwnSkin();
|
player.updateOwnSkin();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,11 @@
|
||||||
package fr.leomelki.loupgarou.roles;
|
package fr.leomelki.loupgarou.roles;
|
||||||
|
|
||||||
import java.util.Collections;
|
import fr.leomelki.loupgarou.classes.LGGame;
|
||||||
|
import fr.leomelki.loupgarou.classes.LGPlayer;
|
||||||
|
import fr.leomelki.loupgarou.classes.LGWinType;
|
||||||
|
import fr.leomelki.loupgarou.events.LGEndCheckEvent;
|
||||||
|
import fr.leomelki.loupgarou.events.LGGameEndEvent;
|
||||||
|
import fr.leomelki.loupgarou.events.LGPlayerKilledEvent.Reason;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
|
@ -10,15 +14,11 @@ import org.bukkit.event.player.PlayerInteractEvent;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.inventory.meta.ItemMeta;
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
|
|
||||||
import fr.leomelki.loupgarou.classes.LGGame;
|
import java.util.Collections;
|
||||||
import fr.leomelki.loupgarou.classes.LGPlayer;
|
|
||||||
import fr.leomelki.loupgarou.classes.LGWinType;
|
|
||||||
import fr.leomelki.loupgarou.events.LGEndCheckEvent;
|
|
||||||
import fr.leomelki.loupgarou.events.LGGameEndEvent;
|
|
||||||
import fr.leomelki.loupgarou.events.LGPlayerKilledEvent.Reason;
|
|
||||||
|
|
||||||
public class RLoupGarouBlanc extends Role{
|
public class RLoupGarouBlanc extends Role {
|
||||||
private static final ItemStack skip;
|
private static final ItemStack skip;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
skip = new ItemStack(Material.IRON_NUGGET);
|
skip = new ItemStack(Material.IRON_NUGGET);
|
||||||
ItemMeta meta = skip.getItemMeta();
|
ItemMeta meta = skip.getItemMeta();
|
||||||
|
@ -27,6 +27,9 @@ public class RLoupGarouBlanc extends Role{
|
||||||
skip.setItemMeta(meta);
|
skip.setItemMeta(meta);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Runnable callback;
|
||||||
|
RLoupGarou lg;
|
||||||
|
|
||||||
public RLoupGarouBlanc(LGGame game) {
|
public RLoupGarouBlanc(LGGame game) {
|
||||||
super(game);
|
super(game);
|
||||||
}
|
}
|
||||||
|
@ -38,7 +41,7 @@ public class RLoupGarouBlanc extends Role{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getFriendlyName() {
|
public String getFriendlyName() {
|
||||||
return "du "+getName();
|
return "du " + getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -58,12 +61,14 @@ public class RLoupGarouBlanc extends Role{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getBroadcastedTask() {
|
public String getBroadcastedTask() {
|
||||||
return "Le "+getName()+"§9 pourrait faire un ravage cette nuit...";
|
return "Le " + getName() + "§9 pourrait faire un ravage cette nuit...";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public RoleType getType() {
|
public RoleType getType() {
|
||||||
return RoleType.LOUP_GAROU;
|
return RoleType.LOUP_GAROU;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public RoleWinType getWinType() {
|
public RoleWinType getWinType() {
|
||||||
return RoleWinType.SEUL;
|
return RoleWinType.SEUL;
|
||||||
|
@ -76,16 +81,16 @@ public class RLoupGarouBlanc extends Role{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasPlayersLeft() {
|
public boolean hasPlayersLeft() {
|
||||||
return super.hasPlayersLeft() && getGame().getNight()%2 == 0;
|
return super.hasPlayersLeft() && getGame().getNight() % 2 == 0;
|
||||||
}
|
}
|
||||||
Runnable callback;
|
|
||||||
@Override
|
@Override
|
||||||
protected void onNightTurn(LGPlayer player, Runnable callback) {
|
protected void onNightTurn(LGPlayer player, Runnable callback) {
|
||||||
this.callback = callback;
|
this.callback = callback;
|
||||||
RLoupGarou lg_ = null;
|
RLoupGarou lg_ = null;
|
||||||
for(Role role : getGame().getRoles())
|
for (Role role : getGame().getRoles())
|
||||||
if(role instanceof RLoupGarou) {
|
if (role instanceof RLoupGarou) {
|
||||||
lg_ = (RLoupGarou)role;
|
lg_ = (RLoupGarou) role;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -93,13 +98,13 @@ public class RLoupGarouBlanc extends Role{
|
||||||
player.showView();
|
player.showView();
|
||||||
player.getPlayer().getInventory().setItem(8, skip);
|
player.getPlayer().getInventory().setItem(8, skip);
|
||||||
player.choose(choosen -> {
|
player.choose(choosen -> {
|
||||||
if(choosen != null && choosen != player) {
|
if (choosen != null && choosen != player) {
|
||||||
if(!lg.getPlayers().contains(choosen)) {
|
if (!lg.getPlayers().contains(choosen)) {
|
||||||
player.sendMessage("§7§l"+choosen.getName()+"§4 n'est pas un Loup-Garou.");
|
player.sendMessage("§7§l" + choosen.getName() + "§4 n'est pas un Loup-Garou.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
player.sendActionBarMessage("§e§l"+choosen.getName()+"§6 va mourir cette nuit");
|
player.sendActionBarMessage("§e§l" + choosen.getName() + "§6 va mourir cette nuit");
|
||||||
player.sendMessage("§6Tu as choisi de dévorer §7§l"+choosen.getName()+"§6.");
|
player.sendMessage("§6Tu as choisi de dévorer §7§l" + choosen.getName() + "§6.");
|
||||||
player.getPlayer().getInventory().setItem(8, null);
|
player.getPlayer().getInventory().setItem(8, null);
|
||||||
player.getPlayer().updateInventory();
|
player.getPlayer().updateInventory();
|
||||||
getGame().kill(choosen, Reason.LOUP_BLANC);
|
getGame().kill(choosen, Reason.LOUP_BLANC);
|
||||||
|
@ -109,11 +114,12 @@ public class RLoupGarouBlanc extends Role{
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onClick(PlayerInteractEvent e) {
|
public void onClick(PlayerInteractEvent e) {
|
||||||
Player p = e.getPlayer();
|
Player p = e.getPlayer();
|
||||||
LGPlayer player = LGPlayer.thePlayer(getGame().getPlugin(), p);
|
LGPlayer player = LGPlayer.thePlayer(getGame().getPlugin(), p);
|
||||||
if(e.getItem() != null && e.getItem().getType() == Material.IRON_NUGGET && player.getRole() == this) {
|
if (e.getItem() != null && e.getItem().getType() == Material.IRON_NUGGET && player.getRole() == this) {
|
||||||
player.stopChoosing();
|
player.stopChoosing();
|
||||||
p.getInventory().setItem(8, null);
|
p.getInventory().setItem(8, null);
|
||||||
p.updateInventory();
|
p.updateInventory();
|
||||||
|
@ -122,6 +128,7 @@ public class RLoupGarouBlanc extends Role{
|
||||||
callback.run();
|
callback.run();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onNightTurnTimeout(LGPlayer player) {
|
protected void onNightTurnTimeout(LGPlayer player) {
|
||||||
player.stopChoosing();
|
player.stopChoosing();
|
||||||
|
@ -131,22 +138,21 @@ public class RLoupGarouBlanc extends Role{
|
||||||
player.sendMessage("§6Tu n'as tué personne.");
|
player.sendMessage("§6Tu n'as tué personne.");
|
||||||
}
|
}
|
||||||
|
|
||||||
RLoupGarou lg;
|
|
||||||
@Override
|
@Override
|
||||||
public void join(LGPlayer player, boolean sendMessage) {
|
public void join(LGPlayer player, boolean sendMessage) {
|
||||||
super.join(player, sendMessage);
|
super.join(player, sendMessage);
|
||||||
for(Role role : getGame().getRoles())
|
for (Role role : getGame().getRoles())
|
||||||
if(role instanceof RLoupGarou)
|
if (role instanceof RLoupGarou)
|
||||||
(lg = (RLoupGarou) role).join(player, false);
|
(lg = (RLoupGarou) role).join(player, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onEndgameCheck(LGEndCheckEvent e) {
|
public void onEndgameCheck(LGEndCheckEvent e) {
|
||||||
if(e.getGame() == getGame() && e.getWinType() == LGWinType.SOLO) {
|
if (e.getGame() == getGame() && e.getWinType() == LGWinType.SOLO) {
|
||||||
if(getPlayers().size() > 0) {
|
if (getPlayers().size() > 0) {
|
||||||
if(lg.getPlayers().size() > getPlayers().size())
|
if (lg.getPlayers().size() > getPlayers().size())
|
||||||
e.setWinType(LGWinType.NONE);
|
e.setWinType(LGWinType.NONE);
|
||||||
else if(lg.getPlayers().size() == getPlayers().size())
|
else if (lg.getPlayers().size() == getPlayers().size())
|
||||||
e.setWinType(LGWinType.LOUPGAROUBLANC);
|
e.setWinType(LGWinType.LOUPGAROUBLANC);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -154,7 +160,7 @@ public class RLoupGarouBlanc extends Role{
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST)
|
@EventHandler(priority = EventPriority.HIGHEST)
|
||||||
public void onEndGame(LGGameEndEvent e) {
|
public void onEndGame(LGGameEndEvent e) {
|
||||||
if(e.getWinType() == LGWinType.LOUPGAROUBLANC) {
|
if (e.getWinType() == LGWinType.LOUPGAROUBLANC) {
|
||||||
e.getWinners().clear();
|
e.getWinners().clear();
|
||||||
e.getWinners().addAll(getPlayers());
|
e.getWinners().addAll(getPlayers());
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,14 @@
|
||||||
package fr.leomelki.loupgarou.roles;
|
package fr.leomelki.loupgarou.roles;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import fr.leomelki.loupgarou.MainLg;
|
||||||
import java.util.Collections;
|
import fr.leomelki.loupgarou.classes.LGCustomItems;
|
||||||
|
import fr.leomelki.loupgarou.classes.LGCustomItems.LGCustomItemsConstraints;
|
||||||
|
import fr.leomelki.loupgarou.classes.LGGame;
|
||||||
|
import fr.leomelki.loupgarou.classes.LGPlayer;
|
||||||
|
import fr.leomelki.loupgarou.classes.LGVote;
|
||||||
|
import fr.leomelki.loupgarou.events.LGCustomItemChangeEvent;
|
||||||
|
import fr.leomelki.loupgarou.events.LGNightEndEvent;
|
||||||
|
import fr.leomelki.loupgarou.events.LGPlayerKilledEvent.Reason;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.craftbukkit.v1_15_R1.inventory.CraftInventoryCustom;
|
import org.bukkit.craftbukkit.v1_15_R1.inventory.CraftInventoryCustom;
|
||||||
|
@ -16,19 +22,13 @@ import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.inventory.meta.ItemMeta;
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
|
||||||
import fr.leomelki.loupgarou.MainLg;
|
import java.util.Arrays;
|
||||||
import fr.leomelki.loupgarou.classes.LGCustomItems;
|
import java.util.Collections;
|
||||||
import fr.leomelki.loupgarou.classes.LGCustomItems.LGCustomItemsConstraints;
|
|
||||||
import fr.leomelki.loupgarou.classes.LGGame;
|
|
||||||
import fr.leomelki.loupgarou.classes.LGPlayer;
|
|
||||||
import fr.leomelki.loupgarou.classes.LGVote;
|
|
||||||
import fr.leomelki.loupgarou.events.LGCustomItemChangeEvent;
|
|
||||||
import fr.leomelki.loupgarou.events.LGNightEndEvent;
|
|
||||||
import fr.leomelki.loupgarou.events.LGPlayerKilledEvent.Reason;
|
|
||||||
|
|
||||||
public class RLoupGarouNoir extends Role{
|
public class RLoupGarouNoir extends Role {
|
||||||
static final ItemStack[] items = new ItemStack[9];
|
static final ItemStack[] items = new ItemStack[9];
|
||||||
static final ItemStack[] skip = new ItemStack[9];
|
static final ItemStack[] skip = new ItemStack[9];
|
||||||
|
|
||||||
static {
|
static {
|
||||||
items[3] = new ItemStack(Material.IRON_NUGGET);
|
items[3] = new ItemStack(Material.IRON_NUGGET);
|
||||||
ItemMeta meta = items[3].getItemMeta();
|
ItemMeta meta = items[3].getItemMeta();
|
||||||
|
@ -45,6 +45,11 @@ public class RLoupGarouNoir extends Role{
|
||||||
skip[4] = items[3];
|
skip[4] = items[3];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LGVote vote;
|
||||||
|
Runnable callback;
|
||||||
|
LGPlayer toInfect;
|
||||||
|
boolean inMenu = false;
|
||||||
|
|
||||||
public RLoupGarouNoir(LGGame game) {
|
public RLoupGarouNoir(LGGame game) {
|
||||||
super(game);
|
super(game);
|
||||||
}
|
}
|
||||||
|
@ -56,7 +61,7 @@ public class RLoupGarouNoir extends Role{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getFriendlyName() {
|
public String getFriendlyName() {
|
||||||
return "du "+getName();
|
return "du " + getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -76,12 +81,14 @@ public class RLoupGarouNoir extends Role{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getBroadcastedTask() {
|
public String getBroadcastedTask() {
|
||||||
return "Le "+getName()+"§9 décide s'il veut infecter sa cible.";
|
return "Le " + getName() + "§9 décide s'il veut infecter sa cible.";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public RoleType getType() {
|
public RoleType getType() {
|
||||||
return RoleType.LOUP_GAROU;
|
return RoleType.LOUP_GAROU;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public RoleWinType getWinType() {
|
public RoleWinType getWinType() {
|
||||||
return RoleWinType.LOUP_GAROU;
|
return RoleWinType.LOUP_GAROU;
|
||||||
|
@ -97,26 +104,24 @@ public class RLoupGarouNoir extends Role{
|
||||||
return super.hasPlayersLeft() && getGame().getDeaths().containsKey(Reason.LOUP_GAROU);
|
return super.hasPlayersLeft() && getGame().getDeaths().containsKey(Reason.LOUP_GAROU);
|
||||||
}
|
}
|
||||||
|
|
||||||
LGVote vote;
|
|
||||||
Runnable callback;
|
|
||||||
LGPlayer toInfect;
|
|
||||||
|
|
||||||
public void openInventory(Player player) {
|
public void openInventory(Player player) {
|
||||||
inMenu = true;
|
inMenu = true;
|
||||||
Inventory inventory = Bukkit.createInventory(null, 9, "§7Infecter "+toInfect.getName()+" ?");
|
Inventory inventory = Bukkit.createInventory(null, 9, "§7Infecter " + toInfect.getName() + " ?");
|
||||||
inventory.setContents(toInfect == null ? skip.clone() : items.clone());
|
inventory.setContents(toInfect == null ? skip.clone() : items.clone());
|
||||||
player.closeInventory();
|
player.closeInventory();
|
||||||
player.openInventory(inventory);
|
player.openInventory(inventory);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onNightTurn(LGPlayer player, Runnable callback) {
|
protected void onNightTurn(LGPlayer player, Runnable callback) {
|
||||||
toInfect = getGame().getDeaths().get(Reason.LOUP_GAROU);
|
toInfect = getGame().getDeaths().get(Reason.LOUP_GAROU);
|
||||||
if(toInfect.getRoleType() == RoleType.LOUP_GAROU)
|
if (toInfect.getRoleType() == RoleType.LOUP_GAROU)
|
||||||
toInfect = null;
|
toInfect = null;
|
||||||
player.showView();
|
player.showView();
|
||||||
this.callback = callback;
|
this.callback = callback;
|
||||||
openInventory(player.getPlayer());
|
openInventory(player.getPlayer());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onNightTurnTimeout(LGPlayer player) {
|
protected void onNightTurnTimeout(LGPlayer player) {
|
||||||
player.getPlayer().getInventory().setItem(8, null);
|
player.getPlayer().getInventory().setItem(8, null);
|
||||||
|
@ -128,27 +133,26 @@ public class RLoupGarouNoir extends Role{
|
||||||
player.sendMessage("§6Tu n'as rien fait cette nuit.");
|
player.sendMessage("§6Tu n'as rien fait cette nuit.");
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean inMenu = false;
|
|
||||||
|
|
||||||
private void closeInventory(Player p) {
|
private void closeInventory(Player p) {
|
||||||
inMenu = false;
|
inMenu = false;
|
||||||
p.closeInventory();
|
p.closeInventory();
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onInventoryClick(InventoryClickEvent e) {
|
public void onInventoryClick(InventoryClickEvent e) {
|
||||||
ItemStack item = e.getCurrentItem();
|
ItemStack item = e.getCurrentItem();
|
||||||
Player player = (Player)e.getWhoClicked();
|
Player player = (Player) e.getWhoClicked();
|
||||||
LGPlayer lgp = LGPlayer.thePlayer(getGame().getPlugin(), player);
|
LGPlayer lgp = LGPlayer.thePlayer(getGame().getPlugin(), player);
|
||||||
|
|
||||||
if(lgp.getRole() != this || item == null || item.getItemMeta() == null)return;
|
if (lgp.getRole() != this || item == null || item.getItemMeta() == null) return;
|
||||||
|
|
||||||
if(item.getItemMeta().getDisplayName().equals(items[3].getItemMeta().getDisplayName())) {
|
if (item.getItemMeta().getDisplayName().equals(items[3].getItemMeta().getDisplayName())) {
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
closeInventory(player);
|
closeInventory(player);
|
||||||
lgp.sendMessage("§6Tu n'as rien fait cette nuit.");
|
lgp.sendMessage("§6Tu n'as rien fait cette nuit.");
|
||||||
lgp.hideView();
|
lgp.hideView();
|
||||||
callback.run();
|
callback.run();
|
||||||
}else if(item.getItemMeta().getDisplayName().equals(items[5].getItemMeta().getDisplayName()) && toInfect != null) {
|
} else if (item.getItemMeta().getDisplayName().equals(items[5].getItemMeta().getDisplayName()) && toInfect != null) {
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
closeInventory(player);
|
closeInventory(player);
|
||||||
player.updateInventory();
|
player.updateInventory();
|
||||||
|
@ -158,37 +162,38 @@ public class RLoupGarouNoir extends Role{
|
||||||
toInfect.getCache().set("infected", true);
|
toInfect.getCache().set("infected", true);
|
||||||
getPlayers().remove(lgp);
|
getPlayers().remove(lgp);
|
||||||
toInfect.getCache().set("just_infected", true);
|
toInfect.getCache().set("just_infected", true);
|
||||||
lgp.sendActionBarMessage("§9§lVous infectez §9"+toInfect.getName());
|
lgp.sendActionBarMessage("§9§lVous infectez §9" + toInfect.getName());
|
||||||
lgp.sendMessage("§6Tu as infecté §7§l"+toInfect.getName()+"§6.");
|
lgp.sendMessage("§6Tu as infecté §7§l" + toInfect.getName() + "§6.");
|
||||||
lgp.stopChoosing();
|
lgp.stopChoosing();
|
||||||
getGame().getDeaths().remove(Reason.LOUP_GAROU, toInfect);
|
getGame().getDeaths().remove(Reason.LOUP_GAROU, toInfect);
|
||||||
lgp.hideView();
|
lgp.hideView();
|
||||||
callback.run();
|
callback.run();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST)
|
@EventHandler(priority = EventPriority.HIGHEST)
|
||||||
public void onDayStart(LGNightEndEvent e) {
|
public void onDayStart(LGNightEndEvent e) {
|
||||||
if(e.getGame() == getGame())
|
if (e.getGame() == getGame())
|
||||||
for(LGPlayer player : getGame().getAlive()) {
|
for (LGPlayer player : getGame().getAlive()) {
|
||||||
if(player.getCache().getBoolean("just_infected")) {
|
if (player.getCache().getBoolean("just_infected")) {
|
||||||
player.getCache().remove("just_infected");
|
player.getCache().remove("just_infected");
|
||||||
player.sendMessage("§6Tu as été infecté pendant la nuit.");
|
player.sendMessage("§6Tu as été infecté pendant la nuit.");
|
||||||
player.sendMessage("§6§oTu gagnes désormais avec les §c§l§oLoups-Garous§6§o.");
|
player.sendMessage("§6§oTu gagnes désormais avec les §c§l§oLoups-Garous§6§o.");
|
||||||
for(Role role : getGame().getRoles())
|
for (Role role : getGame().getRoles())
|
||||||
if(role instanceof RLoupGarou)
|
if (role instanceof RLoupGarou)
|
||||||
if(!player.isDead()) {//Si il n'a pas été tué je ne sais comment
|
if (!player.isDead()) {//Si il n'a pas été tué je ne sais comment
|
||||||
role.join(player, false);
|
role.join(player, false);
|
||||||
player.getPlayer().getInventory().setItemInOffHand(new ItemStack(LGCustomItems.getItem(player)));
|
player.getPlayer().getInventory().setItemInOffHand(new ItemStack(LGCustomItems.getItem(player)));
|
||||||
}
|
}
|
||||||
|
|
||||||
for(LGPlayer lgp : getGame().getInGame()) {
|
for (LGPlayer lgp : getGame().getInGame()) {
|
||||||
if(lgp.getRoleType() == RoleType.LOUP_GAROU)
|
if (lgp.getRoleType() == RoleType.LOUP_GAROU)
|
||||||
lgp.sendMessage("§7§l"+player.getName()+"§6 s'est fait infecter pendant la nuit.");
|
lgp.sendMessage("§7§l" + player.getName() + "§6 s'est fait infecter pendant la nuit.");
|
||||||
else
|
else
|
||||||
lgp.sendMessage("§6Un joueur a été §c§linfecté§6 pendant la nuit.");
|
lgp.sendMessage("§6Un joueur a été §c§linfecté§6 pendant la nuit.");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(getGame().checkEndGame())
|
if (getGame().checkEndGame())
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -197,16 +202,16 @@ public class RLoupGarouNoir extends Role{
|
||||||
@Override
|
@Override
|
||||||
public void join(LGPlayer player, boolean sendMessage) {
|
public void join(LGPlayer player, boolean sendMessage) {
|
||||||
super.join(player, sendMessage);
|
super.join(player, sendMessage);
|
||||||
for(Role role : getGame().getRoles())
|
for (Role role : getGame().getRoles())
|
||||||
if(role instanceof RLoupGarou)
|
if (role instanceof RLoupGarou)
|
||||||
role.join(player, false);
|
role.join(player, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onQuitInventory(InventoryCloseEvent e) {
|
public void onQuitInventory(InventoryCloseEvent e) {
|
||||||
if(e.getInventory() instanceof CraftInventoryCustom) {
|
if (e.getInventory() instanceof CraftInventoryCustom) {
|
||||||
LGPlayer player = LGPlayer.thePlayer(getGame().getPlugin(), (Player)e.getPlayer());
|
LGPlayer player = LGPlayer.thePlayer(getGame().getPlugin(), (Player) e.getPlayer());
|
||||||
if(player.getRole() == this && inMenu) {
|
if (player.getRole() == this && inMenu) {
|
||||||
new BukkitRunnable() {
|
new BukkitRunnable() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -220,8 +225,8 @@ public class RLoupGarouNoir extends Role{
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onCustomItemChange(LGCustomItemChangeEvent e) {
|
public void onCustomItemChange(LGCustomItemChangeEvent e) {
|
||||||
if(e.getGame() == getGame())
|
if (e.getGame() == getGame())
|
||||||
if(e.getPlayer().getCache().getBoolean("infected"))
|
if (e.getPlayer().getCache().getBoolean("infected"))
|
||||||
e.getConstraints().add(LGCustomItemsConstraints.INFECTED.getName());
|
e.getConstraints().add(LGCustomItemsConstraints.INFECTED.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,50 +1,58 @@
|
||||||
package fr.leomelki.loupgarou.roles;
|
package fr.leomelki.loupgarou.roles;
|
||||||
|
|
||||||
import org.bukkit.event.EventHandler;
|
|
||||||
|
|
||||||
import fr.leomelki.loupgarou.classes.LGGame;
|
import fr.leomelki.loupgarou.classes.LGGame;
|
||||||
import fr.leomelki.loupgarou.classes.LGPlayer;
|
import fr.leomelki.loupgarou.classes.LGPlayer;
|
||||||
import fr.leomelki.loupgarou.classes.chat.LGChat;
|
import fr.leomelki.loupgarou.classes.chat.LGChat;
|
||||||
import fr.leomelki.loupgarou.events.LGDayEndEvent;
|
import fr.leomelki.loupgarou.events.LGDayEndEvent;
|
||||||
import fr.leomelki.loupgarou.events.LGPreDayStartEvent;
|
import fr.leomelki.loupgarou.events.LGPreDayStartEvent;
|
||||||
import fr.leomelki.loupgarou.events.LGRoleTurnEndEvent;
|
import fr.leomelki.loupgarou.events.LGRoleTurnEndEvent;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
|
||||||
public class RMedium extends Role{
|
public class RMedium extends Role {
|
||||||
public RMedium(LGGame game) {
|
public RMedium(LGGame game) {
|
||||||
super(game);
|
super(game);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public RoleType getType() {
|
public RoleType getType() {
|
||||||
return RoleType.VILLAGER;
|
return RoleType.VILLAGER;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public RoleWinType getWinType() {
|
public RoleWinType getWinType() {
|
||||||
return RoleWinType.VILLAGE;
|
return RoleWinType.VILLAGE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return "§a§lMédium";
|
return "§a§lMédium";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getFriendlyName() {
|
public String getFriendlyName() {
|
||||||
return "du "+getName();
|
return "du " + getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getShortDescription() {
|
public String getShortDescription() {
|
||||||
return "Tu gagnes avec le §a§lVillage";
|
return "Tu gagnes avec le §a§lVillage";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getDescription() {
|
public String getDescription() {
|
||||||
return "Tu gagnes avec le §a§lVillage§f. Chaque nuit, tu peux communiquer avec les morts pour tenter de récupérer des informations cruciales.";
|
return "Tu gagnes avec le §a§lVillage§f. Chaque nuit, tu peux communiquer avec les morts pour tenter de récupérer des informations cruciales.";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getTask() {
|
public String getTask() {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getBroadcastedTask() {
|
public String getBroadcastedTask() {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getTimeout() {
|
public int getTimeout() {
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -52,8 +60,8 @@ public class RMedium extends Role{
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onNight(LGDayEndEvent e) {
|
public void onNight(LGDayEndEvent e) {
|
||||||
if(e.getGame() == getGame())
|
if (e.getGame() == getGame())
|
||||||
for(LGPlayer lgp : getPlayers()) {
|
for (LGPlayer lgp : getPlayers()) {
|
||||||
lgp.sendMessage("§8§oTu entres en contact avec le monde des morts...");
|
lgp.sendMessage("§8§oTu entres en contact avec le monde des morts...");
|
||||||
joinChat(lgp);
|
joinChat(lgp);
|
||||||
}
|
}
|
||||||
|
@ -65,22 +73,23 @@ public class RMedium extends Role{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String receive(LGPlayer sender, String message) {
|
public String receive(LGPlayer sender, String message) {
|
||||||
return "§7"+sender.getName()+"§6 » §f"+message;
|
return "§7" + sender.getName() + "§6 » §f" + message;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String send(LGPlayer sender, String message) {
|
public String send(LGPlayer sender, String message) {
|
||||||
return getName()+"§6 » §f"+message;
|
return getName() + "§6 » §f" + message;
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onRoleTurn(LGRoleTurnEndEvent e) {
|
public void onRoleTurn(LGRoleTurnEndEvent e) {
|
||||||
if(e.getGame() == getGame())
|
if (e.getGame() == getGame())
|
||||||
if(e.getPreviousRole() instanceof RLoupGarou)
|
if (e.getPreviousRole() instanceof RLoupGarou)
|
||||||
for(LGPlayer lgp : getPlayers())
|
for (LGPlayer lgp : getPlayers())
|
||||||
if(lgp.getChat() != getGame().getSpectatorChat() && lgp.isRoleActive()) {
|
if (lgp.getChat() != getGame().getSpectatorChat() && lgp.isRoleActive()) {
|
||||||
lgp.sendMessage("§6§oTu peux de nouveau parler aux morts...");
|
lgp.sendMessage("§6§oTu peux de nouveau parler aux morts...");
|
||||||
joinChat(lgp);
|
joinChat(lgp);
|
||||||
}
|
}
|
||||||
|
@ -88,9 +97,9 @@ public class RMedium extends Role{
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onDay(LGPreDayStartEvent e) {
|
public void onDay(LGPreDayStartEvent e) {
|
||||||
if(e.getGame() == getGame())
|
if (e.getGame() == getGame())
|
||||||
for(LGPlayer lgp : getPlayers())
|
for (LGPlayer lgp : getPlayers())
|
||||||
if(lgp.isRoleActive())
|
if (lgp.isRoleActive())
|
||||||
lgp.leaveChat();
|
lgp.leaveChat();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,97 +1,105 @@
|
||||||
package fr.leomelki.loupgarou.roles;
|
package fr.leomelki.loupgarou.roles;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Random;
|
|
||||||
|
|
||||||
import org.bukkit.event.EventHandler;
|
|
||||||
import org.bukkit.event.EventPriority;
|
|
||||||
|
|
||||||
import fr.leomelki.loupgarou.MainLg;
|
import fr.leomelki.loupgarou.MainLg;
|
||||||
import fr.leomelki.loupgarou.classes.LGGame;
|
import fr.leomelki.loupgarou.classes.LGGame;
|
||||||
import fr.leomelki.loupgarou.classes.LGPlayer;
|
import fr.leomelki.loupgarou.classes.LGPlayer;
|
||||||
import fr.leomelki.loupgarou.events.LGDayStartEvent;
|
import fr.leomelki.loupgarou.events.LGDayStartEvent;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.EventPriority;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
|
public class RMontreurDOurs extends Role {
|
||||||
|
private static final Random random = new Random();
|
||||||
|
private int lastNight = -1;
|
||||||
|
|
||||||
public class RMontreurDOurs extends Role{
|
|
||||||
public RMontreurDOurs(LGGame game) {
|
public RMontreurDOurs(LGGame game) {
|
||||||
super(game);
|
super(game);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public RoleType getType() {
|
public RoleType getType() {
|
||||||
return RoleType.VILLAGER;
|
return RoleType.VILLAGER;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public RoleWinType getWinType() {
|
public RoleWinType getWinType() {
|
||||||
return RoleWinType.VILLAGE;
|
return RoleWinType.VILLAGE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return "§a§lMontreur d'Ours";
|
return "§a§lMontreur d'Ours";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getFriendlyName() {
|
public String getFriendlyName() {
|
||||||
return "du "+getName();
|
return "du " + getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getShortDescription() {
|
public String getShortDescription() {
|
||||||
return "Tu gagnes avec le §a§lVillage";
|
return "Tu gagnes avec le §a§lVillage";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getDescription() {
|
public String getDescription() {
|
||||||
return "Tu gagnes avec le §a§lVillage§f. Chaque matin, ton Ours va renifler tes voisins et grognera si l'un d'eux est hostile aux Villageois.";
|
return "Tu gagnes avec le §a§lVillage§f. Chaque matin, ton Ours va renifler tes voisins et grognera si l'un d'eux est hostile aux Villageois.";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getTask() {
|
public String getTask() {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getBroadcastedTask() {
|
public String getBroadcastedTask() {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getTimeout() {
|
public int getTimeout() {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final Random random = new Random();
|
|
||||||
private int lastNight = -1;
|
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.LOWEST)
|
@EventHandler(priority = EventPriority.LOWEST)
|
||||||
public void onDay(LGDayStartEvent e) {
|
public void onDay(LGDayStartEvent e) {
|
||||||
if (e.getGame() == getGame() && getPlayers().size() > 0) {
|
if (e.getGame() == getGame() && getPlayers().size() > 0) {
|
||||||
if(lastNight == getGame().getNight())
|
if (lastNight == getGame().getNight())
|
||||||
return;
|
return;
|
||||||
lastNight = getGame().getNight();
|
lastNight = getGame().getNight();
|
||||||
List<?> original = MainLg.getInstance().getConfig().getList("spawns");
|
List<?> original = MainLg.getInstance().getConfig().getList("spawns");
|
||||||
for(LGPlayer target : getPlayers()) {
|
for (LGPlayer target : getPlayers()) {
|
||||||
if(!target.isRoleActive())
|
if (!target.isRoleActive())
|
||||||
continue;
|
continue;
|
||||||
int size = original.size();
|
int size = original.size();
|
||||||
int killedPlace = target.getPlace();
|
int killedPlace = target.getPlace();
|
||||||
|
|
||||||
for (int i = killedPlace + 1;; i++) {
|
for (int i = killedPlace + 1; ; i++) {
|
||||||
if (i == size)
|
if (i == size)
|
||||||
i = 0;
|
i = 0;
|
||||||
LGPlayer lgp = getGame().getPlacements().get(i);
|
LGPlayer lgp = getGame().getPlacements().get(i);
|
||||||
if (lgp != null && !lgp.isDead()) {
|
if (lgp != null && !lgp.isDead()) {
|
||||||
if(lgp.getRoleWinType() == RoleWinType.VILLAGE || lgp.getRoleWinType() == RoleWinType.NONE)
|
if (lgp.getRoleWinType() == RoleWinType.VILLAGE || lgp.getRoleWinType() == RoleWinType.NONE)
|
||||||
break;
|
break;
|
||||||
else{
|
else {
|
||||||
getGame().broadcastMessage("§6La bête du "+getName()+"§6 grogne...");
|
getGame().broadcastMessage("§6La bête du " + getName() + "§6 grogne...");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (lgp == target)// Fait un tour complet
|
if (lgp == target)// Fait un tour complet
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
for (int i = killedPlace - 1;; i--) {
|
for (int i = killedPlace - 1; ; i--) {
|
||||||
if (i == -1)
|
if (i == -1)
|
||||||
i = size - 1;
|
i = size - 1;
|
||||||
LGPlayer lgp = getGame().getPlacements().get(i);
|
LGPlayer lgp = getGame().getPlacements().get(i);
|
||||||
if (lgp != null && !lgp.isDead()) {
|
if (lgp != null && !lgp.isDead()) {
|
||||||
if(lgp.getRoleWinType() == RoleWinType.VILLAGE || lgp.getRoleWinType() == RoleWinType.NONE)
|
if (lgp.getRoleWinType() == RoleWinType.VILLAGE || lgp.getRoleWinType() == RoleWinType.NONE)
|
||||||
break;
|
break;
|
||||||
else{
|
else {
|
||||||
getGame().broadcastMessage("§6La bête du "+getName()+"§6 grogne...");
|
getGame().broadcastMessage("§6La bête du " + getName() + "§6 grogne...");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,72 +1,80 @@
|
||||||
package fr.leomelki.loupgarou.roles;
|
package fr.leomelki.loupgarou.roles;
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.bukkit.event.EventHandler;
|
|
||||||
|
|
||||||
import fr.leomelki.loupgarou.classes.LGGame;
|
import fr.leomelki.loupgarou.classes.LGGame;
|
||||||
import fr.leomelki.loupgarou.classes.LGPlayer;
|
import fr.leomelki.loupgarou.classes.LGPlayer;
|
||||||
import fr.leomelki.loupgarou.events.LGRoleTurnEndEvent;
|
import fr.leomelki.loupgarou.events.LGRoleTurnEndEvent;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class RPetiteFille extends Role {
|
||||||
|
final List<String> customNames = Arrays.asList("Loup Glouton", "Loup Méchant", "Loup Burlesque", "Loup Peureux", "Loup Malingre", "Loup Gentil", "Loup Tueur", "Loup Énervé", "Loup Docteur");
|
||||||
|
|
||||||
public class RPetiteFille extends Role{
|
|
||||||
public RPetiteFille(LGGame game) {
|
public RPetiteFille(LGGame game) {
|
||||||
super(game);
|
super(game);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public RoleType getType() {
|
public RoleType getType() {
|
||||||
return RoleType.VILLAGER;
|
return RoleType.VILLAGER;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public RoleWinType getWinType() {
|
public RoleWinType getWinType() {
|
||||||
return RoleWinType.VILLAGE;
|
return RoleWinType.VILLAGE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return "§a§lPetite Fille";
|
return "§a§lPetite Fille";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getFriendlyName() {
|
public String getFriendlyName() {
|
||||||
return "de la "+getName();
|
return "de la " + getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getShortDescription() {
|
public String getShortDescription() {
|
||||||
return "Tu gagnes avec le §a§lVillage";
|
return "Tu gagnes avec le §a§lVillage";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getDescription() {
|
public String getDescription() {
|
||||||
return "Tu gagnes avec le §a§lVillage§f. Chaque nuit, tu peux espionner les §c§lLoups§f.";
|
return "Tu gagnes avec le §a§lVillage§f. Chaque nuit, tu peux espionner les §c§lLoups§f.";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getTask() {
|
public String getTask() {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getBroadcastedTask() {
|
public String getBroadcastedTask() {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getTimeout() {
|
public int getTimeout() {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
final List<String> customNames = Arrays.asList("Loup Glouton", "Loup Méchant", "Loup Burlesque", "Loup Peureux", "Loup Malingre", "Loup Gentil", "Loup Tueur", "Loup Énervé", "Loup Docteur");
|
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onChangeRole(LGRoleTurnEndEvent e) {
|
public void onChangeRole(LGRoleTurnEndEvent e) {
|
||||||
if(e.getGame() == getGame()) {
|
if (e.getGame() == getGame()) {
|
||||||
if(e.getNewRole() instanceof RLoupGarou)
|
if (e.getNewRole() instanceof RLoupGarou)
|
||||||
for(Role role : getGame().getRoles())
|
for (Role role : getGame().getRoles())
|
||||||
if(role instanceof RLoupGarou) {
|
if (role instanceof RLoupGarou) {
|
||||||
RLoupGarou lgRole = (RLoupGarou)role;
|
RLoupGarou lgRole = (RLoupGarou) role;
|
||||||
for(LGPlayer player : getPlayers())
|
for (LGPlayer player : getPlayers())
|
||||||
if(!player.getCache().getBoolean("infected") && player.isRoleActive())
|
if (!player.getCache().getBoolean("infected") && player.isRoleActive())
|
||||||
player.joinChat(lgRole.getChat(), (sender, message)-> "§c"+customNames.get(lgRole.getPlayers().indexOf(sender))+" §6» §f"+message, true);
|
player.joinChat(lgRole.getChat(), (sender, message) -> "§c" + customNames.get(lgRole.getPlayers().indexOf(sender)) + " §6» §f" + message, true);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if(e.getPreviousRole() instanceof RLoupGarou)
|
if (e.getPreviousRole() instanceof RLoupGarou)
|
||||||
for(LGPlayer player : getPlayers())
|
for (LGPlayer player : getPlayers())
|
||||||
if(!player.getCache().getBoolean("infected") && player.isRoleActive())
|
if (!player.getCache().getBoolean("infected") && player.isRoleActive())
|
||||||
player.leaveChat();
|
player.leaveChat();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,11 @@
|
||||||
package fr.leomelki.loupgarou.roles;
|
package fr.leomelki.loupgarou.roles;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import fr.leomelki.com.comphenix.packetwrapper.WrapperPlayServerHeldItemSlot;
|
||||||
import java.util.Collections;
|
import fr.leomelki.loupgarou.MainLg;
|
||||||
|
import fr.leomelki.loupgarou.classes.LGGame;
|
||||||
|
import fr.leomelki.loupgarou.classes.LGPlayer;
|
||||||
|
import fr.leomelki.loupgarou.events.LGPlayerKilledEvent;
|
||||||
|
import fr.leomelki.loupgarou.events.LGPlayerKilledEvent.Reason;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.craftbukkit.v1_15_R1.inventory.CraftInventoryCustom;
|
import org.bukkit.craftbukkit.v1_15_R1.inventory.CraftInventoryCustom;
|
||||||
|
@ -17,15 +20,12 @@ import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.inventory.meta.ItemMeta;
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
|
||||||
import fr.leomelki.com.comphenix.packetwrapper.WrapperPlayServerHeldItemSlot;
|
import java.util.Arrays;
|
||||||
import fr.leomelki.loupgarou.MainLg;
|
import java.util.Collections;
|
||||||
import fr.leomelki.loupgarou.classes.LGGame;
|
|
||||||
import fr.leomelki.loupgarou.classes.LGPlayer;
|
|
||||||
import fr.leomelki.loupgarou.events.LGPlayerKilledEvent;
|
|
||||||
import fr.leomelki.loupgarou.events.LGPlayerKilledEvent.Reason;
|
|
||||||
|
|
||||||
public class RPirate extends Role{
|
public class RPirate extends Role {
|
||||||
static final ItemStack[] items = new ItemStack[9];
|
static final ItemStack[] items = new ItemStack[9];
|
||||||
|
|
||||||
static {
|
static {
|
||||||
items[3] = new ItemStack(Material.IRON_NUGGET);
|
items[3] = new ItemStack(Material.IRON_NUGGET);
|
||||||
ItemMeta meta = items[3].getItemMeta();
|
ItemMeta meta = items[3].getItemMeta();
|
||||||
|
@ -41,6 +41,9 @@ public class RPirate extends Role{
|
||||||
items[5].setItemMeta(meta);
|
items[5].setItemMeta(meta);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Runnable callback;
|
||||||
|
boolean inMenu = false;
|
||||||
|
|
||||||
public RPirate(LGGame game) {
|
public RPirate(LGGame game) {
|
||||||
super(game);
|
super(game);
|
||||||
}
|
}
|
||||||
|
@ -52,7 +55,7 @@ public class RPirate extends Role{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getFriendlyName() {
|
public String getFriendlyName() {
|
||||||
return "du "+getName();
|
return "du " + getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -72,12 +75,14 @@ public class RPirate extends Role{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getBroadcastedTask() {
|
public String getBroadcastedTask() {
|
||||||
return "Le "+getName()+"§9 aiguise son crochet...";
|
return "Le " + getName() + "§9 aiguise son crochet...";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public RoleType getType() {
|
public RoleType getType() {
|
||||||
return RoleType.VILLAGER;
|
return RoleType.VILLAGER;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public RoleWinType getWinType() {
|
public RoleWinType getWinType() {
|
||||||
return RoleWinType.VILLAGE;
|
return RoleWinType.VILLAGE;
|
||||||
|
@ -88,8 +93,6 @@ public class RPirate extends Role{
|
||||||
return 15;
|
return 15;
|
||||||
}
|
}
|
||||||
|
|
||||||
Runnable callback;
|
|
||||||
|
|
||||||
public void openInventory(Player player) {
|
public void openInventory(Player player) {
|
||||||
inMenu = true;
|
inMenu = true;
|
||||||
Inventory inventory = Bukkit.createInventory(null, 9, "§7Veux-tu prendre un otage ?");
|
Inventory inventory = Bukkit.createInventory(null, 9, "§7Veux-tu prendre un otage ?");
|
||||||
|
@ -97,12 +100,14 @@ public class RPirate extends Role{
|
||||||
player.closeInventory();
|
player.closeInventory();
|
||||||
player.openInventory(inventory);
|
player.openInventory(inventory);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onNightTurn(LGPlayer player, Runnable callback) {
|
protected void onNightTurn(LGPlayer player, Runnable callback) {
|
||||||
player.showView();
|
player.showView();
|
||||||
this.callback = callback;
|
this.callback = callback;
|
||||||
openInventory(player.getPlayer());
|
openInventory(player.getPlayer());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onNightTurnTimeout(LGPlayer player) {
|
protected void onNightTurnTimeout(LGPlayer player) {
|
||||||
player.getPlayer().getInventory().setItem(8, null);
|
player.getPlayer().getInventory().setItem(8, null);
|
||||||
|
@ -114,27 +119,26 @@ public class RPirate extends Role{
|
||||||
player.sendMessage("§6Tu n'as rien fait cette nuit.");
|
player.sendMessage("§6Tu n'as rien fait cette nuit.");
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean inMenu = false;
|
|
||||||
|
|
||||||
private void closeInventory(Player p) {
|
private void closeInventory(Player p) {
|
||||||
inMenu = false;
|
inMenu = false;
|
||||||
p.closeInventory();
|
p.closeInventory();
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onInventoryClick(InventoryClickEvent e) {
|
public void onInventoryClick(InventoryClickEvent e) {
|
||||||
ItemStack item = e.getCurrentItem();
|
ItemStack item = e.getCurrentItem();
|
||||||
Player player = (Player)e.getWhoClicked();
|
Player player = (Player) e.getWhoClicked();
|
||||||
LGPlayer lgp = LGPlayer.thePlayer(getGame().getPlugin(), player);
|
LGPlayer lgp = LGPlayer.thePlayer(getGame().getPlugin(), player);
|
||||||
|
|
||||||
if(lgp.getRole() != this || item == null || item.getItemMeta() == null)return;
|
if (lgp.getRole() != this || item == null || item.getItemMeta() == null) return;
|
||||||
|
|
||||||
if(item.getItemMeta().getDisplayName().equals(items[3].getItemMeta().getDisplayName())) {
|
if (item.getItemMeta().getDisplayName().equals(items[3].getItemMeta().getDisplayName())) {
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
closeInventory(player);
|
closeInventory(player);
|
||||||
lgp.sendMessage("§6Tu n'as rien fait cette nuit.");
|
lgp.sendMessage("§6Tu n'as rien fait cette nuit.");
|
||||||
lgp.hideView();
|
lgp.hideView();
|
||||||
callback.run();
|
callback.run();
|
||||||
}else if(item.getItemMeta().getDisplayName().equals(items[5].getItemMeta().getDisplayName())) {
|
} else if (item.getItemMeta().getDisplayName().equals(items[5].getItemMeta().getDisplayName())) {
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
closeInventory(player);
|
closeInventory(player);
|
||||||
player.getInventory().setItem(8, items[3]);
|
player.getInventory().setItem(8, items[3]);
|
||||||
|
@ -145,29 +149,30 @@ public class RPirate extends Role{
|
||||||
held.sendPacket(player);
|
held.sendPacket(player);
|
||||||
lgp.sendMessage("§6Choisissez votre otage.");
|
lgp.sendMessage("§6Choisissez votre otage.");
|
||||||
lgp.choose(choosen -> {
|
lgp.choose(choosen -> {
|
||||||
if(choosen != null) {
|
if (choosen != null) {
|
||||||
player.getInventory().setItem(8, null);
|
player.getInventory().setItem(8, null);
|
||||||
player.updateInventory();
|
player.updateInventory();
|
||||||
lgp.stopChoosing();
|
lgp.stopChoosing();
|
||||||
lgp.sendMessage("§6Tu as pris §7§l"+choosen.getName()+"§6 en otage.");
|
lgp.sendMessage("§6Tu as pris §7§l" + choosen.getName() + "§6 en otage.");
|
||||||
lgp.sendActionBarMessage("§7§l"+choosen.getName()+"§6 est ton otage");
|
lgp.sendActionBarMessage("§7§l" + choosen.getName() + "§6 est ton otage");
|
||||||
lgp.getCache().set("pirate_otage", choosen);
|
lgp.getCache().set("pirate_otage", choosen);
|
||||||
choosen.getCache().set("pirate_otage_d", lgp);
|
choosen.getCache().set("pirate_otage_d", lgp);
|
||||||
getPlayers().remove(lgp);//Pour éviter qu'il puisse prendre plusieurs otages
|
getPlayers().remove(lgp);//Pour éviter qu'il puisse prendre plusieurs otages
|
||||||
choosen.sendMessage("§7§l"+lgp.getName()+"§6 t'a pris en otage, il est "+getName()+"§6.");
|
choosen.sendMessage("§7§l" + lgp.getName() + "§6 t'a pris en otage, il est " + getName() + "§6.");
|
||||||
lgp.hideView();
|
lgp.hideView();
|
||||||
callback.run();
|
callback.run();
|
||||||
}
|
}
|
||||||
}, lgp);
|
}, lgp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.LOWEST)
|
@EventHandler(priority = EventPriority.LOWEST)
|
||||||
public void onPlayerKilled(LGPlayerKilledEvent e) {
|
public void onPlayerKilled(LGPlayerKilledEvent e) {
|
||||||
if(e.getGame() == getGame() && e.getReason() == Reason.VOTE)
|
if (e.getGame() == getGame() && e.getReason() == Reason.VOTE)
|
||||||
if(e.getKilled().getCache().has("pirate_otage") && e.getKilled().isRoleActive()) {
|
if (e.getKilled().getCache().has("pirate_otage") && e.getKilled().isRoleActive()) {
|
||||||
LGPlayer otage = e.getKilled().getCache().remove("pirate_otage");
|
LGPlayer otage = e.getKilled().getCache().remove("pirate_otage");
|
||||||
if(!otage.isDead() && otage.getCache().get("pirate_otage_d") == e.getKilled()) {
|
if (!otage.isDead() && otage.getCache().get("pirate_otage_d") == e.getKilled()) {
|
||||||
getGame().broadcastMessage("§7§l"+e.getKilled().getName()+"§6 est "+getName()+"§6, c'est son otage qui va mourir.");
|
getGame().broadcastMessage("§7§l" + e.getKilled().getName() + "§6 est " + getName() + "§6, c'est son otage qui va mourir.");
|
||||||
e.setKilled(otage);
|
e.setKilled(otage);
|
||||||
e.setReason(Reason.PIRATE);
|
e.setReason(Reason.PIRATE);
|
||||||
}
|
}
|
||||||
|
@ -178,8 +183,8 @@ public class RPirate extends Role{
|
||||||
public void onClick(PlayerInteractEvent e) {
|
public void onClick(PlayerInteractEvent e) {
|
||||||
Player player = e.getPlayer();
|
Player player = e.getPlayer();
|
||||||
LGPlayer lgp = LGPlayer.thePlayer(getGame().getPlugin(), player);
|
LGPlayer lgp = LGPlayer.thePlayer(getGame().getPlugin(), player);
|
||||||
if(lgp.getRole() == this) {
|
if (lgp.getRole() == this) {
|
||||||
if(e.getItem() != null && e.getItem().hasItemMeta() && e.getItem().getItemMeta().getDisplayName().equals(items[3].getItemMeta().getDisplayName())) {
|
if (e.getItem() != null && e.getItem().hasItemMeta() && e.getItem().getItemMeta().getDisplayName().equals(items[3].getItemMeta().getDisplayName())) {
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
player.getInventory().setItem(8, null);
|
player.getInventory().setItem(8, null);
|
||||||
player.updateInventory();
|
player.updateInventory();
|
||||||
|
@ -190,11 +195,12 @@ public class RPirate extends Role{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onQuitInventory(InventoryCloseEvent e) {
|
public void onQuitInventory(InventoryCloseEvent e) {
|
||||||
if(e.getInventory() instanceof CraftInventoryCustom) {
|
if (e.getInventory() instanceof CraftInventoryCustom) {
|
||||||
LGPlayer player = LGPlayer.thePlayer(getGame().getPlugin(), (Player)e.getPlayer());
|
LGPlayer player = LGPlayer.thePlayer(getGame().getPlugin(), (Player) e.getPlayer());
|
||||||
if(player.getRole() == this && inMenu) {
|
if (player.getRole() == this && inMenu) {
|
||||||
new BukkitRunnable() {
|
new BukkitRunnable() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -1,9 +1,16 @@
|
||||||
package fr.leomelki.loupgarou.roles;
|
package fr.leomelki.loupgarou.roles;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import com.comphenix.protocol.wrappers.WrappedDataWatcher;
|
||||||
import java.util.Arrays;
|
import com.comphenix.protocol.wrappers.WrappedDataWatcher.WrappedDataWatcherObject;
|
||||||
import java.util.Collections;
|
import com.comphenix.protocol.wrappers.WrappedWatchableObject;
|
||||||
|
import fr.leomelki.com.comphenix.packetwrapper.WrapperPlayServerEntityMetadata;
|
||||||
|
import fr.leomelki.com.comphenix.packetwrapper.WrapperPlayServerHeldItemSlot;
|
||||||
|
import fr.leomelki.loupgarou.MainLg;
|
||||||
|
import fr.leomelki.loupgarou.classes.LGCustomItems;
|
||||||
|
import fr.leomelki.loupgarou.classes.LGGame;
|
||||||
|
import fr.leomelki.loupgarou.classes.LGPlayer;
|
||||||
|
import fr.leomelki.loupgarou.events.LGPreDayStartEvent;
|
||||||
|
import fr.leomelki.loupgarou.utils.VariousUtils;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.craftbukkit.v1_15_R1.inventory.CraftInventoryCustom;
|
import org.bukkit.craftbukkit.v1_15_R1.inventory.CraftInventoryCustom;
|
||||||
|
@ -19,21 +26,13 @@ import org.bukkit.inventory.meta.ItemMeta;
|
||||||
import org.bukkit.potion.PotionEffectType;
|
import org.bukkit.potion.PotionEffectType;
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
|
||||||
import com.comphenix.protocol.wrappers.WrappedDataWatcher;
|
import java.util.ArrayList;
|
||||||
import com.comphenix.protocol.wrappers.WrappedDataWatcher.WrappedDataWatcherObject;
|
import java.util.Arrays;
|
||||||
import com.comphenix.protocol.wrappers.WrappedWatchableObject;
|
import java.util.Collections;
|
||||||
|
|
||||||
import fr.leomelki.com.comphenix.packetwrapper.WrapperPlayServerEntityMetadata;
|
public class RPretre extends Role {
|
||||||
import fr.leomelki.com.comphenix.packetwrapper.WrapperPlayServerHeldItemSlot;
|
|
||||||
import fr.leomelki.loupgarou.MainLg;
|
|
||||||
import fr.leomelki.loupgarou.classes.LGCustomItems;
|
|
||||||
import fr.leomelki.loupgarou.classes.LGGame;
|
|
||||||
import fr.leomelki.loupgarou.classes.LGPlayer;
|
|
||||||
import fr.leomelki.loupgarou.events.LGPreDayStartEvent;
|
|
||||||
import fr.leomelki.loupgarou.utils.VariousUtils;
|
|
||||||
|
|
||||||
public class RPretre extends Role{
|
|
||||||
static final ItemStack[] items = new ItemStack[9];
|
static final ItemStack[] items = new ItemStack[9];
|
||||||
|
|
||||||
static {
|
static {
|
||||||
items[3] = new ItemStack(Material.IRON_NUGGET);
|
items[3] = new ItemStack(Material.IRON_NUGGET);
|
||||||
ItemMeta meta = items[3].getItemMeta();
|
ItemMeta meta = items[3].getItemMeta();
|
||||||
|
@ -49,6 +48,11 @@ public class RPretre extends Role{
|
||||||
items[5].setItemMeta(meta);
|
items[5].setItemMeta(meta);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final WrappedDataWatcherObject invisible = new WrappedDataWatcherObject(0, WrappedDataWatcher.Registry.get(Byte.class));
|
||||||
|
final ArrayList<LGPlayer> ressucited = new ArrayList<>();
|
||||||
|
Runnable callback;
|
||||||
|
boolean inMenu = false;
|
||||||
|
|
||||||
public RPretre(LGGame game) {
|
public RPretre(LGGame game) {
|
||||||
super(game);
|
super(game);
|
||||||
}
|
}
|
||||||
|
@ -60,7 +64,7 @@ public class RPretre extends Role{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getFriendlyName() {
|
public String getFriendlyName() {
|
||||||
return "du "+getName();
|
return "du " + getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -80,12 +84,14 @@ public class RPretre extends Role{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getBroadcastedTask() {
|
public String getBroadcastedTask() {
|
||||||
return "Le "+getName()+"§9 récite ses ouvrages...";
|
return "Le " + getName() + "§9 récite ses ouvrages...";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public RoleType getType() {
|
public RoleType getType() {
|
||||||
return RoleType.VILLAGER;
|
return RoleType.VILLAGER;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public RoleWinType getWinType() {
|
public RoleWinType getWinType() {
|
||||||
return RoleWinType.VILLAGE;
|
return RoleWinType.VILLAGE;
|
||||||
|
@ -95,17 +101,16 @@ public class RPretre extends Role{
|
||||||
public int getTimeout() {
|
public int getTimeout() {
|
||||||
return 30;
|
return 30;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasPlayersLeft() {
|
public boolean hasPlayersLeft() {
|
||||||
for(LGPlayer pretre : getPlayers())
|
for (LGPlayer pretre : getPlayers())
|
||||||
for(LGPlayer lgp : getGame().getInGame())
|
for (LGPlayer lgp : getGame().getInGame())
|
||||||
if(lgp.isDead() && (lgp.getRoleType() == RoleType.VILLAGER || lgp.getRoleType() == pretre.getRoleType()))
|
if (lgp.isDead() && (lgp.getRoleType() == RoleType.VILLAGER || lgp.getRoleType() == pretre.getRoleType()))
|
||||||
return super.hasPlayersLeft();
|
return super.hasPlayersLeft();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Runnable callback;
|
|
||||||
|
|
||||||
public void openInventory(Player player) {
|
public void openInventory(Player player) {
|
||||||
inMenu = true;
|
inMenu = true;
|
||||||
Inventory inventory = Bukkit.createInventory(null, 9, "§7Veux-tu réssusciter quelqu'un ?");
|
Inventory inventory = Bukkit.createInventory(null, 9, "§7Veux-tu réssusciter quelqu'un ?");
|
||||||
|
@ -113,24 +118,25 @@ public class RPretre extends Role{
|
||||||
player.closeInventory();
|
player.closeInventory();
|
||||||
player.openInventory(inventory);
|
player.openInventory(inventory);
|
||||||
}
|
}
|
||||||
final WrappedDataWatcherObject invisible = new WrappedDataWatcherObject(0, WrappedDataWatcher.Registry.get(Byte.class));
|
|
||||||
@Override
|
@Override
|
||||||
protected void onNightTurn(LGPlayer player, Runnable callback) {
|
protected void onNightTurn(LGPlayer player, Runnable callback) {
|
||||||
player.showView();
|
player.showView();
|
||||||
for(LGPlayer lgp : getGame().getInGame())
|
for (LGPlayer lgp : getGame().getInGame())
|
||||||
if(lgp.isDead() && (lgp.getRoleType() == RoleType.VILLAGER || lgp.getRoleType() == player.getRoleType())){
|
if (lgp.isDead() && (lgp.getRoleType() == RoleType.VILLAGER || lgp.getRoleType() == player.getRoleType())) {
|
||||||
if(lgp.getPlayer() != null) {
|
if (lgp.getPlayer() != null) {
|
||||||
player.getPlayer().showPlayer(getGame().getPlugin(), lgp.getPlayer());
|
player.getPlayer().showPlayer(getGame().getPlugin(), lgp.getPlayer());
|
||||||
WrapperPlayServerEntityMetadata meta = new WrapperPlayServerEntityMetadata();
|
WrapperPlayServerEntityMetadata meta = new WrapperPlayServerEntityMetadata();
|
||||||
meta.setEntityID(lgp.getPlayer().getEntityId());
|
meta.setEntityID(lgp.getPlayer().getEntityId());
|
||||||
meta.setMetadata(Collections.singletonList(new WrappedWatchableObject(invisible, (byte) 0)));
|
meta.setMetadata(Collections.singletonList(new WrappedWatchableObject(invisible, (byte) 0)));
|
||||||
meta.sendPacket(player.getPlayer());
|
meta.sendPacket(player.getPlayer());
|
||||||
}
|
}
|
||||||
}else
|
} else
|
||||||
player.getPlayer().hidePlayer(getGame().getPlugin(), lgp.getPlayer());
|
player.getPlayer().hidePlayer(getGame().getPlugin(), lgp.getPlayer());
|
||||||
this.callback = callback;
|
this.callback = callback;
|
||||||
openInventory(player.getPlayer());
|
openInventory(player.getPlayer());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onNightTurnTimeout(LGPlayer player) {
|
protected void onNightTurnTimeout(LGPlayer player) {
|
||||||
player.getPlayer().getInventory().setItem(8, null);
|
player.getPlayer().getInventory().setItem(8, null);
|
||||||
|
@ -144,36 +150,34 @@ public class RPretre extends Role{
|
||||||
}
|
}
|
||||||
|
|
||||||
private void hidePlayers(LGPlayer player) {
|
private void hidePlayers(LGPlayer player) {
|
||||||
if(player.getPlayer() != null) {
|
if (player.getPlayer() != null) {
|
||||||
for(LGPlayer lgp : getGame().getInGame())
|
for (LGPlayer lgp : getGame().getInGame())
|
||||||
if(lgp.getPlayer() != null && lgp != player)
|
if (lgp.getPlayer() != null && lgp != player)
|
||||||
player.getPlayer().hidePlayer(getGame().getPlugin(), lgp.getPlayer());
|
player.getPlayer().hidePlayer(getGame().getPlugin(), lgp.getPlayer());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean inMenu = false;
|
|
||||||
final ArrayList<LGPlayer> ressucited = new ArrayList<>();
|
|
||||||
|
|
||||||
private void closeInventory(Player p) {
|
private void closeInventory(Player p) {
|
||||||
inMenu = false;
|
inMenu = false;
|
||||||
p.closeInventory();
|
p.closeInventory();
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onInventoryClick(InventoryClickEvent e) {
|
public void onInventoryClick(InventoryClickEvent e) {
|
||||||
ItemStack item = e.getCurrentItem();
|
ItemStack item = e.getCurrentItem();
|
||||||
Player player = (Player)e.getWhoClicked();
|
Player player = (Player) e.getWhoClicked();
|
||||||
LGPlayer lgp = LGPlayer.thePlayer(getGame().getPlugin(), player);
|
LGPlayer lgp = LGPlayer.thePlayer(getGame().getPlugin(), player);
|
||||||
|
|
||||||
if(lgp.getRole() != this || item == null || item.getItemMeta() == null)return;
|
if (lgp.getRole() != this || item == null || item.getItemMeta() == null) return;
|
||||||
|
|
||||||
if(item.getItemMeta().getDisplayName().equals(items[3].getItemMeta().getDisplayName())) {
|
if (item.getItemMeta().getDisplayName().equals(items[3].getItemMeta().getDisplayName())) {
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
closeInventory(player);
|
closeInventory(player);
|
||||||
lgp.sendMessage("§6Tu n'as rien fait cette nuit.");
|
lgp.sendMessage("§6Tu n'as rien fait cette nuit.");
|
||||||
hidePlayers(lgp);
|
hidePlayers(lgp);
|
||||||
lgp.hideView();
|
lgp.hideView();
|
||||||
callback.run();
|
callback.run();
|
||||||
}else if(item.getItemMeta().getDisplayName().equals(items[5].getItemMeta().getDisplayName())) {
|
} else if (item.getItemMeta().getDisplayName().equals(items[5].getItemMeta().getDisplayName())) {
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
closeInventory(player);
|
closeInventory(player);
|
||||||
player.getInventory().setItem(8, items[3]);
|
player.getInventory().setItem(8, items[3]);
|
||||||
|
@ -185,20 +189,20 @@ public class RPretre extends Role{
|
||||||
lgp.sendMessage("§6Choisissez qui réssusciter.");
|
lgp.sendMessage("§6Choisissez qui réssusciter.");
|
||||||
lgp.canSelectDead = true;
|
lgp.canSelectDead = true;
|
||||||
lgp.choose(choosen -> {
|
lgp.choose(choosen -> {
|
||||||
if(choosen != null) {
|
if (choosen != null) {
|
||||||
if(!choosen.isDead())
|
if (!choosen.isDead())
|
||||||
lgp.sendMessage("§7§l"+choosen.getName()+"§c n'est pas mort.");
|
lgp.sendMessage("§7§l" + choosen.getName() + "§c n'est pas mort.");
|
||||||
else if(lgp.getRoleType() == RoleType.LOUP_GAROU && choosen.getRoleType() == RoleType.NEUTRAL) {
|
else if (lgp.getRoleType() == RoleType.LOUP_GAROU && choosen.getRoleType() == RoleType.NEUTRAL) {
|
||||||
lgp.sendMessage("§7§l"+choosen.getName()+"§c ne faisait ni partie du §a§lVillage§6 ni des §c§lLoups§6.");
|
lgp.sendMessage("§7§l" + choosen.getName() + "§c ne faisait ni partie du §a§lVillage§6 ni des §c§lLoups§6.");
|
||||||
}else if(lgp.getRoleType() != RoleType.LOUP_GAROU && choosen.getRoleType() != RoleType.VILLAGER) {
|
} else if (lgp.getRoleType() != RoleType.LOUP_GAROU && choosen.getRoleType() != RoleType.VILLAGER) {
|
||||||
lgp.sendMessage("§7§l"+choosen.getName()+"§c ne faisait pas partie du §a§lVillage§6.");
|
lgp.sendMessage("§7§l" + choosen.getName() + "§c ne faisait pas partie du §a§lVillage§6.");
|
||||||
} else {
|
} else {
|
||||||
player.getInventory().setItem(8, null);
|
player.getInventory().setItem(8, null);
|
||||||
player.updateInventory();
|
player.updateInventory();
|
||||||
lgp.stopChoosing();
|
lgp.stopChoosing();
|
||||||
lgp.canSelectDead = false;
|
lgp.canSelectDead = false;
|
||||||
lgp.sendMessage("§6Tu as ramené §7§l"+choosen.getName()+"§6 à la vie.");
|
lgp.sendMessage("§6Tu as ramené §7§l" + choosen.getName() + "§6 à la vie.");
|
||||||
lgp.sendActionBarMessage("§7§l"+choosen.getName()+"§6 sera réssuscité");
|
lgp.sendActionBarMessage("§7§l" + choosen.getName() + "§6 sera réssuscité");
|
||||||
|
|
||||||
|
|
||||||
ressucited.add(choosen);
|
ressucited.add(choosen);
|
||||||
|
@ -212,12 +216,13 @@ public class RPretre extends Role{
|
||||||
}, lgp);
|
}, lgp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onClick(PlayerInteractEvent e) {
|
public void onClick(PlayerInteractEvent e) {
|
||||||
Player player = e.getPlayer();
|
Player player = e.getPlayer();
|
||||||
LGPlayer lgp = LGPlayer.thePlayer(getGame().getPlugin(), player);
|
LGPlayer lgp = LGPlayer.thePlayer(getGame().getPlugin(), player);
|
||||||
if(lgp.getRole() == this) {
|
if (lgp.getRole() == this) {
|
||||||
if(e.getItem() != null && e.getItem().hasItemMeta() && e.getItem().getItemMeta().getDisplayName().equals(items[3].getItemMeta().getDisplayName())) {
|
if (e.getItem() != null && e.getItem().hasItemMeta() && e.getItem().getItemMeta().getDisplayName().equals(items[3].getItemMeta().getDisplayName())) {
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
player.getInventory().setItem(8, null);
|
player.getInventory().setItem(8, null);
|
||||||
player.updateInventory();
|
player.updateInventory();
|
||||||
|
@ -232,18 +237,18 @@ public class RPretre extends Role{
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST)
|
@EventHandler(priority = EventPriority.HIGHEST)
|
||||||
public void onDayStart(LGPreDayStartEvent e) {
|
public void onDayStart(LGPreDayStartEvent e) {
|
||||||
if(e.getGame() == getGame())
|
if (e.getGame() == getGame())
|
||||||
if(ressucited.size() > 0) {
|
if (ressucited.size() > 0) {
|
||||||
for(LGPlayer lgp : ressucited) {
|
for (LGPlayer lgp : ressucited) {
|
||||||
if(lgp.getPlayer() == null || !lgp.isDead())
|
if (lgp.getPlayer() == null || !lgp.isDead())
|
||||||
continue;
|
continue;
|
||||||
lgp.setDead(false);
|
lgp.setDead(false);
|
||||||
lgp.getCache().reset();
|
lgp.getCache().reset();
|
||||||
RVillageois villagers = null;
|
RVillageois villagers = null;
|
||||||
for(Role role : getGame().getRoles())
|
for (Role role : getGame().getRoles())
|
||||||
if(role instanceof RVillageois)
|
if (role instanceof RVillageois)
|
||||||
villagers = (RVillageois)role;
|
villagers = (RVillageois) role;
|
||||||
if(villagers == null)
|
if (villagers == null)
|
||||||
getGame().getRoles().add(villagers = new RVillageois(getGame()));
|
getGame().getRoles().add(villagers = new RVillageois(getGame()));
|
||||||
villagers.join(lgp, false);//Le joueur réssuscité rejoint les villageois.
|
villagers.join(lgp, false);//Le joueur réssuscité rejoint les villageois.
|
||||||
lgp.setRole(villagers);
|
lgp.setRole(villagers);
|
||||||
|
@ -257,21 +262,22 @@ public class RPretre extends Role{
|
||||||
|
|
||||||
getGame().updateRoleScoreboard();
|
getGame().updateRoleScoreboard();
|
||||||
|
|
||||||
getGame().broadcastMessage("§7§l"+lgp.getName()+"§6 a été ressuscité cette nuit.");
|
getGame().broadcastMessage("§7§l" + lgp.getName() + "§6 a été ressuscité cette nuit.");
|
||||||
|
|
||||||
for(LGPlayer player : getGame().getInGame())
|
for (LGPlayer player : getGame().getInGame())
|
||||||
if(player.getPlayer() != null && player != lgp) {
|
if (player.getPlayer() != null && player != lgp) {
|
||||||
player.getPlayer().showPlayer(getGame().getPlugin(), lgp.getPlayer());
|
player.getPlayer().showPlayer(getGame().getPlugin(), lgp.getPlayer());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ressucited.clear();
|
ressucited.clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onQuitInventory(InventoryCloseEvent e) {
|
public void onQuitInventory(InventoryCloseEvent e) {
|
||||||
if(e.getInventory() instanceof CraftInventoryCustom) {
|
if (e.getInventory() instanceof CraftInventoryCustom) {
|
||||||
LGPlayer player = LGPlayer.thePlayer(getGame().getPlugin(), (Player)e.getPlayer());
|
LGPlayer player = LGPlayer.thePlayer(getGame().getPlugin(), (Player) e.getPlayer());
|
||||||
if(player.getRole() == this && inMenu) {
|
if (player.getRole() == this && inMenu) {
|
||||||
new BukkitRunnable() {
|
new BukkitRunnable() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -3,42 +3,51 @@ package fr.leomelki.loupgarou.roles;
|
||||||
import fr.leomelki.loupgarou.classes.LGGame;
|
import fr.leomelki.loupgarou.classes.LGGame;
|
||||||
import fr.leomelki.loupgarou.classes.LGPlayer;
|
import fr.leomelki.loupgarou.classes.LGPlayer;
|
||||||
|
|
||||||
public class RPronostiqueur extends Role{
|
public class RPronostiqueur extends Role {
|
||||||
public RPronostiqueur(LGGame game) {
|
public RPronostiqueur(LGGame game) {
|
||||||
super(game);
|
super(game);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public RoleType getType() {
|
public RoleType getType() {
|
||||||
return RoleType.VILLAGER;
|
return RoleType.VILLAGER;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public RoleWinType getWinType() {
|
public RoleWinType getWinType() {
|
||||||
return RoleWinType.VILLAGE;
|
return RoleWinType.VILLAGE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return "§a§lPronostiqueur";
|
return "§a§lPronostiqueur";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getFriendlyName() {
|
public String getFriendlyName() {
|
||||||
return "du "+getName();
|
return "du " + getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getShortDescription() {
|
public String getShortDescription() {
|
||||||
return "Tu gagnes avec le §a§lVillage";
|
return "Tu gagnes avec le §a§lVillage";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getDescription() {
|
public String getDescription() {
|
||||||
return "Tu gagnes avec le §a§lVillage§f. Chaque nuit, tu peux espionner un joueur et découvrir s'il est gentil ou non. Cependant, dans certaines parties, vos pronostiques ne sont pas exacts...";
|
return "Tu gagnes avec le §a§lVillage§f. Chaque nuit, tu peux espionner un joueur et découvrir s'il est gentil ou non. Cependant, dans certaines parties, vos pronostiques ne sont pas exacts...";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getTask() {
|
public String getTask() {
|
||||||
return "Choisis un joueur sur lequel pronostiquer.";
|
return "Choisis un joueur sur lequel pronostiquer.";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getBroadcastedTask() {
|
public String getBroadcastedTask() {
|
||||||
return "Le "+getName()+"§9 s'apprête à pronostiquer...";
|
return "Le " + getName() + "§9 s'apprête à pronostiquer...";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getTimeout() {
|
public int getTimeout() {
|
||||||
return 15;
|
return 15;
|
||||||
|
@ -49,17 +58,18 @@ public class RPronostiqueur extends Role{
|
||||||
player.showView();
|
player.showView();
|
||||||
|
|
||||||
player.choose(choosen -> {
|
player.choose(choosen -> {
|
||||||
if(choosen != null && choosen != player) {
|
if (choosen != null && choosen != player) {
|
||||||
//player.sendTitle("§6Vous avez regardé un rôle", "§e§l"+choosen.getName()+"§6§l est §e§l"+choosen.getRole().getName(), 5*20);
|
//player.sendTitle("§6Vous avez regardé un rôle", "§e§l"+choosen.getName()+"§6§l est §e§l"+choosen.getRole().getName(), 5*20);
|
||||||
String gentilMechant = choosen.getRoleWinType() == RoleWinType.VILLAGE || choosen.getRoleWinType() == RoleWinType.NONE ? "§a§lgentil" : "§c§lméchant";
|
String gentilMechant = choosen.getRoleWinType() == RoleWinType.VILLAGE || choosen.getRoleWinType() == RoleWinType.NONE ? "§a§lgentil" : "§c§lméchant";
|
||||||
player.sendActionBarMessage("§e§l"+choosen.getName()+"§6 est "+gentilMechant);
|
player.sendActionBarMessage("§e§l" + choosen.getName() + "§6 est " + gentilMechant);
|
||||||
player.sendMessage("§6Votre instinct vous dit que §7§l"+choosen.getName()+"§6 est "+gentilMechant+"§6.");
|
player.sendMessage("§6Votre instinct vous dit que §7§l" + choosen.getName() + "§6 est " + gentilMechant + "§6.");
|
||||||
player.stopChoosing();
|
player.stopChoosing();
|
||||||
player.hideView();
|
player.hideView();
|
||||||
callback.run();
|
callback.run();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onNightTurnTimeout(LGPlayer player) {
|
protected void onNightTurnTimeout(LGPlayer player) {
|
||||||
player.stopChoosing();
|
player.stopChoosing();
|
||||||
|
|
|
@ -1,10 +1,15 @@
|
||||||
package fr.leomelki.loupgarou.roles;
|
package fr.leomelki.loupgarou.roles;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import fr.leomelki.com.comphenix.packetwrapper.WrapperPlayServerHeldItemSlot;
|
||||||
import java.util.Arrays;
|
import fr.leomelki.loupgarou.MainLg;
|
||||||
import java.util.Collections;
|
import fr.leomelki.loupgarou.classes.LGGame;
|
||||||
import java.util.List;
|
import fr.leomelki.loupgarou.classes.LGPlayer;
|
||||||
|
import fr.leomelki.loupgarou.classes.LGWinType;
|
||||||
|
import fr.leomelki.loupgarou.events.LGEndCheckEvent;
|
||||||
|
import fr.leomelki.loupgarou.events.LGGameEndEvent;
|
||||||
|
import fr.leomelki.loupgarou.events.LGPlayerKilledEvent;
|
||||||
|
import fr.leomelki.loupgarou.events.LGPlayerKilledEvent.Reason;
|
||||||
|
import fr.leomelki.loupgarou.events.LGPyromaneGasoilEvent;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.craftbukkit.v1_15_R1.inventory.CraftInventoryCustom;
|
import org.bukkit.craftbukkit.v1_15_R1.inventory.CraftInventoryCustom;
|
||||||
|
@ -19,21 +24,16 @@ import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.inventory.meta.ItemMeta;
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
|
||||||
import fr.leomelki.com.comphenix.packetwrapper.WrapperPlayServerHeldItemSlot;
|
import java.util.ArrayList;
|
||||||
import fr.leomelki.loupgarou.MainLg;
|
import java.util.Arrays;
|
||||||
import fr.leomelki.loupgarou.classes.LGGame;
|
import java.util.Collections;
|
||||||
import fr.leomelki.loupgarou.classes.LGPlayer;
|
import java.util.List;
|
||||||
import fr.leomelki.loupgarou.classes.LGWinType;
|
|
||||||
import fr.leomelki.loupgarou.events.LGEndCheckEvent;
|
|
||||||
import fr.leomelki.loupgarou.events.LGGameEndEvent;
|
|
||||||
import fr.leomelki.loupgarou.events.LGPlayerKilledEvent;
|
|
||||||
import fr.leomelki.loupgarou.events.LGPyromaneGasoilEvent;
|
|
||||||
import fr.leomelki.loupgarou.events.LGPlayerKilledEvent.Reason;
|
|
||||||
|
|
||||||
public class RPyromane extends Role{
|
public class RPyromane extends Role {
|
||||||
static final ItemStack[] items = new ItemStack[9];
|
static final ItemStack[] items = new ItemStack[9];
|
||||||
static final ItemStack cancel;
|
static final ItemStack cancel;
|
||||||
static final ItemStack nothing;
|
static final ItemStack nothing;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
cancel = new ItemStack(Material.IRON_NUGGET);
|
cancel = new ItemStack(Material.IRON_NUGGET);
|
||||||
ItemMeta meta = cancel.getItemMeta();
|
ItemMeta meta = cancel.getItemMeta();
|
||||||
|
@ -59,6 +59,10 @@ public class RPyromane extends Role{
|
||||||
items[5].setItemMeta(meta);
|
items[5].setItemMeta(meta);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Runnable callback;
|
||||||
|
boolean inMenu = false;
|
||||||
|
LGPlayer first;
|
||||||
|
|
||||||
public RPyromane(LGGame game) {
|
public RPyromane(LGGame game) {
|
||||||
super(game);
|
super(game);
|
||||||
}
|
}
|
||||||
|
@ -70,7 +74,7 @@ public class RPyromane extends Role{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getFriendlyName() {
|
public String getFriendlyName() {
|
||||||
return "du "+getName();
|
return "du " + getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -90,12 +94,14 @@ public class RPyromane extends Role{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getBroadcastedTask() {
|
public String getBroadcastedTask() {
|
||||||
return "Le "+getName()+"§9 joue avec une allumette...";
|
return "Le " + getName() + "§9 joue avec une allumette...";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public RoleType getType() {
|
public RoleType getType() {
|
||||||
return RoleType.NEUTRAL;
|
return RoleType.NEUTRAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public RoleWinType getWinType() {
|
public RoleWinType getWinType() {
|
||||||
return RoleWinType.SEUL;
|
return RoleWinType.SEUL;
|
||||||
|
@ -106,21 +112,20 @@ public class RPyromane extends Role{
|
||||||
return 30;
|
return 30;
|
||||||
}
|
}
|
||||||
|
|
||||||
Runnable callback;
|
|
||||||
|
|
||||||
public void openInventory(Player player) {
|
public void openInventory(Player player) {
|
||||||
inMenu = true;
|
inMenu = true;
|
||||||
Inventory inventory = Bukkit.createInventory(null, 9, "§7Que veux-tu faire ?");
|
Inventory inventory = Bukkit.createInventory(null, 9, "§7Que veux-tu faire ?");
|
||||||
ItemStack[] content = items.clone();
|
ItemStack[] content = items.clone();
|
||||||
LGPlayer lgp = LGPlayer.thePlayer(getGame().getPlugin(), player);
|
LGPlayer lgp = LGPlayer.thePlayer(getGame().getPlugin(), player);
|
||||||
if(!lgp.getCache().has("pyromane_essence"))
|
if (!lgp.getCache().has("pyromane_essence"))
|
||||||
lgp.getCache().set("pyromane_essence", new ArrayList<>());
|
lgp.getCache().set("pyromane_essence", new ArrayList<>());
|
||||||
if(lgp.getCache().<List<LGPlayer>>get("pyromane_essence").size() == 0)
|
if (lgp.getCache().<List<LGPlayer>>get("pyromane_essence").size() == 0)
|
||||||
content[3] = nothing;
|
content[3] = nothing;
|
||||||
inventory.setContents(content);
|
inventory.setContents(content);
|
||||||
player.closeInventory();
|
player.closeInventory();
|
||||||
player.openInventory(inventory);
|
player.openInventory(inventory);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onNightTurn(LGPlayer player, Runnable callback) {
|
protected void onNightTurn(LGPlayer player, Runnable callback) {
|
||||||
first = null;
|
first = null;
|
||||||
|
@ -128,14 +133,15 @@ public class RPyromane extends Role{
|
||||||
this.callback = callback;
|
this.callback = callback;
|
||||||
openInventory(player.getPlayer());
|
openInventory(player.getPlayer());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onNightTurnTimeout(LGPlayer player) {
|
protected void onNightTurnTimeout(LGPlayer player) {
|
||||||
if(first != null) {
|
if (first != null) {
|
||||||
List<LGPlayer> liste = player.getCache().get("pyromane_essence");
|
List<LGPlayer> liste = player.getCache().get("pyromane_essence");
|
||||||
LGPyromaneGasoilEvent event = new LGPyromaneGasoilEvent(getGame(), first);
|
LGPyromaneGasoilEvent event = new LGPyromaneGasoilEvent(getGame(), first);
|
||||||
Bukkit.getPluginManager().callEvent(event);
|
Bukkit.getPluginManager().callEvent(event);
|
||||||
if(event.isCancelled())
|
if (event.isCancelled())
|
||||||
player.sendMessage("§7§l"+event.getPlayer().getName()+"§c est immunisé.");
|
player.sendMessage("§7§l" + event.getPlayer().getName() + "§c est immunisé.");
|
||||||
else {
|
else {
|
||||||
event.getPlayer().sendMessage("§6Tu es recouvert de gasoil...");
|
event.getPlayer().sendMessage("§6Tu es recouvert de gasoil...");
|
||||||
liste.add(event.getPlayer());
|
liste.add(event.getPlayer());
|
||||||
|
@ -149,44 +155,42 @@ public class RPyromane extends Role{
|
||||||
player.sendMessage("§6Tu n'as rien fait cette nuit.");
|
player.sendMessage("§6Tu n'as rien fait cette nuit.");
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean inMenu = false;
|
|
||||||
LGPlayer first;
|
|
||||||
|
|
||||||
private void closeInventory(Player p) {
|
private void closeInventory(Player p) {
|
||||||
inMenu = false;
|
inMenu = false;
|
||||||
p.closeInventory();
|
p.closeInventory();
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onInventoryClick(InventoryClickEvent e) {
|
public void onInventoryClick(InventoryClickEvent e) {
|
||||||
ItemStack item = e.getCurrentItem();
|
ItemStack item = e.getCurrentItem();
|
||||||
Player player = (Player)e.getWhoClicked();
|
Player player = (Player) e.getWhoClicked();
|
||||||
LGPlayer lgp = LGPlayer.thePlayer(getGame().getPlugin(), player);
|
LGPlayer lgp = LGPlayer.thePlayer(getGame().getPlugin(), player);
|
||||||
|
|
||||||
if(lgp.getRole() != this || item == null || item.getItemMeta() == null)return;
|
if (lgp.getRole() != this || item == null || item.getItemMeta() == null) return;
|
||||||
if(item.getItemMeta().getDisplayName().equals(nothing.getItemMeta().getDisplayName())) {
|
if (item.getItemMeta().getDisplayName().equals(nothing.getItemMeta().getDisplayName())) {
|
||||||
lgp.stopChoosing();
|
lgp.stopChoosing();
|
||||||
closeInventory(player);
|
closeInventory(player);
|
||||||
lgp.hideView();
|
lgp.hideView();
|
||||||
lgp.sendMessage("§6Tu n'as rien fait cette nuit.");
|
lgp.sendMessage("§6Tu n'as rien fait cette nuit.");
|
||||||
callback.run();
|
callback.run();
|
||||||
}else if(item.getItemMeta().getDisplayName().equals(items[3].getItemMeta().getDisplayName())) {
|
} else if (item.getItemMeta().getDisplayName().equals(items[3].getItemMeta().getDisplayName())) {
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
closeInventory(player);
|
closeInventory(player);
|
||||||
if(lgp.getCache().<List<LGPlayer>>get("pyromane_essence").size() != 0) {
|
if (lgp.getCache().<List<LGPlayer>>get("pyromane_essence").size() != 0) {
|
||||||
List<LGPlayer> liste = lgp.getCache().get("pyromane_essence");
|
List<LGPlayer> liste = lgp.getCache().get("pyromane_essence");
|
||||||
for(LGPlayer scndPlayer : liste) {
|
for (LGPlayer scndPlayer : liste) {
|
||||||
if(!scndPlayer.isDead() && scndPlayer.getPlayer() != null) {
|
if (!scndPlayer.isDead() && scndPlayer.getPlayer() != null) {
|
||||||
getGame().kill(scndPlayer, Reason.PYROMANE);
|
getGame().kill(scndPlayer, Reason.PYROMANE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
liste.clear();
|
liste.clear();
|
||||||
lgp.sendMessage("§6§lTu as décidé de brûler tes victimes ce soir.");
|
lgp.sendMessage("§6§lTu as décidé de brûler tes victimes ce soir.");
|
||||||
lgp.sendActionBarMessage("§6Tes victimes brûleront ce soir.");
|
lgp.sendActionBarMessage("§6Tes victimes brûleront ce soir.");
|
||||||
}else
|
} else
|
||||||
lgp.sendMessage("§6§lPersonne n'a pris feu.");
|
lgp.sendMessage("§6§lPersonne n'a pris feu.");
|
||||||
lgp.hideView();
|
lgp.hideView();
|
||||||
callback.run();
|
callback.run();
|
||||||
}else if(item.getItemMeta().getDisplayName().equals(items[5].getItemMeta().getDisplayName())) {
|
} else if (item.getItemMeta().getDisplayName().equals(items[5].getItemMeta().getDisplayName())) {
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
closeInventory(player);
|
closeInventory(player);
|
||||||
player.getInventory().setItem(8, cancel);
|
player.getInventory().setItem(8, cancel);
|
||||||
|
@ -197,40 +201,40 @@ public class RPyromane extends Role{
|
||||||
held.sendPacket(player);
|
held.sendPacket(player);
|
||||||
lgp.sendMessage("§6Choisis deux joueurs à recouvrir de gasoil.");
|
lgp.sendMessage("§6Choisis deux joueurs à recouvrir de gasoil.");
|
||||||
lgp.choose(choosen -> {
|
lgp.choose(choosen -> {
|
||||||
if(choosen != null) {
|
if (choosen != null) {
|
||||||
if(choosen == first) {
|
if (choosen == first) {
|
||||||
lgp.sendMessage("§cTu as déjà versé du gasoil sur §7§l"+choosen.getName()+"§6.");
|
lgp.sendMessage("§cTu as déjà versé du gasoil sur §7§l" + choosen.getName() + "§6.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
List<LGPlayer> liste = lgp.getCache().get("pyromane_essence");
|
List<LGPlayer> liste = lgp.getCache().get("pyromane_essence");
|
||||||
if(liste.contains(choosen)) {
|
if (liste.contains(choosen)) {
|
||||||
lgp.sendMessage("§7§l"+choosen.getName()+"§c est déjà recouvert de gasoil.");
|
lgp.sendMessage("§7§l" + choosen.getName() + "§c est déjà recouvert de gasoil.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(first == choosen) {
|
if (first == choosen) {
|
||||||
lgp.sendMessage("§cVous avez déjà sélectionné §7§l"+choosen.getName()+"§c.");
|
lgp.sendMessage("§cVous avez déjà sélectionné §7§l" + choosen.getName() + "§c.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
player.getInventory().setItem(8, null);
|
player.getInventory().setItem(8, null);
|
||||||
player.updateInventory();
|
player.updateInventory();
|
||||||
lgp.sendMessage("§6Tu as versé du gasoil sur §7§l"+choosen.getName()+"§6.");
|
lgp.sendMessage("§6Tu as versé du gasoil sur §7§l" + choosen.getName() + "§6.");
|
||||||
lgp.sendActionBarMessage("§6§7§l"+choosen.getName()+"§6 est recouvert de gasoil");
|
lgp.sendActionBarMessage("§6§7§l" + choosen.getName() + "§6 est recouvert de gasoil");
|
||||||
if(first != null || getGame().getAlive().size() == 2) {
|
if (first != null || getGame().getAlive().size() == 2) {
|
||||||
lgp.hideView();
|
lgp.hideView();
|
||||||
lgp.stopChoosing();
|
lgp.stopChoosing();
|
||||||
LGPyromaneGasoilEvent event = new LGPyromaneGasoilEvent(getGame(), choosen);
|
LGPyromaneGasoilEvent event = new LGPyromaneGasoilEvent(getGame(), choosen);
|
||||||
Bukkit.getPluginManager().callEvent(event);
|
Bukkit.getPluginManager().callEvent(event);
|
||||||
if(event.isCancelled())
|
if (event.isCancelled())
|
||||||
lgp.sendMessage("§7§l"+event.getPlayer().getName()+"§c est immunisée.");
|
lgp.sendMessage("§7§l" + event.getPlayer().getName() + "§c est immunisée.");
|
||||||
else {
|
else {
|
||||||
event.getPlayer().sendMessage("§6Tu es recouvert de gasoil...");
|
event.getPlayer().sendMessage("§6Tu es recouvert de gasoil...");
|
||||||
liste.add(event.getPlayer());
|
liste.add(event.getPlayer());
|
||||||
}
|
}
|
||||||
if(first != null) {
|
if (first != null) {
|
||||||
event = new LGPyromaneGasoilEvent(getGame(), first);
|
event = new LGPyromaneGasoilEvent(getGame(), first);
|
||||||
Bukkit.getPluginManager().callEvent(event);
|
Bukkit.getPluginManager().callEvent(event);
|
||||||
if(event.isCancelled())
|
if (event.isCancelled())
|
||||||
lgp.sendMessage("§7§l"+event.getPlayer().getName()+"§c est immunisée.");
|
lgp.sendMessage("§7§l" + event.getPlayer().getName() + "§c est immunisée.");
|
||||||
else {
|
else {
|
||||||
event.getPlayer().sendMessage("§6Tu es recouvert de gasoil...");
|
event.getPlayer().sendMessage("§6Tu es recouvert de gasoil...");
|
||||||
liste.add(event.getPlayer());
|
liste.add(event.getPlayer());
|
||||||
|
@ -245,12 +249,13 @@ public class RPyromane extends Role{
|
||||||
}, lgp);
|
}, lgp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onClick(PlayerInteractEvent e) {
|
public void onClick(PlayerInteractEvent e) {
|
||||||
Player player = e.getPlayer();
|
Player player = e.getPlayer();
|
||||||
LGPlayer lgp = LGPlayer.thePlayer(getGame().getPlugin(), player);
|
LGPlayer lgp = LGPlayer.thePlayer(getGame().getPlugin(), player);
|
||||||
if(lgp.getRole() == this) {
|
if (lgp.getRole() == this) {
|
||||||
if(e.getItem() != null && e.getItem().hasItemMeta() && e.getItem().getItemMeta().getDisplayName().equals(cancel.getItemMeta().getDisplayName())) {
|
if (e.getItem() != null && e.getItem().hasItemMeta() && e.getItem().getItemMeta().getDisplayName().equals(cancel.getItemMeta().getDisplayName())) {
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
player.getInventory().setItem(8, null);
|
player.getInventory().setItem(8, null);
|
||||||
player.updateInventory();
|
player.updateInventory();
|
||||||
|
@ -259,21 +264,23 @@ public class RPyromane extends Role{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onKilled(LGPlayerKilledEvent e) {
|
public void onKilled(LGPlayerKilledEvent e) {
|
||||||
if(e.getGame() == getGame())
|
if (e.getGame() == getGame())
|
||||||
for(LGPlayer lgp : getPlayers())
|
for (LGPlayer lgp : getPlayers())
|
||||||
if(lgp.getCache().has("pyromane_essence")) {
|
if (lgp.getCache().has("pyromane_essence")) {
|
||||||
List<LGPlayer> liste = lgp.getCache().get("pyromane_essence");
|
List<LGPlayer> liste = lgp.getCache().get("pyromane_essence");
|
||||||
//Au cas où le mec soit rez
|
//Au cas où le mec soit rez
|
||||||
liste.remove(e.getKilled());
|
liste.remove(e.getKilled());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onQuitInventory(InventoryCloseEvent e) {
|
public void onQuitInventory(InventoryCloseEvent e) {
|
||||||
if(e.getInventory() instanceof CraftInventoryCustom) {
|
if (e.getInventory() instanceof CraftInventoryCustom) {
|
||||||
LGPlayer player = LGPlayer.thePlayer(getGame().getPlugin(), (Player)e.getPlayer());
|
LGPlayer player = LGPlayer.thePlayer(getGame().getPlugin(), (Player) e.getPlayer());
|
||||||
if(player.getRole() == this && inMenu) {
|
if (player.getRole() == this && inMenu) {
|
||||||
new BukkitRunnable() {
|
new BukkitRunnable() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -289,14 +296,15 @@ public class RPyromane extends Role{
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onEndgameCheck(LGEndCheckEvent e) {
|
public void onEndgameCheck(LGEndCheckEvent e) {
|
||||||
if(e.getGame() == getGame() && e.getWinType() == LGWinType.SOLO) {
|
if (e.getGame() == getGame() && e.getWinType() == LGWinType.SOLO) {
|
||||||
if(getPlayers().size() > 0)
|
if (getPlayers().size() > 0)
|
||||||
e.setWinType(LGWinType.PYROMANE);
|
e.setWinType(LGWinType.PYROMANE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST)
|
@EventHandler(priority = EventPriority.HIGHEST)
|
||||||
public void onEndGame(LGGameEndEvent e) {
|
public void onEndGame(LGGameEndEvent e) {
|
||||||
if(e.getWinType() == LGWinType.PYROMANE) {
|
if (e.getWinType() == LGWinType.PYROMANE) {
|
||||||
e.getWinners().clear();
|
e.getWinners().clear();
|
||||||
e.getWinners().addAll(getPlayers());
|
e.getWinners().addAll(getPlayers());
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,10 @@
|
||||||
package fr.leomelki.loupgarou.roles;
|
package fr.leomelki.loupgarou.roles;
|
||||||
|
|
||||||
import java.util.Collections;
|
import fr.leomelki.com.comphenix.packetwrapper.WrapperPlayServerHeldItemSlot;
|
||||||
|
import fr.leomelki.loupgarou.MainLg;
|
||||||
|
import fr.leomelki.loupgarou.classes.LGGame;
|
||||||
|
import fr.leomelki.loupgarou.classes.LGPlayer;
|
||||||
|
import fr.leomelki.loupgarou.events.LGPlayerKilledEvent.Reason;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.craftbukkit.v1_15_R1.inventory.CraftInventoryCustom;
|
import org.bukkit.craftbukkit.v1_15_R1.inventory.CraftInventoryCustom;
|
||||||
|
@ -16,15 +19,12 @@ import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.inventory.meta.ItemMeta;
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
|
||||||
import fr.leomelki.com.comphenix.packetwrapper.WrapperPlayServerHeldItemSlot;
|
import java.util.Collections;
|
||||||
import fr.leomelki.loupgarou.MainLg;
|
|
||||||
import fr.leomelki.loupgarou.classes.LGGame;
|
|
||||||
import fr.leomelki.loupgarou.classes.LGPlayer;
|
|
||||||
import fr.leomelki.loupgarou.events.LGPlayerKilledEvent.Reason;
|
|
||||||
|
|
||||||
public class RSorciere extends Role{
|
public class RSorciere extends Role {
|
||||||
private static final ItemStack[] items = new ItemStack[4];
|
private static final ItemStack[] items = new ItemStack[4];
|
||||||
private static final ItemStack cancel;
|
private static final ItemStack cancel;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
items[0] = new ItemStack(Material.PURPLE_DYE, 1);
|
items[0] = new ItemStack(Material.PURPLE_DYE, 1);
|
||||||
ItemMeta meta = items[0].getItemMeta();
|
ItemMeta meta = items[0].getItemMeta();
|
||||||
|
@ -46,60 +46,70 @@ public class RSorciere extends Role{
|
||||||
cancel.setItemMeta(meta);
|
cancel.setItemMeta(meta);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
boolean inMenu = false;
|
||||||
|
private LGPlayer sauver;
|
||||||
|
private Runnable callback;
|
||||||
|
|
||||||
public RSorciere(LGGame game) {
|
public RSorciere(LGGame game) {
|
||||||
super(game);
|
super(game);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public RoleType getType() {
|
public RoleType getType() {
|
||||||
return RoleType.VILLAGER;
|
return RoleType.VILLAGER;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public RoleWinType getWinType() {
|
public RoleWinType getWinType() {
|
||||||
return RoleWinType.VILLAGE;
|
return RoleWinType.VILLAGE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return "§a§lSorcière";
|
return "§a§lSorcière";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getFriendlyName() {
|
public String getFriendlyName() {
|
||||||
return "de la "+getName();
|
return "de la " + getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getShortDescription() {
|
public String getShortDescription() {
|
||||||
return "Tu gagnes avec le §a§lVillage";
|
return "Tu gagnes avec le §a§lVillage";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getDescription() {
|
public String getDescription() {
|
||||||
return "Tu gagnes avec le §a§lVillage§f. Tu disposes de deux potions : une §e§o§lpotion de vie§f pour sauver la victime des §c§lLoups§f, et une §e§o§lpotion de mort§f pour assassiner quelqu'un.";
|
return "Tu gagnes avec le §a§lVillage§f. Tu disposes de deux potions : une §e§o§lpotion de vie§f pour sauver la victime des §c§lLoups§f, et une §e§o§lpotion de mort§f pour assassiner quelqu'un.";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getTask() {
|
public String getTask() {
|
||||||
return "Que veux-tu faire cette nuit ?";
|
return "Que veux-tu faire cette nuit ?";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getBroadcastedTask() {
|
public String getBroadcastedTask() {
|
||||||
return "La "+getName()+"§9 est en train de concocter un nouvel élixir.";
|
return "La " + getName() + "§9 est en train de concocter un nouvel élixir.";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getTimeout() {
|
public int getTimeout() {
|
||||||
return 30;
|
return 30;
|
||||||
}
|
}
|
||||||
|
|
||||||
private LGPlayer sauver;
|
|
||||||
private Runnable callback;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onNightTurn(LGPlayer player, Runnable callback) {
|
protected void onNightTurn(LGPlayer player, Runnable callback) {
|
||||||
player.showView();
|
player.showView();
|
||||||
this.callback = callback;
|
this.callback = callback;
|
||||||
sauver = getGame().getDeaths().get(Reason.LOUP_GAROU);
|
sauver = getGame().getDeaths().get(Reason.LOUP_GAROU);
|
||||||
if(sauver == null)
|
if (sauver == null)
|
||||||
sauver = getGame().getDeaths().get(Reason.DONT_DIE);
|
sauver = getGame().getDeaths().get(Reason.DONT_DIE);
|
||||||
|
|
||||||
openInventory(player);
|
openInventory(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onNightTurnTimeout(LGPlayer player) {
|
protected void onNightTurnTimeout(LGPlayer player) {
|
||||||
player.getPlayer().getInventory().setItem(8, null);
|
player.getPlayer().getInventory().setItem(8, null);
|
||||||
|
@ -110,31 +120,32 @@ public class RSorciere extends Role{
|
||||||
//player.sendTitle("§cVous n'avez utilisé aucune potion", "§4Vous avez mis trop de temps à vous décider...", 80);
|
//player.sendTitle("§cVous n'avez utilisé aucune potion", "§4Vous avez mis trop de temps à vous décider...", 80);
|
||||||
//player.sendMessage("§6Tu n'as rien fait cette nuit.");
|
//player.sendMessage("§6Tu n'as rien fait cette nuit.");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void openInventory(LGPlayer player) {
|
private void openInventory(LGPlayer player) {
|
||||||
inMenu = true;
|
inMenu = true;
|
||||||
Inventory inventory = Bukkit.createInventory(null, InventoryType.BREWING, sauver == null ? "§7Personne n'a été ciblé" : "§7§l"+sauver.getName()+" §7est ciblé");
|
Inventory inventory = Bukkit.createInventory(null, InventoryType.BREWING, sauver == null ? "§7Personne n'a été ciblé" : "§7§l" + sauver.getName() + " §7est ciblé");
|
||||||
inventory.setContents(items.clone());//clone au cas où Bukkit prenne directement la liste pour éviter de la modifier avec setItem (jsp)
|
inventory.setContents(items.clone());//clone au cas où Bukkit prenne directement la liste pour éviter de la modifier avec setItem (jsp)
|
||||||
if(sauver == null || player.getCache().getBoolean("witch_used_life"))
|
if (sauver == null || player.getCache().getBoolean("witch_used_life"))
|
||||||
inventory.setItem(0, null);
|
inventory.setItem(0, null);
|
||||||
|
|
||||||
if(sauver != null) {
|
if (sauver != null) {
|
||||||
ItemStack head = new ItemStack(Material.ARROW);
|
ItemStack head = new ItemStack(Material.ARROW);
|
||||||
ItemMeta meta = head.getItemMeta();
|
ItemMeta meta = head.getItemMeta();
|
||||||
meta.setDisplayName("§7§l"+sauver.getName()+"§c est ciblé");
|
meta.setDisplayName("§7§l" + sauver.getName() + "§c est ciblé");
|
||||||
head.setItemMeta(meta);
|
head.setItemMeta(meta);
|
||||||
inventory.setItem(4, head);
|
inventory.setItem(4, head);
|
||||||
}
|
}
|
||||||
if(player.getCache().getBoolean("witch_used_death"))
|
if (player.getCache().getBoolean("witch_used_death"))
|
||||||
inventory.setItem(2, null);
|
inventory.setItem(2, null);
|
||||||
player.getPlayer().closeInventory();
|
player.getPlayer().closeInventory();
|
||||||
player.getPlayer().openInventory(inventory);
|
player.getPlayer().openInventory(inventory);
|
||||||
}
|
}
|
||||||
boolean inMenu = false;
|
|
||||||
|
|
||||||
private void closeInventory(Player p) {
|
private void closeInventory(Player p) {
|
||||||
inMenu = false;
|
inMenu = false;
|
||||||
p.closeInventory();
|
p.closeInventory();
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onInventoryClick(InventoryClickEvent e) {
|
public void onInventoryClick(InventoryClickEvent e) {
|
||||||
ItemStack item = e.getCurrentItem();
|
ItemStack item = e.getCurrentItem();
|
||||||
|
@ -178,7 +189,7 @@ public class RSorciere extends Role{
|
||||||
public void onClick(PlayerInteractEvent e) {
|
public void onClick(PlayerInteractEvent e) {
|
||||||
Player p = e.getPlayer();
|
Player p = e.getPlayer();
|
||||||
LGPlayer player = LGPlayer.thePlayer(getGame().getPlugin(), p);
|
LGPlayer player = LGPlayer.thePlayer(getGame().getPlugin(), p);
|
||||||
if(e.getItem() != null && e.getItem().getType() == Material.IRON_NUGGET && player.getRole() == this) {
|
if (e.getItem() != null && e.getItem().getType() == Material.IRON_NUGGET && player.getRole() == this) {
|
||||||
player.stopChoosing();
|
player.stopChoosing();
|
||||||
p.getInventory().setItem(8, null);
|
p.getInventory().setItem(8, null);
|
||||||
p.updateInventory();
|
p.updateInventory();
|
||||||
|
@ -186,11 +197,12 @@ public class RSorciere extends Role{
|
||||||
openInventory(player);
|
openInventory(player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onQuitInventory(InventoryCloseEvent e) {
|
public void onQuitInventory(InventoryCloseEvent e) {
|
||||||
if(e.getInventory() instanceof CraftInventoryCustom) {
|
if (e.getInventory() instanceof CraftInventoryCustom) {
|
||||||
LGPlayer player = LGPlayer.thePlayer(getGame().getPlugin(), (Player)e.getPlayer());
|
LGPlayer player = LGPlayer.thePlayer(getGame().getPlugin(), (Player) e.getPlayer());
|
||||||
if(player.getRole() == this && inMenu) {
|
if (player.getRole() == this && inMenu) {
|
||||||
new BukkitRunnable() {
|
new BukkitRunnable() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -207,16 +219,17 @@ public class RSorciere extends Role{
|
||||||
player.getPlayer().updateInventory();
|
player.getPlayer().updateInventory();
|
||||||
player.getCache().set("witch_used_death", true);
|
player.getCache().set("witch_used_death", true);
|
||||||
getGame().kill(choosen, Reason.SORCIERE);
|
getGame().kill(choosen, Reason.SORCIERE);
|
||||||
player.sendMessage("§6Tu as décidé d'assassiner §7§l"+choosen.getName()+"§6.");
|
player.sendMessage("§6Tu as décidé d'assassiner §7§l" + choosen.getName() + "§6.");
|
||||||
player.sendActionBarMessage("§7§l"+choosen.getName()+"§9 a été tué.");
|
player.sendActionBarMessage("§7§l" + choosen.getName() + "§9 a été tué.");
|
||||||
player.hideView();
|
player.hideView();
|
||||||
callback.run();
|
callback.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void saveLife(LGPlayer player) {
|
private void saveLife(LGPlayer player) {
|
||||||
player.getCache().set("witch_used_life", true);
|
player.getCache().set("witch_used_life", true);
|
||||||
getGame().getDeaths().remove(Reason.LOUP_GAROU, sauver);
|
getGame().getDeaths().remove(Reason.LOUP_GAROU, sauver);
|
||||||
player.sendMessage("§6Tu as décidé de sauver §7§l"+sauver.getName()+"§6.");
|
player.sendMessage("§6Tu as décidé de sauver §7§l" + sauver.getName() + "§6.");
|
||||||
player.sendActionBarMessage("§7§l"+sauver.getName()+"§9 a été sauvé.");
|
player.sendActionBarMessage("§7§l" + sauver.getName() + "§9 a été sauvé.");
|
||||||
player.hideView();
|
player.hideView();
|
||||||
callback.run();
|
callback.run();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,15 @@
|
||||||
package fr.leomelki.loupgarou.roles;
|
package fr.leomelki.loupgarou.roles;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import fr.leomelki.loupgarou.MainLg;
|
||||||
import java.util.Collections;
|
import fr.leomelki.loupgarou.classes.LGGame;
|
||||||
|
import fr.leomelki.loupgarou.classes.LGPlayer;
|
||||||
|
import fr.leomelki.loupgarou.classes.LGWinType;
|
||||||
|
import fr.leomelki.loupgarou.events.LGGameEndEvent;
|
||||||
|
import fr.leomelki.loupgarou.events.LGNightPlayerPreKilledEvent;
|
||||||
|
import fr.leomelki.loupgarou.events.LGPlayerKilledEvent.Reason;
|
||||||
|
import fr.leomelki.loupgarou.events.LGPreDayStartEvent;
|
||||||
|
import fr.leomelki.loupgarou.events.LGVampiredEvent;
|
||||||
|
import fr.leomelki.loupgarou.utils.VariableCache;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.craftbukkit.v1_15_R1.inventory.CraftInventoryCustom;
|
import org.bukkit.craftbukkit.v1_15_R1.inventory.CraftInventoryCustom;
|
||||||
|
@ -15,64 +22,68 @@ import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.inventory.meta.ItemMeta;
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
|
||||||
import fr.leomelki.loupgarou.MainLg;
|
import java.util.Arrays;
|
||||||
import fr.leomelki.loupgarou.classes.LGGame;
|
import java.util.Collections;
|
||||||
import fr.leomelki.loupgarou.classes.LGPlayer;
|
|
||||||
import fr.leomelki.loupgarou.classes.LGWinType;
|
public class RSurvivant extends Role {
|
||||||
import fr.leomelki.loupgarou.events.LGGameEndEvent;
|
boolean inMenu;
|
||||||
import fr.leomelki.loupgarou.events.LGNightPlayerPreKilledEvent;
|
Runnable callback;
|
||||||
import fr.leomelki.loupgarou.events.LGPlayerKilledEvent.Reason;
|
|
||||||
import fr.leomelki.loupgarou.events.LGPreDayStartEvent;
|
|
||||||
import fr.leomelki.loupgarou.events.LGVampiredEvent;
|
|
||||||
import fr.leomelki.loupgarou.utils.VariableCache;
|
|
||||||
|
|
||||||
public class RSurvivant extends Role{
|
|
||||||
public RSurvivant(LGGame game) {
|
public RSurvivant(LGGame game) {
|
||||||
super(game);
|
super(game);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public RoleType getType() {
|
public RoleType getType() {
|
||||||
return RoleType.NEUTRAL;
|
return RoleType.NEUTRAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public RoleWinType getWinType() {
|
public RoleWinType getWinType() {
|
||||||
return RoleWinType.NONE;
|
return RoleWinType.NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return "§d§lSurvivant";
|
return "§d§lSurvivant";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getFriendlyName() {
|
public String getFriendlyName() {
|
||||||
return "du "+getName();
|
return "du " + getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getShortDescription() {
|
public String getShortDescription() {
|
||||||
return "Tu gagnes si tu remplis ton objectif";
|
return "Tu gagnes si tu remplis ton objectif";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getDescription() {
|
public String getDescription() {
|
||||||
return "Tu es §d§lNeutre§f et tu gagnes si tu remplis ton objectif. Ton objectif est de survivre. Tu disposes de §l2§f protections. Chaque nuit, tu peux utiliser une protection pour ne pas être tué par les §c§lLoups§f. Tu peux gagner aussi bien avec les §a§lVillageois§f qu'avec les §c§lLoups§f, tu dois juste rester en vie jusqu'à la fin de la partie.";
|
return "Tu es §d§lNeutre§f et tu gagnes si tu remplis ton objectif. Ton objectif est de survivre. Tu disposes de §l2§f protections. Chaque nuit, tu peux utiliser une protection pour ne pas être tué par les §c§lLoups§f. Tu peux gagner aussi bien avec les §a§lVillageois§f qu'avec les §c§lLoups§f, tu dois juste rester en vie jusqu'à la fin de la partie.";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getTask() {
|
public String getTask() {
|
||||||
return "Veux-tu utiliser une protection cette nuit ?";
|
return "Veux-tu utiliser une protection cette nuit ?";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getBroadcastedTask() {
|
public String getBroadcastedTask() {
|
||||||
return "Le "+getName()+"§9 décide s'il veut se protéger.";
|
return "Le " + getName() + "§9 décide s'il veut se protéger.";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getTimeout() {
|
public int getTimeout() {
|
||||||
return 15;
|
return 15;
|
||||||
}
|
}
|
||||||
boolean inMenu;
|
|
||||||
public void openInventory(Player player) {
|
public void openInventory(Player player) {
|
||||||
inMenu = true;
|
inMenu = true;
|
||||||
Inventory inventory = Bukkit.createInventory(null, 9, "§7Veux-tu te protéger ?");
|
Inventory inventory = Bukkit.createInventory(null, 9, "§7Veux-tu te protéger ?");
|
||||||
ItemStack[] items = new ItemStack[9];
|
ItemStack[] items = new ItemStack[9];
|
||||||
VariableCache cache = LGPlayer.thePlayer(getGame().getPlugin(), player).getCache();
|
VariableCache cache = LGPlayer.thePlayer(getGame().getPlugin(), player).getCache();
|
||||||
if(cache.<Integer>get("survivant_left") > 0) {
|
if (cache.<Integer>get("survivant_left") > 0) {
|
||||||
items[3] = new ItemStack(Material.IRON_NUGGET);
|
items[3] = new ItemStack(Material.IRON_NUGGET);
|
||||||
ItemMeta meta = items[3].getItemMeta();
|
ItemMeta meta = items[3].getItemMeta();
|
||||||
meta.setDisplayName("§7§lNe rien faire");
|
meta.setDisplayName("§7§lNe rien faire");
|
||||||
|
@ -80,7 +91,7 @@ public class RSurvivant extends Role{
|
||||||
items[3].setItemMeta(meta);
|
items[3].setItemMeta(meta);
|
||||||
items[5] = new ItemStack(Material.GOLD_NUGGET);
|
items[5] = new ItemStack(Material.GOLD_NUGGET);
|
||||||
meta = items[5].getItemMeta();
|
meta = items[5].getItemMeta();
|
||||||
meta.setDisplayName("§2§lSe protéger (§6§l"+cache.<Integer>get("survivant_left")+"§2§l restant)");
|
meta.setDisplayName("§2§lSe protéger (§6§l" + cache.<Integer>get("survivant_left") + "§2§l restant)");
|
||||||
meta.setLore(Arrays.asList(
|
meta.setLore(Arrays.asList(
|
||||||
"§8Tu ne pourras pas être tué par",
|
"§8Tu ne pourras pas être tué par",
|
||||||
"§8 les §c§lLoups§8 cette nuit."));
|
"§8 les §c§lLoups§8 cette nuit."));
|
||||||
|
@ -96,19 +107,20 @@ public class RSurvivant extends Role{
|
||||||
inventory.setContents(items);
|
inventory.setContents(items);
|
||||||
player.openInventory(inventory);
|
player.openInventory(inventory);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void join(LGPlayer player) {
|
public void join(LGPlayer player) {
|
||||||
super.join(player);
|
super.join(player);
|
||||||
player.getCache().set("survivant_left", 2);
|
player.getCache().set("survivant_left", 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
Runnable callback;
|
|
||||||
@Override
|
@Override
|
||||||
protected void onNightTurn(LGPlayer player, Runnable callback) {
|
protected void onNightTurn(LGPlayer player, Runnable callback) {
|
||||||
player.showView();
|
player.showView();
|
||||||
this.callback = callback;
|
this.callback = callback;
|
||||||
openInventory(player.getPlayer());
|
openInventory(player.getPlayer());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onNightTurnTimeout(LGPlayer player) {
|
protected void onNightTurnTimeout(LGPlayer player) {
|
||||||
player.hideView();
|
player.hideView();
|
||||||
|
@ -120,26 +132,27 @@ public class RSurvivant extends Role{
|
||||||
inMenu = false;
|
inMenu = false;
|
||||||
p.closeInventory();
|
p.closeInventory();
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onInventoryClick(InventoryClickEvent e) {
|
public void onInventoryClick(InventoryClickEvent e) {
|
||||||
ItemStack item = e.getCurrentItem();
|
ItemStack item = e.getCurrentItem();
|
||||||
Player player = (Player)e.getWhoClicked();
|
Player player = (Player) e.getWhoClicked();
|
||||||
LGPlayer lgp = LGPlayer.thePlayer(getGame().getPlugin(), player);
|
LGPlayer lgp = LGPlayer.thePlayer(getGame().getPlugin(), player);
|
||||||
|
|
||||||
if(lgp.getRole() != this || item == null || item.getItemMeta() == null)return;
|
if (lgp.getRole() != this || item == null || item.getItemMeta() == null) return;
|
||||||
|
|
||||||
if(item.getType() == Material.IRON_NUGGET) {
|
if (item.getType() == Material.IRON_NUGGET) {
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
lgp.sendMessage("§4§oTu es sans défense...");
|
lgp.sendMessage("§4§oTu es sans défense...");
|
||||||
closeInventory(player);
|
closeInventory(player);
|
||||||
lgp.hideView();
|
lgp.hideView();
|
||||||
callback.run();
|
callback.run();
|
||||||
}else if(item.getType() == Material.GOLD_NUGGET) {
|
} else if (item.getType() == Material.GOLD_NUGGET) {
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
closeInventory(player);
|
closeInventory(player);
|
||||||
lgp.sendActionBarMessage("§9§lTu as décidé de te protéger.");
|
lgp.sendActionBarMessage("§9§lTu as décidé de te protéger.");
|
||||||
lgp.sendMessage("§6Tu as décidé de te protéger.");
|
lgp.sendMessage("§6Tu as décidé de te protéger.");
|
||||||
lgp.getCache().set("survivant_left", lgp.getCache().<Integer>get("survivant_left")-1);
|
lgp.getCache().set("survivant_left", lgp.getCache().<Integer>get("survivant_left") - 1);
|
||||||
lgp.getCache().set("survivant_protected", true);
|
lgp.getCache().set("survivant_protected", true);
|
||||||
lgp.hideView();
|
lgp.hideView();
|
||||||
callback.run();
|
callback.run();
|
||||||
|
@ -148,28 +161,30 @@ public class RSurvivant extends Role{
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlayerKill(LGNightPlayerPreKilledEvent e) {
|
public void onPlayerKill(LGNightPlayerPreKilledEvent e) {
|
||||||
if(e.getGame() == getGame() && (e.getReason() == Reason.LOUP_GAROU || e.getReason() == Reason.LOUP_BLANC || e.getReason() == Reason.GM_LOUP_GAROU || e.getReason() == Reason.ASSASSIN) && e.getKilled().getCache().getBoolean("survivant_protected") && e.getKilled().isRoleActive()) {
|
if (e.getGame() == getGame() && (e.getReason() == Reason.LOUP_GAROU || e.getReason() == Reason.LOUP_BLANC || e.getReason() == Reason.GM_LOUP_GAROU || e.getReason() == Reason.ASSASSIN) && e.getKilled().getCache().getBoolean("survivant_protected") && e.getKilled().isRoleActive()) {
|
||||||
e.setReason(Reason.DONT_DIE);
|
e.setReason(Reason.DONT_DIE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onVampired(LGVampiredEvent e) {
|
public void onVampired(LGVampiredEvent e) {
|
||||||
if(e.getGame() == getGame() && e.getPlayer().getCache().getBoolean("survivant_protected"))
|
if (e.getGame() == getGame() && e.getPlayer().getCache().getBoolean("survivant_protected"))
|
||||||
e.setProtect(true);
|
e.setProtect(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onDayStart(LGPreDayStartEvent e) {
|
public void onDayStart(LGPreDayStartEvent e) {
|
||||||
if(e.getGame() == getGame())
|
if (e.getGame() == getGame())
|
||||||
for(LGPlayer lgp : getGame().getInGame())
|
for (LGPlayer lgp : getGame().getInGame())
|
||||||
if(lgp.isRoleActive())
|
if (lgp.isRoleActive())
|
||||||
lgp.getCache().remove("survivant_protected");
|
lgp.getCache().remove("survivant_protected");
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onQuitInventory(InventoryCloseEvent e) {
|
public void onQuitInventory(InventoryCloseEvent e) {
|
||||||
if(e.getInventory() instanceof CraftInventoryCustom) {
|
if (e.getInventory() instanceof CraftInventoryCustom) {
|
||||||
LGPlayer player = LGPlayer.thePlayer(getGame().getPlugin(), (Player)e.getPlayer());
|
LGPlayer player = LGPlayer.thePlayer(getGame().getPlugin(), (Player) e.getPlayer());
|
||||||
if(player.getRole() == this && inMenu) {
|
if (player.getRole() == this && inMenu) {
|
||||||
new BukkitRunnable() {
|
new BukkitRunnable() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -182,19 +197,16 @@ public class RSurvivant extends Role{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onWin(LGGameEndEvent e) {
|
public void onWin(LGGameEndEvent e) {
|
||||||
if(e.getGame() == getGame() && getPlayers().size() > 0 && e.getWinType() != LGWinType.ANGE) {
|
if (e.getGame() == getGame() && getPlayers().size() > 0 && e.getWinType() != LGWinType.ANGE) {
|
||||||
for(LGPlayer lgp : getPlayers())
|
for (LGPlayer lgp : getPlayers())
|
||||||
e.getWinners().add(lgp);
|
e.getWinners().add(lgp);
|
||||||
new BukkitRunnable() {
|
new BukkitRunnable() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
getGame().broadcastMessage("§6§oLe "+getName()+"§6§o a rempli son objectif.");
|
getGame().broadcastMessage("§6§oLe " + getName() + "§6§o a rempli son objectif.");
|
||||||
}
|
}
|
||||||
}.runTaskAsynchronously(MainLg.getInstance());
|
}.runTaskAsynchronously(MainLg.getInstance());
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,29 +1,25 @@
|
||||||
package fr.leomelki.loupgarou.roles;
|
package fr.leomelki.loupgarou.roles;
|
||||||
|
|
||||||
|
import fr.leomelki.loupgarou.classes.*;
|
||||||
|
import fr.leomelki.loupgarou.classes.LGCustomItems.LGCustomItemsConstraints;
|
||||||
|
import fr.leomelki.loupgarou.classes.chat.LGChat;
|
||||||
|
import fr.leomelki.loupgarou.events.*;
|
||||||
|
import fr.leomelki.loupgarou.events.LGPlayerKilledEvent.Reason;
|
||||||
|
import lombok.Getter;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.EventPriority;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
public class RVampire extends Role {
|
||||||
import org.bukkit.event.EventHandler;
|
|
||||||
import org.bukkit.event.EventPriority;
|
|
||||||
|
|
||||||
import fr.leomelki.loupgarou.classes.LGCustomItems;
|
@Getter
|
||||||
import fr.leomelki.loupgarou.classes.LGGame;
|
private final LGChat chat = new LGChat((sender, message) -> "§5" + sender.getName() + " §6» §f" + message);
|
||||||
import fr.leomelki.loupgarou.classes.LGPlayer;
|
int nextCanInfect = 0;
|
||||||
import fr.leomelki.loupgarou.classes.LGVote;
|
LGVote vote;
|
||||||
import fr.leomelki.loupgarou.classes.LGWinType;
|
|
||||||
import fr.leomelki.loupgarou.classes.LGCustomItems.LGCustomItemsConstraints;
|
|
||||||
import fr.leomelki.loupgarou.classes.chat.LGChat;
|
|
||||||
import fr.leomelki.loupgarou.events.LGCustomItemChangeEvent;
|
|
||||||
import fr.leomelki.loupgarou.events.LGGameEndEvent;
|
|
||||||
import fr.leomelki.loupgarou.events.LGNightEndEvent;
|
|
||||||
import fr.leomelki.loupgarou.events.LGPlayerKilledEvent.Reason;
|
|
||||||
import fr.leomelki.loupgarou.events.LGUpdatePrefixEvent;
|
|
||||||
import fr.leomelki.loupgarou.events.LGVampiredEvent;
|
|
||||||
import lombok.Getter;
|
|
||||||
|
|
||||||
public class RVampire extends Role{
|
|
||||||
|
|
||||||
public RVampire(LGGame game) {
|
public RVampire(LGGame game) {
|
||||||
super(game);
|
super(game);
|
||||||
|
@ -58,10 +54,12 @@ public class RVampire extends Role{
|
||||||
public String getBroadcastedTask() {
|
public String getBroadcastedTask() {
|
||||||
return "Les §5§lVampires§9 choisissent leur cible.";
|
return "Les §5§lVampires§9 choisissent leur cible.";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public RoleType getType() {
|
public RoleType getType() {
|
||||||
return RoleType.VAMPIRE;
|
return RoleType.VAMPIRE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public RoleWinType getWinType() {
|
public RoleWinType getWinType() {
|
||||||
return RoleWinType.VAMPIRE;
|
return RoleWinType.VAMPIRE;
|
||||||
|
@ -71,122 +69,122 @@ public class RVampire extends Role{
|
||||||
public int getTimeout() {
|
public int getTimeout() {
|
||||||
return 30;
|
return 30;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasPlayersLeft() {
|
public boolean hasPlayersLeft() {
|
||||||
return nextCanInfect < getGame().getNight() && super.hasPlayersLeft();
|
return nextCanInfect < getGame().getNight() && super.hasPlayersLeft();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Getter private final LGChat chat = new LGChat((sender, message) -> "§5"+sender.getName()+" §6» §f"+message);
|
|
||||||
int nextCanInfect = 0;
|
|
||||||
LGVote vote;
|
|
||||||
@Override
|
@Override
|
||||||
public void join(LGPlayer player, boolean sendMessage) {
|
public void join(LGPlayer player, boolean sendMessage) {
|
||||||
super.join(player, sendMessage);
|
super.join(player, sendMessage);
|
||||||
for(LGPlayer p : getPlayers())
|
for (LGPlayer p : getPlayers())
|
||||||
p.updatePrefix();
|
p.updatePrefix();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onNightTurn(Runnable callback) {
|
public void onNightTurn(Runnable callback) {
|
||||||
vote = new LGVote(getTimeout(), getTimeout()/3, getGame(), false, false, (player, secondsLeft)-> !getPlayers().contains(player) ? "§6C'est au tour "+getFriendlyName()+" §6(§e"+secondsLeft+" s§6)" : player.getCache().has("vote") ? "§l§9Vous votez pour §c§l"+player.getCache().<LGPlayer>get("vote").getName() : "§6Il vous reste §e"+secondsLeft+" seconde"+(secondsLeft > 1 ? "s" : "")+"§6 pour voter");
|
vote = new LGVote(getTimeout(), getTimeout() / 3, getGame(), false, false, (player, secondsLeft) -> !getPlayers().contains(player) ? "§6C'est au tour " + getFriendlyName() + " §6(§e" + secondsLeft + " s§6)" : player.getCache().has("vote") ? "§l§9Vous votez pour §c§l" + player.getCache().<LGPlayer>get("vote").getName() : "§6Il vous reste §e" + secondsLeft + " seconde" + (secondsLeft > 1 ? "s" : "") + "§6 pour voter");
|
||||||
for(LGPlayer lgp : getGame().getAlive())
|
for (LGPlayer lgp : getGame().getAlive())
|
||||||
if(lgp.getRoleType() == RoleType.VAMPIRE)
|
if (lgp.getRoleType() == RoleType.VAMPIRE)
|
||||||
lgp.showView();
|
lgp.showView();
|
||||||
for(LGPlayer player : getPlayers()) {
|
for (LGPlayer player : getPlayers()) {
|
||||||
player.sendMessage("§6"+getTask());
|
player.sendMessage("§6" + getTask());
|
||||||
// player.sendTitle("§6C'est à vous de jouer", "§a"+getTask(), 100);
|
// player.sendTitle("§6C'est à vous de jouer", "§a"+getTask(), 100);
|
||||||
player.joinChat(chat);
|
player.joinChat(chat);
|
||||||
}
|
}
|
||||||
vote.start(getPlayers(), getPlayers(), ()->{
|
vote.start(getPlayers(), getPlayers(), () -> {
|
||||||
onNightTurnEnd();
|
onNightTurnEnd();
|
||||||
callback.run();
|
callback.run();
|
||||||
}, getPlayers());
|
}, getPlayers());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onNightTurnEnd() {
|
private void onNightTurnEnd() {
|
||||||
for(LGPlayer lgp : getGame().getAlive())
|
for (LGPlayer lgp : getGame().getAlive())
|
||||||
if(lgp.getRoleType() == RoleType.VAMPIRE)
|
if (lgp.getRoleType() == RoleType.VAMPIRE)
|
||||||
lgp.hideView();
|
lgp.hideView();
|
||||||
for(LGPlayer player : getPlayers())
|
for (LGPlayer player : getPlayers())
|
||||||
player.leaveChat();
|
player.leaveChat();
|
||||||
|
|
||||||
LGPlayer choosen = vote.getChoosen();
|
LGPlayer choosen = vote.getChoosen();
|
||||||
if(choosen == null) {
|
if (choosen == null) {
|
||||||
if(vote.getVotes().size() > 0) {
|
if (vote.getVotes().size() > 0) {
|
||||||
int max = 0;
|
int max = 0;
|
||||||
boolean equal = false;
|
boolean equal = false;
|
||||||
for(Entry<LGPlayer, List<LGPlayer>> entry : vote.getVotes().entrySet())
|
for (Entry<LGPlayer, List<LGPlayer>> entry : vote.getVotes().entrySet())
|
||||||
if(entry.getValue().size() > max) {
|
if (entry.getValue().size() > max) {
|
||||||
equal = false;
|
equal = false;
|
||||||
max = entry.getValue().size();
|
max = entry.getValue().size();
|
||||||
choosen = entry.getKey();
|
choosen = entry.getKey();
|
||||||
}else if(entry.getValue().size() == max)
|
} else if (entry.getValue().size() == max)
|
||||||
equal = true;
|
equal = true;
|
||||||
if(equal) {
|
if (equal) {
|
||||||
choosen = null;
|
choosen = null;
|
||||||
ArrayList<LGPlayer> choosable = new ArrayList<>();
|
ArrayList<LGPlayer> choosable = new ArrayList<>();
|
||||||
for(Entry<LGPlayer, List<LGPlayer>> entry : vote.getVotes().entrySet())
|
for (Entry<LGPlayer, List<LGPlayer>> entry : vote.getVotes().entrySet())
|
||||||
if(entry.getValue().size() == max && entry.getKey().getRoleType() != RoleType.VAMPIRE)
|
if (entry.getValue().size() == max && entry.getKey().getRoleType() != RoleType.VAMPIRE)
|
||||||
choosable.add(entry.getKey());
|
choosable.add(entry.getKey());
|
||||||
if(choosable.size() > 0)
|
if (choosable.size() > 0)
|
||||||
choosen = choosable.get(getGame().getRandom().nextInt(choosable.size()));
|
choosen = choosable.get(getGame().getRandom().nextInt(choosable.size()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(choosen != null) {
|
if (choosen != null) {
|
||||||
if(choosen.getRoleType() == RoleType.LOUP_GAROU || choosen.getRoleType() == RoleType.VAMPIRE) {
|
if (choosen.getRoleType() == RoleType.LOUP_GAROU || choosen.getRoleType() == RoleType.VAMPIRE) {
|
||||||
for(LGPlayer player : getPlayers())
|
for (LGPlayer player : getPlayers())
|
||||||
player.sendMessage("§cVotre cible est immunisée.");
|
player.sendMessage("§cVotre cible est immunisée.");
|
||||||
return;
|
return;
|
||||||
}else if(choosen.getRole() instanceof RChasseurDeVampire) {
|
} else if (choosen.getRole() instanceof RChasseurDeVampire) {
|
||||||
for(LGPlayer player : getPlayers())
|
for (LGPlayer player : getPlayers())
|
||||||
player.sendMessage("§cVotre cible est immunisée.");
|
player.sendMessage("§cVotre cible est immunisée.");
|
||||||
getGame().kill(getPlayers().get(getPlayers().size()-1), Reason.CHASSEUR_DE_VAMPIRE);
|
getGame().kill(getPlayers().get(getPlayers().size() - 1), Reason.CHASSEUR_DE_VAMPIRE);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
LGVampiredEvent event = new LGVampiredEvent(getGame(), choosen);
|
LGVampiredEvent event = new LGVampiredEvent(getGame(), choosen);
|
||||||
Bukkit.getPluginManager().callEvent(event);
|
Bukkit.getPluginManager().callEvent(event);
|
||||||
if(event.isImmuned()) {
|
if (event.isImmuned()) {
|
||||||
for(LGPlayer player : getPlayers())
|
for (LGPlayer player : getPlayers())
|
||||||
player.sendMessage("§cVotre cible est immunisée.");
|
player.sendMessage("§cVotre cible est immunisée.");
|
||||||
return;
|
return;
|
||||||
}else if(event.isProtect()) {
|
} else if (event.isProtect()) {
|
||||||
for(LGPlayer player : getPlayers())
|
for (LGPlayer player : getPlayers())
|
||||||
player.sendMessage("§cVotre cible est protégée.");
|
player.sendMessage("§cVotre cible est protégée.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for(LGPlayer player : getPlayers())
|
for (LGPlayer player : getPlayers())
|
||||||
player.sendMessage("§7§l"+choosen.getName()+" s'est transformé en §5§lVampire§6.");
|
player.sendMessage("§7§l" + choosen.getName() + " s'est transformé en §5§lVampire§6.");
|
||||||
choosen.sendMessage("§6Tu as été infecté par les §5§lVampires §6pendant la nuit. Tu as perdu tes pouvoirs.");
|
choosen.sendMessage("§6Tu as été infecté par les §5§lVampires §6pendant la nuit. Tu as perdu tes pouvoirs.");
|
||||||
choosen.sendMessage("§6§oTu gagnes désormais avec les §5§l§oVampires§6§o.");
|
choosen.sendMessage("§6§oTu gagnes désormais avec les §5§l§oVampires§6§o.");
|
||||||
choosen.getCache().set("vampire", true);
|
choosen.getCache().set("vampire", true);
|
||||||
choosen.getCache().set("just_vampire", true);
|
choosen.getCache().set("just_vampire", true);
|
||||||
nextCanInfect = getGame().getNight()+1;
|
nextCanInfect = getGame().getNight() + 1;
|
||||||
join(choosen, false);
|
join(choosen, false);
|
||||||
LGCustomItems.updateItem(choosen);
|
LGCustomItems.updateItem(choosen);
|
||||||
}else
|
} else
|
||||||
for(LGPlayer player : getPlayers())
|
for (LGPlayer player : getPlayers())
|
||||||
player.sendMessage("§6Personne n'a été infecté.");
|
player.sendMessage("§6Personne n'a été infecté.");
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST)
|
@EventHandler(priority = EventPriority.HIGHEST)
|
||||||
public void onDayStart(LGNightEndEvent e) {
|
public void onDayStart(LGNightEndEvent e) {
|
||||||
if(e.getGame() == getGame())
|
if (e.getGame() == getGame())
|
||||||
for(LGPlayer player : getGame().getAlive()) {
|
for (LGPlayer player : getGame().getAlive()) {
|
||||||
if(player.getCache().getBoolean("just_vampire")) {
|
if (player.getCache().getBoolean("just_vampire")) {
|
||||||
player.getCache().remove("just_vampire");
|
player.getCache().remove("just_vampire");
|
||||||
for(LGPlayer lgp : getGame().getInGame()) {
|
for (LGPlayer lgp : getGame().getInGame()) {
|
||||||
if(lgp.getRoleType() == RoleType.VAMPIRE)
|
if (lgp.getRoleType() == RoleType.VAMPIRE)
|
||||||
lgp.sendMessage("§7§l"+player.getName()+"§6 s'est transformé en §5§lVampire§6...");
|
lgp.sendMessage("§7§l" + player.getName() + "§6 s'est transformé en §5§lVampire§6...");
|
||||||
else
|
else
|
||||||
lgp.sendMessage("§6Quelqu'un s'est transformé en §5§lVampire§6...");
|
lgp.sendMessage("§6Quelqu'un s'est transformé en §5§lVampire§6...");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(getGame().checkEndGame())
|
if (getGame().checkEndGame())
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* @EventHandler(priority = EventPriority.HIGHEST)
|
/* @EventHandler(priority = EventPriority.HIGHEST)
|
||||||
public void onSkinChange(LGSkinLoadEvent e) {
|
public void onSkinChange(LGSkinLoadEvent e) {
|
||||||
if(e.getGame() == getGame())
|
if(e.getGame() == getGame())
|
||||||
if(getPlayers().contains(e.getPlayer()) && getPlayers().contains(e.getTo()) && showSkins) {
|
if(getPlayers().contains(e.getPlayer()) && getPlayers().contains(e.getTo()) && showSkins) {
|
||||||
|
@ -196,23 +194,23 @@ public class RVampire extends Role{
|
||||||
}*/
|
}*/
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onGameEnd(LGGameEndEvent e) {
|
public void onGameEnd(LGGameEndEvent e) {
|
||||||
if(e.getGame() == getGame() && e.getWinType() == LGWinType.VAMPIRE)
|
if (e.getGame() == getGame() && e.getWinType() == LGWinType.VAMPIRE)
|
||||||
for(LGPlayer lgp : getGame().getInGame())
|
for (LGPlayer lgp : getGame().getInGame())
|
||||||
if(lgp.getRoleWinType() == RoleWinType.VAMPIRE)//Changed to wintype
|
if (lgp.getRoleWinType() == RoleWinType.VAMPIRE)//Changed to wintype
|
||||||
e.getWinners().add(lgp);
|
e.getWinners().add(lgp);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.LOWEST)
|
@EventHandler(priority = EventPriority.LOWEST)
|
||||||
public void onUpdatePrefix (LGUpdatePrefixEvent e) {
|
public void onUpdatePrefix(LGUpdatePrefixEvent e) {
|
||||||
if(e.getGame() == getGame())
|
if (e.getGame() == getGame())
|
||||||
if(getPlayers().contains(e.getTo()) && getPlayers().contains(e.getPlayer()))
|
if (getPlayers().contains(e.getTo()) && getPlayers().contains(e.getPlayer()))
|
||||||
e.setPrefix(e.getPrefix()+"§5");
|
e.setPrefix(e.getPrefix() + "§5");
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onCustomItemChange(LGCustomItemChangeEvent e) {
|
public void onCustomItemChange(LGCustomItemChangeEvent e) {
|
||||||
if(e.getGame() == getGame())
|
if (e.getGame() == getGame())
|
||||||
if(e.getPlayer().getCache().getBoolean("vampire"))
|
if (e.getPlayer().getCache().getBoolean("vampire"))
|
||||||
e.getConstraints().add(LGCustomItemsConstraints.VAMPIRE_INFECTE.getName());
|
e.getConstraints().add(LGCustomItemsConstraints.VAMPIRE_INFECTE.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,42 +2,51 @@ package fr.leomelki.loupgarou.roles;
|
||||||
|
|
||||||
import fr.leomelki.loupgarou.classes.LGGame;
|
import fr.leomelki.loupgarou.classes.LGGame;
|
||||||
|
|
||||||
public class RVillageois extends Role{
|
public class RVillageois extends Role {
|
||||||
public RVillageois(LGGame game) {
|
public RVillageois(LGGame game) {
|
||||||
super(game);
|
super(game);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public RoleType getType() {
|
public RoleType getType() {
|
||||||
return RoleType.VILLAGER;
|
return RoleType.VILLAGER;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public RoleWinType getWinType() {
|
public RoleWinType getWinType() {
|
||||||
return RoleWinType.VILLAGE;
|
return RoleWinType.VILLAGE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return "§a§lVillageois";
|
return "§a§lVillageois";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getFriendlyName() {
|
public String getFriendlyName() {
|
||||||
return "des "+getName();
|
return "des " + getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getShortDescription() {
|
public String getShortDescription() {
|
||||||
return "Tu gagnes avec le §a§lVillage";
|
return "Tu gagnes avec le §a§lVillage";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getDescription() {
|
public String getDescription() {
|
||||||
return "Tu gagnes avec le §a§lVillage§f. Tu ne disposes d'aucun pouvoir particulier, uniquement ta perspicacité et ta force de persuasion.";
|
return "Tu gagnes avec le §a§lVillage§f. Tu ne disposes d'aucun pouvoir particulier, uniquement ta perspicacité et ta force de persuasion.";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getTask() {
|
public String getTask() {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getBroadcastedTask() {
|
public String getBroadcastedTask() {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getTimeout() {
|
public int getTimeout() {
|
||||||
return -1;
|
return -1;
|
||||||
|
|
|
@ -3,26 +3,31 @@ package fr.leomelki.loupgarou.roles;
|
||||||
import fr.leomelki.loupgarou.classes.LGGame;
|
import fr.leomelki.loupgarou.classes.LGGame;
|
||||||
import fr.leomelki.loupgarou.classes.LGPlayer;
|
import fr.leomelki.loupgarou.classes.LGPlayer;
|
||||||
|
|
||||||
public class RVoyante extends Role{
|
public class RVoyante extends Role {
|
||||||
public RVoyante(LGGame game) {
|
public RVoyante(LGGame game) {
|
||||||
super(game);
|
super(game);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public RoleType getType() {
|
public RoleType getType() {
|
||||||
return RoleType.VILLAGER;
|
return RoleType.VILLAGER;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public RoleWinType getWinType() {
|
public RoleWinType getWinType() {
|
||||||
return RoleWinType.VILLAGE;
|
return RoleWinType.VILLAGE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return "§a§lVoyante";
|
return "§a§lVoyante";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getFriendlyName() {
|
public String getFriendlyName() {
|
||||||
return "de la "+getName();
|
return "de la " + getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getShortDescription() {
|
public String getShortDescription() {
|
||||||
return "Tu gagnes avec le §a§lVillage";
|
return "Tu gagnes avec le §a§lVillage";
|
||||||
|
@ -32,14 +37,17 @@ public class RVoyante extends Role{
|
||||||
public String getDescription() {
|
public String getDescription() {
|
||||||
return "Tu gagnes avec le §a§lVillage§f. Chaque nuit, tu peux espionner un joueur et découvrir sa véritable identité...";
|
return "Tu gagnes avec le §a§lVillage§f. Chaque nuit, tu peux espionner un joueur et découvrir sa véritable identité...";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getTask() {
|
public String getTask() {
|
||||||
return "Choisis un joueur dont tu veux connnaître l'identité.";
|
return "Choisis un joueur dont tu veux connnaître l'identité.";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getBroadcastedTask() {
|
public String getBroadcastedTask() {
|
||||||
return "La "+getName()+"§9 s'apprête à sonder un joueur...";
|
return "La " + getName() + "§9 s'apprête à sonder un joueur...";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getTimeout() {
|
public int getTimeout() {
|
||||||
return 15;
|
return 15;
|
||||||
|
@ -50,16 +58,17 @@ public class RVoyante extends Role{
|
||||||
player.showView();
|
player.showView();
|
||||||
|
|
||||||
player.choose(choosen -> {
|
player.choose(choosen -> {
|
||||||
if(choosen != null && choosen != player) {
|
if (choosen != null && choosen != player) {
|
||||||
//player.sendTitle("§6Vous avez regardé un rôle", "§e§l"+choosen.getName()+"§6§l est §e§l"+choosen.getRole().getName(), 5*20);
|
//player.sendTitle("§6Vous avez regardé un rôle", "§e§l"+choosen.getName()+"§6§l est §e§l"+choosen.getRole().getName(), 5*20);
|
||||||
player.sendActionBarMessage("§e§l"+choosen.getName()+"§6 est §e§l"+choosen.getRole().getName());
|
player.sendActionBarMessage("§e§l" + choosen.getName() + "§6 est §e§l" + choosen.getRole().getName());
|
||||||
player.sendMessage("§6Tu découvres que §7§l"+choosen.getName()+"§6 est "+choosen.getRole().getName()+"§6.");
|
player.sendMessage("§6Tu découvres que §7§l" + choosen.getName() + "§6 est " + choosen.getRole().getName() + "§6.");
|
||||||
player.stopChoosing();
|
player.stopChoosing();
|
||||||
player.hideView();
|
player.hideView();
|
||||||
callback.run();
|
callback.run();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onNightTurnTimeout(LGPlayer player) {
|
protected void onNightTurnTimeout(LGPlayer player) {
|
||||||
player.stopChoosing();
|
player.stopChoosing();
|
||||||
|
|
|
@ -1,49 +1,66 @@
|
||||||
package fr.leomelki.loupgarou.roles;
|
package fr.leomelki.loupgarou.roles;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.concurrent.ThreadLocalRandom;
|
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.configuration.file.FileConfiguration;
|
|
||||||
import org.bukkit.event.Listener;
|
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
|
||||||
|
|
||||||
import fr.leomelki.loupgarou.MainLg;
|
import fr.leomelki.loupgarou.MainLg;
|
||||||
import fr.leomelki.loupgarou.classes.LGCustomItems;
|
import fr.leomelki.loupgarou.classes.LGCustomItems;
|
||||||
import fr.leomelki.loupgarou.classes.LGGame;
|
import fr.leomelki.loupgarou.classes.LGGame;
|
||||||
import fr.leomelki.loupgarou.classes.LGPlayer;
|
import fr.leomelki.loupgarou.classes.LGPlayer;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
|
||||||
public abstract class Role implements Listener{
|
import java.util.ArrayList;
|
||||||
@Getter @Setter private int waitedPlayers;
|
import java.util.concurrent.ThreadLocalRandom;
|
||||||
@Getter private final ArrayList<LGPlayer> players = new ArrayList<>();
|
|
||||||
@Getter private final LGGame game;
|
public abstract class Role implements Listener {
|
||||||
|
@Getter
|
||||||
|
private final ArrayList<LGPlayer> players = new ArrayList<>();
|
||||||
|
@Getter
|
||||||
|
private final LGGame game;
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
private int waitedPlayers;
|
||||||
|
|
||||||
public Role(LGGame game) {
|
public Role(LGGame game) {
|
||||||
this.game = game;
|
this.game = game;
|
||||||
Bukkit.getPluginManager().registerEvents(this, MainLg.getInstance());
|
Bukkit.getPluginManager().registerEvents(this, MainLg.getInstance());
|
||||||
FileConfiguration config = MainLg.getInstance().getConfig();
|
FileConfiguration config = MainLg.getInstance().getConfig();
|
||||||
String roleConfigName = "role."+getClass().getSimpleName().substring(1);
|
String roleConfigName = "role." + getClass().getSimpleName().substring(1);
|
||||||
if(config.contains(roleConfigName))
|
if (config.contains(roleConfigName))
|
||||||
waitedPlayers = config.getInt(roleConfigName);
|
waitedPlayers = config.getInt(roleConfigName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public abstract String getName();
|
public abstract String getName();
|
||||||
|
|
||||||
public abstract String getFriendlyName();
|
public abstract String getFriendlyName();
|
||||||
|
|
||||||
public abstract String getShortDescription();
|
public abstract String getShortDescription();
|
||||||
|
|
||||||
public abstract String getDescription();
|
public abstract String getDescription();
|
||||||
|
|
||||||
public abstract String getTask();
|
public abstract String getTask();
|
||||||
|
|
||||||
public abstract String getBroadcastedTask();
|
public abstract String getBroadcastedTask();
|
||||||
|
|
||||||
public RoleType getType(LGPlayer lgp) {
|
public RoleType getType(LGPlayer lgp) {
|
||||||
return getType();
|
return getType();
|
||||||
}
|
}
|
||||||
|
|
||||||
public RoleWinType getWinType(LGPlayer lgp) {
|
public RoleWinType getWinType(LGPlayer lgp) {
|
||||||
return getWinType();
|
return getWinType();
|
||||||
}
|
}
|
||||||
public RoleType getType() {return null;}
|
|
||||||
public RoleWinType getWinType() {return null;}
|
public RoleType getType() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public RoleWinType getWinType() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Timeout in second for this role
|
* @return Timeout in second for this role
|
||||||
*/
|
*/
|
||||||
|
@ -56,26 +73,27 @@ public abstract class Role implements Listener{
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
getGame().cancelWait();
|
getGame().cancelWait();
|
||||||
if(players.size() == 0) {
|
if (players.size() == 0) {
|
||||||
onTurnFinish(callback);
|
onTurnFinish(callback);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
LGPlayer player = players.remove(0);
|
LGPlayer player = players.remove(0);
|
||||||
if(player.isRoleActive()) {
|
if (player.isRoleActive()) {
|
||||||
getGame().wait(getTimeout(), ()->{
|
getGame().wait(getTimeout(), () -> {
|
||||||
try {
|
try {
|
||||||
Role.this.onNightTurnTimeout(player);
|
Role.this.onNightTurnTimeout(player);
|
||||||
}catch(Exception err) {
|
} catch (Exception err) {
|
||||||
System.out.println("Error when timeout role");
|
System.out.println("Error when timeout role");
|
||||||
err.printStackTrace();
|
err.printStackTrace();
|
||||||
}
|
}
|
||||||
this.run();
|
this.run();
|
||||||
}, (currentPlayer, secondsLeft)-> currentPlayer == player ? "§9§lC'est à ton tour !" : "§6C'est au tour "+getFriendlyName()+" §6(§e"+secondsLeft+" s§6)");
|
}, (currentPlayer, secondsLeft) -> currentPlayer == player ? "§9§lC'est à ton tour !" : "§6C'est au tour " + getFriendlyName() + " §6(§e" + secondsLeft + " s§6)");
|
||||||
player.sendMessage("§6"+getTask());
|
player.sendMessage("§6" + getTask());
|
||||||
// player.sendTitle("§6C'est à vous de jouer", "§a"+getTask(), 100);
|
// player.sendTitle("§6C'est à vous de jouer", "§a"+getTask(), 100);
|
||||||
onNightTurn(player, this);
|
onNightTurn(player, this);
|
||||||
} else {
|
} else {
|
||||||
getGame().wait(getTimeout(), ()->{}, (currentPlayer, secondsLeft)-> currentPlayer == player ? "§c§lTu ne peux pas jouer" : "§6C'est au tour "+getFriendlyName()+" §6(§e"+secondsLeft+" s§6)");
|
getGame().wait(getTimeout(), () -> {
|
||||||
|
}, (currentPlayer, secondsLeft) -> currentPlayer == player ? "§c§lTu ne peux pas jouer" : "§6C'est au tour " + getFriendlyName() + " §6(§e" + secondsLeft + " s§6)");
|
||||||
Runnable run = this;
|
Runnable run = this;
|
||||||
new BukkitRunnable() {
|
new BukkitRunnable() {
|
||||||
|
|
||||||
|
@ -83,40 +101,49 @@ public abstract class Role implements Listener{
|
||||||
public void run() {
|
public void run() {
|
||||||
run.run();
|
run.run();
|
||||||
}
|
}
|
||||||
}.runTaskLater(MainLg.getInstance(), 20*(ThreadLocalRandom.current().nextInt(getTimeout()/3*2-4)+4));
|
}.runTaskLater(MainLg.getInstance(), 20 * (ThreadLocalRandom.current().nextInt(getTimeout() / 3 * 2 - 4) + 4));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}.run();
|
}.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void join(LGPlayer player, boolean sendMessage) {
|
public void join(LGPlayer player, boolean sendMessage) {
|
||||||
System.out.println(player.getName()+" est "+getName());
|
System.out.println(player.getName() + " est " + getName());
|
||||||
players.add(player);
|
players.add(player);
|
||||||
if(player.getRole() == null)
|
if (player.getRole() == null)
|
||||||
player.setRole(this);
|
player.setRole(this);
|
||||||
waitedPlayers--;
|
waitedPlayers--;
|
||||||
if(sendMessage) {
|
if (sendMessage) {
|
||||||
player.sendTitle("§6Tu es "+getName(), "§e"+getShortDescription(), 200);
|
player.sendTitle("§6Tu es " + getName(), "§e" + getShortDescription(), 200);
|
||||||
player.sendMessage("§6Tu es "+getName()+"§6.");
|
player.sendMessage("§6Tu es " + getName() + "§6.");
|
||||||
player.sendMessage("§6Description : §f"+getDescription());
|
player.sendMessage("§6Description : §f" + getDescription());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void join(LGPlayer player) {
|
public void join(LGPlayer player) {
|
||||||
join(player, !getGame().isStarted());
|
join(player, !getGame().isStarted());
|
||||||
LGCustomItems.updateItem(player);
|
LGCustomItems.updateItem(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasPlayersLeft() {
|
public boolean hasPlayersLeft() {
|
||||||
return getPlayers().size() > 0;
|
return getPlayers().size() > 0;
|
||||||
}
|
}
|
||||||
protected void onNightTurnTimeout(LGPlayer player) {}
|
|
||||||
protected void onNightTurn(LGPlayer player, Runnable callback) {}
|
protected void onNightTurnTimeout(LGPlayer player) {
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void onNightTurn(LGPlayer player, Runnable callback) {
|
||||||
|
}
|
||||||
|
|
||||||
protected void onTurnFinish(Runnable callback) {
|
protected void onTurnFinish(Runnable callback) {
|
||||||
callback.run();
|
callback.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getTurnOrder() {
|
public int getTurnOrder() {
|
||||||
try {
|
try {
|
||||||
RoleSort role = RoleSort.valueOf(getClass().getSimpleName().substring(1));
|
RoleSort role = RoleSort.valueOf(getClass().getSimpleName().substring(1));
|
||||||
return role == null ? -1 : role.ordinal();
|
return role == null ? -1 : role.ordinal();
|
||||||
}catch(Throwable e) {
|
} catch (Throwable e) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}//En combientième ce rôle doit être appellé
|
}//En combientième ce rôle doit être appellé
|
||||||
|
|
|
@ -1,10 +1,6 @@
|
||||||
package fr.leomelki.loupgarou.scoreboard;
|
package fr.leomelki.loupgarou.scoreboard;
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import com.comphenix.protocol.wrappers.WrappedChatComponent;
|
import com.comphenix.protocol.wrappers.WrappedChatComponent;
|
||||||
|
|
||||||
import fr.leomelki.com.comphenix.packetwrapper.WrapperPlayServerScoreboardDisplayObjective;
|
import fr.leomelki.com.comphenix.packetwrapper.WrapperPlayServerScoreboardDisplayObjective;
|
||||||
import fr.leomelki.com.comphenix.packetwrapper.WrapperPlayServerScoreboardObjective;
|
import fr.leomelki.com.comphenix.packetwrapper.WrapperPlayServerScoreboardObjective;
|
||||||
import fr.leomelki.loupgarou.classes.LGPlayer;
|
import fr.leomelki.loupgarou.classes.LGPlayer;
|
||||||
|
@ -12,18 +8,25 @@ import fr.leomelki.loupgarou.utils.RandomString;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public class CustomScoreboard {
|
public class CustomScoreboard {
|
||||||
@Getter private final String name = RandomString.generate(16);
|
@Getter
|
||||||
@Getter private final String displayName;
|
private final String name = RandomString.generate(16);
|
||||||
|
@Getter
|
||||||
|
private final String displayName;
|
||||||
private final List<CustomScoreboardEntry> entries = Arrays.asList(new CustomScoreboardEntry(15, this), new CustomScoreboardEntry(14, this), new CustomScoreboardEntry(13, this),
|
private final List<CustomScoreboardEntry> entries = Arrays.asList(new CustomScoreboardEntry(15, this), new CustomScoreboardEntry(14, this), new CustomScoreboardEntry(13, this),
|
||||||
new CustomScoreboardEntry(12, this), new CustomScoreboardEntry(11, this), new CustomScoreboardEntry(10, this),
|
new CustomScoreboardEntry(12, this), new CustomScoreboardEntry(11, this), new CustomScoreboardEntry(10, this),
|
||||||
new CustomScoreboardEntry(9, this), new CustomScoreboardEntry(8, this), new CustomScoreboardEntry(7, this),
|
new CustomScoreboardEntry(9, this), new CustomScoreboardEntry(8, this), new CustomScoreboardEntry(7, this),
|
||||||
new CustomScoreboardEntry(6, this), new CustomScoreboardEntry(5, this), new CustomScoreboardEntry(4, this),
|
new CustomScoreboardEntry(6, this), new CustomScoreboardEntry(5, this), new CustomScoreboardEntry(4, this),
|
||||||
new CustomScoreboardEntry(3, this), new CustomScoreboardEntry(2, this), new CustomScoreboardEntry(1, this),
|
new CustomScoreboardEntry(3, this), new CustomScoreboardEntry(2, this), new CustomScoreboardEntry(1, this),
|
||||||
new CustomScoreboardEntry(0, this));
|
new CustomScoreboardEntry(0, this));
|
||||||
@Getter private final LGPlayer player;
|
@Getter
|
||||||
@Getter private boolean shown;
|
private final LGPlayer player;
|
||||||
|
@Getter
|
||||||
|
private boolean shown;
|
||||||
|
|
||||||
public CustomScoreboardEntry getLine(int index) {
|
public CustomScoreboardEntry getLine(int index) {
|
||||||
return entries.get(index);
|
return entries.get(index);
|
||||||
|
@ -41,7 +44,7 @@ public class CustomScoreboard {
|
||||||
display.sendPacket(player.getPlayer());
|
display.sendPacket(player.getPlayer());
|
||||||
shown = true;
|
shown = true;
|
||||||
|
|
||||||
for(CustomScoreboardEntry entry : entries)
|
for (CustomScoreboardEntry entry : entries)
|
||||||
entry.show();
|
entry.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,7 +54,7 @@ public class CustomScoreboard {
|
||||||
remove.setName(name);
|
remove.setName(name);
|
||||||
remove.sendPacket(player.getPlayer());
|
remove.sendPacket(player.getPlayer());
|
||||||
|
|
||||||
for(CustomScoreboardEntry entry : entries)
|
for (CustomScoreboardEntry entry : entries)
|
||||||
entry.hide();
|
entry.hide();
|
||||||
|
|
||||||
shown = false;
|
shown = false;
|
||||||
|
|
|
@ -1,39 +1,39 @@
|
||||||
package fr.leomelki.loupgarou.scoreboard;
|
package fr.leomelki.loupgarou.scoreboard;
|
||||||
|
|
||||||
import java.util.Collections;
|
|
||||||
|
|
||||||
import com.comphenix.protocol.wrappers.EnumWrappers.ScoreboardAction;
|
import com.comphenix.protocol.wrappers.EnumWrappers.ScoreboardAction;
|
||||||
import com.comphenix.protocol.wrappers.WrappedChatComponent;
|
import com.comphenix.protocol.wrappers.WrappedChatComponent;
|
||||||
|
|
||||||
import fr.leomelki.com.comphenix.packetwrapper.WrapperPlayServerScoreboardScore;
|
import fr.leomelki.com.comphenix.packetwrapper.WrapperPlayServerScoreboardScore;
|
||||||
import fr.leomelki.com.comphenix.packetwrapper.WrapperPlayServerScoreboardTeam;
|
import fr.leomelki.com.comphenix.packetwrapper.WrapperPlayServerScoreboardTeam;
|
||||||
import fr.leomelki.loupgarou.utils.VariousUtils;
|
import fr.leomelki.loupgarou.utils.VariousUtils;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
|
||||||
public class CustomScoreboardEntry {
|
public class CustomScoreboardEntry {
|
||||||
private static final WrappedChatComponent nullComponent = WrappedChatComponent.fromText("");
|
private static final WrappedChatComponent nullComponent = WrappedChatComponent.fromText("");
|
||||||
|
|
||||||
//setter car flemme de modifier le systeme pour le rendre plus logique
|
|
||||||
@Getter @Setter private int score;
|
|
||||||
private final String name;
|
private final String name;
|
||||||
private final CustomScoreboard scoreboard;
|
private final CustomScoreboard scoreboard;
|
||||||
|
//setter car flemme de modifier le systeme pour le rendre plus logique
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
private int score;
|
||||||
private WrappedChatComponent prefix, suffix;
|
private WrappedChatComponent prefix, suffix;
|
||||||
|
|
||||||
public CustomScoreboardEntry(int score, CustomScoreboard scoreboard) {
|
public CustomScoreboardEntry(int score, CustomScoreboard scoreboard) {
|
||||||
this.score = score;
|
this.score = score;
|
||||||
this.scoreboard = scoreboard;
|
this.scoreboard = scoreboard;
|
||||||
this.name = "§"+VariousUtils.toHex(score);
|
this.name = "§" + VariousUtils.toHex(score);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void show() {
|
public void show() {
|
||||||
if(prefix != null) {
|
if (prefix != null) {
|
||||||
WrapperPlayServerScoreboardTeam team = new WrapperPlayServerScoreboardTeam();
|
WrapperPlayServerScoreboardTeam team = new WrapperPlayServerScoreboardTeam();
|
||||||
team.setPlayers(Collections.singletonList(name));
|
team.setPlayers(Collections.singletonList(name));
|
||||||
team.setName(name);
|
team.setName(name);
|
||||||
team.setMode(0);
|
team.setMode(0);
|
||||||
team.setPrefix(prefix);
|
team.setPrefix(prefix);
|
||||||
if(suffix != null)
|
if (suffix != null)
|
||||||
team.setSuffix(suffix);
|
team.setSuffix(suffix);
|
||||||
team.sendPacket(scoreboard.getPlayer().getPlayer());
|
team.sendPacket(scoreboard.getPlayer().getPlayer());
|
||||||
|
|
||||||
|
@ -48,32 +48,31 @@ public class CustomScoreboardEntry {
|
||||||
|
|
||||||
public void setDisplayName(String displayName) {
|
public void setDisplayName(String displayName) {
|
||||||
boolean spawn = prefix == null;
|
boolean spawn = prefix == null;
|
||||||
if(displayName.length() > 16) {
|
if (displayName.length() > 16) {
|
||||||
char colorCode = 'f';
|
char colorCode = 'f';
|
||||||
int limit = displayName.charAt(14) == '§' && displayName.charAt(13) != '§' ? 14 : displayName.charAt(15) == '§' ? 15 : 16;
|
int limit = displayName.charAt(14) == '§' && displayName.charAt(13) != '§' ? 14 : displayName.charAt(15) == '§' ? 15 : 16;
|
||||||
String prefixStr = displayName.substring(0, limit);
|
String prefixStr = displayName.substring(0, limit);
|
||||||
|
|
||||||
prefix = WrappedChatComponent.fromText(prefixStr);
|
prefix = WrappedChatComponent.fromText(prefixStr);
|
||||||
|
|
||||||
if(limit == 16) {
|
if (limit == 16) {
|
||||||
boolean storeColorCode = false;
|
boolean storeColorCode = false;
|
||||||
for(char c : prefixStr.toCharArray())
|
for (char c : prefixStr.toCharArray())
|
||||||
if(storeColorCode) {
|
if (storeColorCode) {
|
||||||
storeColorCode = false;
|
storeColorCode = false;
|
||||||
colorCode = c;
|
colorCode = c;
|
||||||
}else
|
} else if (c == '§')
|
||||||
if(c == '§')
|
|
||||||
storeColorCode = true;
|
storeColorCode = true;
|
||||||
suffix = WrappedChatComponent.fromText("§"+colorCode+displayName.substring(limit));
|
suffix = WrappedChatComponent.fromText("§" + colorCode + displayName.substring(limit));
|
||||||
}else
|
} else
|
||||||
suffix = WrappedChatComponent.fromText(displayName.substring(limit));
|
suffix = WrappedChatComponent.fromText(displayName.substring(limit));
|
||||||
} else {
|
} else {
|
||||||
prefix = WrappedChatComponent.fromText(displayName);
|
prefix = WrappedChatComponent.fromText(displayName);
|
||||||
suffix = nullComponent;
|
suffix = nullComponent;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(scoreboard.isShown()) {
|
if (scoreboard.isShown()) {
|
||||||
if(spawn)
|
if (spawn)
|
||||||
show();
|
show();
|
||||||
else {
|
else {
|
||||||
WrapperPlayServerScoreboardTeam team = new WrapperPlayServerScoreboardTeam();
|
WrapperPlayServerScoreboardTeam team = new WrapperPlayServerScoreboardTeam();
|
||||||
|
@ -81,18 +80,20 @@ public class CustomScoreboardEntry {
|
||||||
team.setName(name);
|
team.setName(name);
|
||||||
team.setMode(2);
|
team.setMode(2);
|
||||||
team.setPrefix(prefix);
|
team.setPrefix(prefix);
|
||||||
if(suffix != null)
|
if (suffix != null)
|
||||||
team.setSuffix(suffix);
|
team.setSuffix(suffix);
|
||||||
team.sendPacket(scoreboard.getPlayer().getPlayer());
|
team.sendPacket(scoreboard.getPlayer().getPlayer());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void delete() {
|
public void delete() {
|
||||||
hide();
|
hide();
|
||||||
prefix = null;
|
prefix = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void hide() {
|
public void hide() {
|
||||||
if(prefix != null && scoreboard.isShown()) {
|
if (prefix != null && scoreboard.isShown()) {
|
||||||
WrapperPlayServerScoreboardScore score = new WrapperPlayServerScoreboardScore();
|
WrapperPlayServerScoreboardScore score = new WrapperPlayServerScoreboardScore();
|
||||||
score.setObjectiveName(scoreboard.getName());
|
score.setObjectiveName(scoreboard.getName());
|
||||||
score.setScoreboardAction(ScoreboardAction.REMOVE);
|
score.setScoreboardAction(ScoreboardAction.REMOVE);
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue