Reformat code

This commit is contained in:
Ethanell 2020-09-07 23:40:57 +02:00
parent 53f1508a01
commit 20b545b93d
108 changed files with 10123 additions and 9809 deletions

View file

@ -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>

View file

@ -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

View file

@ -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/>.
*/ */

View file

@ -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));
} }

View file

@ -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/>.
*/ */

View file

@ -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;

View file

@ -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/>.
*/ */

View file

@ -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 =

View file

@ -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;

View file

@ -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 =

View file

@ -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 =

View file

@ -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/>.
*/ */

View file

@ -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/>.
*/ */

View file

@ -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 =

View file

@ -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 =

View file

@ -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;

View file

@ -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
}
} }

View file

@ -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;

View file

@ -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/>.
*/ */

View file

@ -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;
}
}
} }

View file

@ -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/>.
*/ */

View file

@ -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;
}
}
} }

View file

@ -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;
}
}
} }

View file

@ -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.
* *

View file

@ -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/>.
*/ */

View file

@ -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/>.
*/ */

View file

@ -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/>.
*/ */

View file

@ -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/>.
*/ */

View file

@ -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,71 +33,26 @@ 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;
import fr.leomelki.com.comphenix.packetwrapper.WrapperPlayServerNamedSoundEffect;
import fr.leomelki.com.comphenix.packetwrapper.WrapperPlayServerPlayerInfo;
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 { public class MainLg extends JavaPlugin {
@Getter
private static final String prefix = ""/*"§7[§9Loup-Garou§7] "*/;
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() {
@ -324,7 +287,9 @@ public class MainLg extends JavaPlugin{
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];
@ -365,6 +330,7 @@ public class MainLg extends JavaPlugin{
} }
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"))
@ -382,6 +348,7 @@ public class MainLg extends JavaPlugin{
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<>();
@ -392,19 +359,19 @@ public class MainLg extends JavaPlugin{
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));

View file

@ -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++;
} }

View file

@ -1,23 +1,23 @@
package fr.leomelki.loupgarou.classes; package fr.leomelki.loupgarou.classes;
import java.util.ArrayList; import fr.leomelki.loupgarou.events.LGCustomItemChangeEvent;
import java.util.Collections; import fr.leomelki.loupgarou.roles.Role;
import java.util.HashMap; import lombok.Getter;
import java.util.StringJoiner; import lombok.RequiredArgsConstructor;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.json.simple.JSONObject; import org.json.simple.JSONObject;
import org.json.simple.parser.JSONParser; import org.json.simple.parser.JSONParser;
import fr.leomelki.loupgarou.events.LGCustomItemChangeEvent; import java.util.ArrayList;
import fr.leomelki.loupgarou.roles.Role; import java.util.Collections;
import lombok.Getter; import java.util.HashMap;
import lombok.RequiredArgsConstructor; import java.util.StringJoiner;
public class LGCustomItems { public class LGCustomItems {
static final HashMap<Class<? extends Role>, HashMap<String, Material>> mappings = new HashMap<>(); static final HashMap<Class<? extends Role>, HashMap<String, Material>> mappings = new HashMap<>();
static { static {
JSONParser parser = new JSONParser(); JSONParser parser = new JSONParser();
try { try {
@ -41,6 +41,7 @@ public class LGCustomItems {
public static Material getItem(Role role) { public static Material getItem(Role role) {
return mappings.get(role.getClass()).get(""); return mappings.get(role.getClass()).get("");
} }
public static Material getItem(LGPlayer player, ArrayList<String> constraints) { public static Material getItem(LGPlayer player, ArrayList<String> constraints) {
Bukkit.getPluginManager().callEvent(new LGCustomItemChangeEvent(player.getGame(), player, constraints)); Bukkit.getPluginManager().callEvent(new LGCustomItemChangeEvent(player.getGame(), player, constraints));
@ -53,6 +54,7 @@ public class LGCustomItems {
sj.add(s); sj.add(s);
return mapps.get(sj.toString()); return mapps.get(sj.toString());
} }
public static Material getItem(LGPlayer player) { public static Material getItem(LGPlayer player) {
return getItem(player, new ArrayList<>()); return getItem(player, new ArrayList<>());
} }
@ -73,7 +75,8 @@ public class LGCustomItems {
MAYOR("maire"), MAYOR("maire"),
VAMPIRE_INFECTE("vampire-infecte"), VAMPIRE_INFECTE("vampire-infecte"),
DEAD("mort"); DEAD("mort");
@Getter private final String name; @Getter
private final String name;
} }
} }

View file

@ -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;
} }

View file

@ -1,13 +1,22 @@
package fr.leomelki.loupgarou.classes; package fr.leomelki.loupgarou.classes;
import java.lang.reflect.Constructor; import com.comphenix.protocol.wrappers.EnumWrappers.NativeGameMode;
import java.security.SecureRandom; import com.comphenix.protocol.wrappers.EnumWrappers.PlayerInfoAction;
import java.util.ArrayList; import com.comphenix.protocol.wrappers.PlayerInfoData;
import java.util.Comparator; import com.comphenix.protocol.wrappers.WrappedChatComponent;
import java.util.HashMap; import com.comphenix.protocol.wrappers.WrappedGameProfile;
import java.util.List; import fr.leomelki.com.comphenix.packetwrapper.*;
import java.util.Map.Entry; import fr.leomelki.loupgarou.MainLg;
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 fr.leomelki.loupgarou.roles.*;
import fr.leomelki.loupgarou.scoreboard.CustomScoreboard;
import fr.leomelki.loupgarou.utils.MultipleValueMap;
import fr.leomelki.loupgarou.utils.VariousUtils;
import lombok.Getter;
import lombok.Setter;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.GameMode; import org.bukkit.GameMode;
import org.bukkit.Location; import org.bukkit.Location;
@ -23,73 +32,56 @@ import org.bukkit.potion.PotionEffectType;
import org.bukkit.scheduler.BukkitRunnable; import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.scheduler.BukkitTask; import org.bukkit.scheduler.BukkitTask;
import com.comphenix.protocol.wrappers.EnumWrappers.NativeGameMode; import java.lang.reflect.Constructor;
import com.comphenix.protocol.wrappers.EnumWrappers.PlayerInfoAction; import java.security.SecureRandom;
import com.comphenix.protocol.wrappers.PlayerInfoData; import java.util.ArrayList;
import com.comphenix.protocol.wrappers.WrappedChatComponent; import java.util.Comparator;
import com.comphenix.protocol.wrappers.WrappedGameProfile; import java.util.HashMap;
import java.util.List;
import fr.leomelki.com.comphenix.packetwrapper.WrapperPlayServerChat; import java.util.Map.Entry;
import fr.leomelki.com.comphenix.packetwrapper.WrapperPlayServerEntityDestroy;
import fr.leomelki.com.comphenix.packetwrapper.WrapperPlayServerExperience;
import fr.leomelki.com.comphenix.packetwrapper.WrapperPlayServerPlayerInfo;
import fr.leomelki.com.comphenix.packetwrapper.WrapperPlayServerScoreboardObjective;
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.MainLg;
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.LGDayEndEvent;
import fr.leomelki.loupgarou.events.LGDayStartEvent;
import fr.leomelki.loupgarou.events.LGEndCheckEvent;
import fr.leomelki.loupgarou.events.LGGameEndEvent;
import fr.leomelki.loupgarou.events.LGGameJoinEvent;
import fr.leomelki.loupgarou.events.LGMayorVoteEvent;
import fr.leomelki.loupgarou.events.LGNightEndEvent;
import fr.leomelki.loupgarou.events.LGNightPlayerPreKilledEvent;
import fr.leomelki.loupgarou.events.LGNightStart;
import fr.leomelki.loupgarou.events.LGPlayerGotKilledEvent;
import fr.leomelki.loupgarou.events.LGPlayerKilledEvent;
import fr.leomelki.loupgarou.events.LGPlayerKilledEvent.Reason;
import fr.leomelki.loupgarou.events.LGPreDayStartEvent;
import fr.leomelki.loupgarou.events.LGRoleTurnEndEvent;
import fr.leomelki.loupgarou.events.LGSkinLoadEvent;
import fr.leomelki.loupgarou.events.LGVoteEvent;
import fr.leomelki.loupgarou.events.LGVoteLeaderChange;
import fr.leomelki.loupgarou.roles.RChienLoupLG;
import fr.leomelki.loupgarou.roles.REnfantSauvageLG;
import fr.leomelki.loupgarou.roles.Role;
import fr.leomelki.loupgarou.roles.RoleType;
import fr.leomelki.loupgarou.roles.RoleWinType;
import fr.leomelki.loupgarou.scoreboard.CustomScoreboard;
import fr.leomelki.loupgarou.utils.MultipleValueMap;
import fr.leomelki.loupgarou.utils.VariousUtils;
import lombok.Getter;
import lombok.Setter;
public class LGGame implements Listener { public class LGGame implements Listener {
private static final boolean autoStart = false; private static final boolean autoStart = false;
@Getter private final SecureRandom random = new SecureRandom(); @Getter
@Getter private final int maxPlayers; private final SecureRandom random = new SecureRandom();
@Getter private final ArrayList<LGPlayer> inGame = new ArrayList<>(); @Getter
@Getter private final ArrayList<Role> roles = new ArrayList<>(); private final int maxPlayers;
@Getter private final MainLg plugin; @Getter
private final ArrayList<LGPlayer> inGame = new ArrayList<>();
@Getter private boolean started; @Getter
@Getter private int night = 0; private final ArrayList<Role> roles = new ArrayList<>();
@Getter
private final MainLg plugin;
@Getter
private final HashMap<Integer, LGPlayer> placements = new HashMap<>();
@Getter
private final LGChat spectatorChat = new LGChat((sender, message) -> "§7" + sender.getName() + " §6» §f" + message);
@Getter
private final LGChat dayChat = new LGChat((sender, message) -> "§e" + sender.getName() + " §6» §f" + message);
@Getter
private final MultipleValueMap<LGPlayerKilledEvent.Reason, LGPlayer> deaths = new MultipleValueMap<>();
@Getter
public long time = 0;
@Setter
boolean ended;
boolean isPeopleVote = false;
@Getter
private boolean started;
@Getter
private int night = 0;
private BukkitTask startingTask; private BukkitTask startingTask;
@Getter @Setter private int waitTicks; @Getter
@Getter private boolean day; @Setter
@Getter public long time = 0; private int waitTicks;
@Getter private final HashMap<Integer, LGPlayer> placements = new HashMap<>(); @Getter
private boolean day;
@Getter private final LGChat spectatorChat = new LGChat((sender, message) -> "§7"+sender.getName()+" §6» §f"+message); private BukkitTask waitTask;
@Getter private final LGChat dayChat = new LGChat((sender, message) -> "§e"+sender.getName()+" §6» §f"+message); @Getter
private LGPlayer mayor;
@Getter
private LGVote vote;
public LGGame(MainLg mainLg, int maxPlayers) { public LGGame(MainLg mainLg, int maxPlayers) {
this.plugin = mainLg; this.plugin = mainLg;
@ -97,9 +89,6 @@ public class LGGame implements Listener{
Bukkit.getPluginManager().registerEvents(this, MainLg.getInstance()); Bukkit.getPluginManager().registerEvents(this, MainLg.getInstance());
} }
@Getter
private final MultipleValueMap<LGPlayerKilledEvent.Reason, LGPlayer> deaths = new MultipleValueMap<>();
public void sendActionBarMessage(String msg) { public void sendActionBarMessage(String msg) {
WrapperPlayServerChat chat = new WrapperPlayServerChat(); WrapperPlayServerChat chat = new WrapperPlayServerChat();
chat.setPosition((byte) 2); chat.setPosition((byte) 2);
@ -107,19 +96,21 @@ public class LGGame implements Listener{
for (LGPlayer lgp : inGame) for (LGPlayer lgp : inGame)
chat.sendPacket(lgp.getPlayer()); chat.sendPacket(lgp.getPlayer());
} }
public void broadcastMessage(String msg) { public void broadcastMessage(String msg) {
for (LGPlayer lgp : inGame) for (LGPlayer lgp : inGame)
lgp.sendMessage(msg); lgp.sendMessage(msg);
} }
public void broadcastSpacer() { public void broadcastSpacer() {
for (LGPlayer lgp : inGame) for (LGPlayer lgp : inGame)
lgp.getPlayer().sendMessage("\n"); lgp.getPlayer().sendMessage("\n");
} }
private BukkitTask waitTask;
public void wait(int seconds, Runnable callback) { public void wait(int seconds, Runnable callback) {
wait(seconds, callback, null); wait(seconds, callback, null);
} }
public void wait(int seconds, Runnable callback, TextGenerator generator) { public void wait(int seconds, Runnable callback, TextGenerator generator) {
cancelWait(); cancelWait();
waitTicks = seconds * 20; waitTicks = seconds * 20;
@ -145,6 +136,7 @@ public class LGGame implements Listener{
} }
}.runTaskTimer(MainLg.getInstance(), 0, 1); }.runTaskTimer(MainLg.getInstance(), 0, 1);
} }
public void wait(int seconds, int initialSeconds, Runnable callback, TextGenerator generator) { public void wait(int seconds, int initialSeconds, Runnable callback, TextGenerator generator) {
cancelWait(); cancelWait();
waitTicks = seconds * 20; waitTicks = seconds * 20;
@ -171,9 +163,6 @@ public class LGGame implements Listener{
}.runTaskTimer(MainLg.getInstance(), 0, 1); }.runTaskTimer(MainLg.getInstance(), 0, 1);
} }
public interface TextGenerator{
String generate(LGPlayer player, int secondsLeft);
}
public void cancelWait() { public void cancelWait() {
if (waitTask != null) { if (waitTask != null) {
waitTask.cancel(); waitTask.cancel();
@ -189,6 +178,7 @@ public class LGGame implements Listener{
deaths.put(event.getReason(), player); deaths.put(event.getReason(), player);
} }
} }
public boolean tryToJoin(LGPlayer lgp) { public boolean tryToJoin(LGPlayer lgp) {
if (ended) return false; if (ended) return false;
if (!started && inGame.size() < maxPlayers) {//Si la partie n'a pas démarrée et qu'il reste de la place if (!started && inGame.size() < maxPlayers) {//Si la partie n'a pas démarrée et qu'il reste de la place
@ -259,6 +249,7 @@ public class LGGame implements Listener{
} }
return false; return false;
} }
public void checkLeave() { public void checkLeave() {
if (startingTask != null) { if (startingTask != null) {
startingTask.cancel(); startingTask.cancel();
@ -266,6 +257,7 @@ public class LGGame implements Listener{
broadcastMessage("§c§oUn joueur s'est déconnecté. Le décompte de lancement a donc été arrêté."); broadcastMessage("§c§oUn joueur s'est déconnecté. Le décompte de lancement a donc été arrêté.");
} }
} }
public void updateStart() { public void updateStart() {
if (!isStarted()) if (!isStarted())
if (inGame.size() == maxPlayers) {//Il faut que la partie soit totalement remplie pour qu'elle démarre car sinon, tous les rôles ne seraient pas distribués if (inGame.size() == maxPlayers) {//Il faut que la partie soit totalement remplie pour qu'elle démarre car sinon, tous les rôles ne seraient pas distribués
@ -277,6 +269,7 @@ public class LGGame implements Listener{
if (startingTask == null) { if (startingTask == null) {
startingTask = new BukkitRunnable() { startingTask = new BukkitRunnable() {
int timeLeft = 5 + 1; int timeLeft = 5 + 1;
@Override @Override
public void run() { public void run() {
if (--timeLeft == 0)//start if (--timeLeft == 0)//start
@ -291,6 +284,7 @@ public class LGGame implements Listener{
broadcastMessage("§c§oLe démarrage de la partie a été annulé car une personne l'a quittée !"); broadcastMessage("§c§oLe démarrage de la partie a été annulé car une personne l'a quittée !");
} }
} }
public void start() { public void start() {
if (startingTask != null) { if (startingTask != null) {
startingTask.cancel(); startingTask.cancel();
@ -331,6 +325,7 @@ public class LGGame implements Listener{
new BukkitRunnable() { new BukkitRunnable() {
int timeLeft = 5 * 2; int timeLeft = 5 * 2;
int actualRole = getRoles().size(); int actualRole = getRoles().size();
@Override @Override
public void run() { public void run() {
if (--timeLeft == 0) { if (--timeLeft == 0) {
@ -359,6 +354,7 @@ public class LGGame implements Listener{
} }
}.runTaskTimer(MainLg.getInstance(), 0, 4); }.runTaskTimer(MainLg.getInstance(), 0, 4);
} }
private void _start() { private void _start() {
broadcastMessage("§8§oDébut de la partie..."); broadcastMessage("§8§oDébut de la partie...");
//Give roles... //Give roles...
@ -386,6 +382,7 @@ public class LGGame implements Listener{
//Start day one //Start day one
nextNight(10); nextNight(10);
} }
public void updateRoleScoreboard() { public void updateRoleScoreboard() {
HashMap<Role, IndexedRole> roles_ = new HashMap<>(); HashMap<Role, IndexedRole> roles_ = new HashMap<>();
for (LGPlayer lgp : getAlive()) for (LGPlayer lgp : getAlive())
@ -411,6 +408,7 @@ public class LGGame implements Listener{
for (LGPlayer lgp : getInGame()) for (LGPlayer lgp : getInGame())
lgp.getScoreboard().getLine(i).delete(); lgp.getScoreboard().getLine(i).delete();
} }
public List<LGPlayer> getAlive() { public List<LGPlayer> getAlive() {
ArrayList<LGPlayer> alive = new ArrayList<>(); ArrayList<LGPlayer> alive = new ArrayList<>();
for (LGPlayer lgp : getInGame()) for (LGPlayer lgp : getInGame())
@ -422,6 +420,7 @@ public class LGGame implements Listener{
public void nextNight() { public void nextNight() {
nextNight(5); nextNight(5);
} }
public void nextNight(int timeout) { public void nextNight(int timeout) {
if (ended) return; if (ended) return;
LGNightStart event = new LGNightStart(this); LGNightStart event = new LGNightStart(this);
@ -452,6 +451,7 @@ public class LGGame implements Listener{
new BukkitRunnable() { new BukkitRunnable() {
int timeoutLeft = timeout * 20; int timeoutLeft = timeout * 20;
@Override @Override
public void run() { public void run() {
if (--timeoutLeft <= 20 + 20 * 2) { if (--timeoutLeft <= 20 + 20 * 2) {
@ -467,6 +467,7 @@ public class LGGame implements Listener{
}.runTaskTimer(MainLg.getInstance(), 1, 1); }.runTaskTimer(MainLg.getInstance(), 1, 1);
LGGame.this.wait(timeout, this::nextNight_, (player, secondsLeft) -> "§6La nuit va tomber dans §e" + secondsLeft + " seconde" + (secondsLeft > 1 ? "s" : "")); LGGame.this.wait(timeout, this::nextNight_, (player, secondsLeft) -> "§6La nuit va tomber dans §e" + secondsLeft + " seconde" + (secondsLeft > 1 ? "s" : ""));
} }
private void nextNight_() { private void nextNight_() {
if (ended) return; if (ended) return;
night++; night++;
@ -515,6 +516,7 @@ public class LGGame implements Listener{
} }
}.run(); }.run();
} }
public boolean kill(LGPlayer killed, Reason reason, boolean endGame) { public boolean kill(LGPlayer killed, Reason reason, boolean endGame) {
if (killed.getPlayer() != null) { if (killed.getPlayer() != null) {
killed.getPlayer().addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, 999999, 1, false, false)); killed.getPlayer().addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, 999999, 1, false, false));
@ -578,8 +580,6 @@ public class LGGame implements Listener{
e.getWinners().add(lgp); e.getWinners().add(lgp);
} }
@Setter
boolean ended;
public void endGame(LGWinType winType) { public void endGame(LGWinType winType) {
if (ended) return; if (ended) return;
@ -612,8 +612,7 @@ public class LGGame implements Listener{
if (winners.contains(lgp)) if (winners.contains(lgp))
lgp.sendTitle("§a§lVictoire !", "§6Vous avez gagné la partie.", 200); lgp.sendTitle("§a§lVictoire !", "§6Vous avez gagné la partie.", 200);
else else if (winType == LGWinType.EQUAL || winType == LGWinType.NONE)
if(winType == LGWinType.EQUAL || winType == LGWinType.NONE)
lgp.sendTitle("§7§lÉgalité", "§8Personne n'a gagné...", 200); lgp.sendTitle("§7§lÉgalité", "§8Personne n'a gagné...", 200);
else else
lgp.sendTitle("§c§lDéfaite...", "§4Vous avez perdu la partie.", 200); lgp.sendTitle("§c§lDéfaite...", "§4Vous avez perdu la partie.", 200);
@ -648,9 +647,11 @@ public class LGGame implements Listener{
return "§6Démarrage d'une nouvelle partie dans §e"+secondsLeft+" seconde"+(secondsLeft > 1 ? "s" : ""); return "§6Démarrage d'une nouvelle partie dans §e"+secondsLeft+" seconde"+(secondsLeft > 1 ? "s" : "");
});*/ });*/
} }
public boolean mayorKilled() { public boolean mayorKilled() {
return getMayor() != null && getMayor().isDead(); return getMayor() != null && getMayor().isDead();
} }
public void endNight() { public void endNight() {
if (ended) return; if (ended) return;
broadcastSpacer(); broadcastSpacer();
@ -697,6 +698,7 @@ public class LGGame implements Listener{
new BukkitRunnable() { new BukkitRunnable() {
int timeoutLeft = 20; int timeoutLeft = 20;
@Override @Override
public void run() { public void run() {
if (timeoutLeft++ > 20) { if (timeoutLeft++ > 20) {
@ -720,6 +722,7 @@ public class LGGame implements Listener{
startDay(); startDay();
} }
} }
public void startDay() { public void startDay() {
for (LGPlayer player : getInGame()) for (LGPlayer player : getInGame())
player.joinChat(dayChat, player.isDead()); player.joinChat(dayChat, player.isDead());
@ -760,7 +763,6 @@ public class LGGame implements Listener{
}.runTaskLater(MainLg.getInstance(), 40); }.runTaskLater(MainLg.getInstance(), 40);
} }
@Getter private LGPlayer mayor;
public void setMayor(LGPlayer mayor) { public void setMayor(LGPlayer mayor) {
LGPlayer latestMayor = this.mayor; LGPlayer latestMayor = this.mayor;
@ -786,6 +788,7 @@ public class LGGame implements Listener{
e.getConstraints().add(LGCustomItemsConstraints.DEAD.getName()); e.getConstraints().add(LGCustomItemsConstraints.DEAD.getName());
} }
} }
@EventHandler(priority = EventPriority.LOWEST) @EventHandler(priority = EventPriority.LOWEST)
public void onSkinChange(LGSkinLoadEvent e) { public void onSkinChange(LGSkinLoadEvent e) {
if (e.getGame() == this) { if (e.getGame() == this) {
@ -815,8 +818,7 @@ public class LGGame implements Listener{
}); });
} }
} }
@Getter private LGVote vote;
boolean isPeopleVote = false;
@EventHandler @EventHandler
public void leaderChange(LGVoteLeaderChange e) { public void leaderChange(LGVoteLeaderChange e) {
if (isPeopleVote && vote != null && e.getGame() == this) { if (isPeopleVote && vote != null && e.getGame() == this) {
@ -829,6 +831,7 @@ public class LGGame implements Listener{
VariousUtils.setWarning(player.getPlayer(), true); VariousUtils.setWarning(player.getPlayer(), true);
} }
} }
private void peopleVote() { private void peopleVote() {
if (ended) return; if (ended) return;
LGVoteEvent event = new LGVoteEvent(this); LGVoteEvent event = new LGVoteEvent(this);
@ -857,6 +860,7 @@ public class LGGame implements Listener{
public boolean checkEndGame() { public boolean checkEndGame() {
return checkEndGame(true); return checkEndGame(true);
} }
public boolean checkEndGame(boolean doEndGame) { public boolean checkEndGame(boolean doEndGame) {
int goodGuy = 0, badGuy = 0, solo = 0, vampires = 0; int goodGuy = 0, badGuy = 0, solo = 0, vampires = 0;
for (LGPlayer lgp : getAlive()) for (LGPlayer lgp : getAlive())
@ -884,4 +888,8 @@ public class LGGame implements Listener{
endGame(event.getWinType()); endGame(event.getWinType());
return event.getWinType() != LGWinType.NONE; return event.getWinType() != LGWinType.NONE;
} }
public interface TextGenerator {
String generate(LGPlayer player, int secondsLeft);
}
} }

View file

@ -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,10 +26,59 @@ 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
private final VariableCache cache = new VariableCache();
public boolean canSelectDead;
@Getter
boolean muted;
long lastChoose;
@Getter
@Setter
private int place;
@Getter
private Player player;
@Getter
@Setter
private boolean dead;
@Setter
@Getter
private Role role;
private LGChooseCallback chooseCallback;
private List<LGPlayer> blacklistedChoice = new ArrayList<>(0);
@Getter
@Setter
private LGGame game;
@Getter
@Setter
private String latestObjective;
@Getter
private CustomScoreboard scoreboard;
private String name;
@Getter
private LGChat chat;
public LGPlayer(MainLg mainLg, Player player) {
this.plugin = mainLg;
this.player = player;
}
public LGPlayer(MainLg mainLg, String name) {
this.plugin = mainLg;
this.name = name;
}
public static LGPlayer thePlayer(MainLg plugin, Player player) { public static LGPlayer thePlayer(MainLg plugin, Player player) {
LGPlayer lgp = cachedPlayers.get(player); LGPlayer lgp = cachedPlayers.get(player);
@ -50,27 +88,10 @@ public class LGPlayer {
} }
return lgp; return lgp;
} }
public static LGPlayer removePlayer(Player player) { public static LGPlayer removePlayer(Player player) {
return cachedPlayers.remove(player);//.remove(); return cachedPlayers.remove(player);//.remove();
} }
@Getter @Setter private int place;
@Getter private Player player;
@Getter @Setter private boolean dead;
@Setter @Getter private Role role;
private LGChooseCallback chooseCallback;
private List<LGPlayer> blacklistedChoice = new ArrayList<>(0);
@Getter private final VariableCache cache = new VariableCache();
@Getter @Setter private LGGame game;
@Getter @Setter private String latestObjective;
@Getter private CustomScoreboard scoreboard;
public LGPlayer(MainLg mainLg, Player player) {
this.plugin = mainLg;
this.player = player;
}
public LGPlayer(MainLg mainLg, String name) {
this.plugin = mainLg;
this.name = name;
}
public void setScoreboard(CustomScoreboard scoreboard) { public void setScoreboard(CustomScoreboard scoreboard) {
if (player != null) { if (player != null) {
@ -92,10 +113,12 @@ public class LGPlayer {
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();
@ -116,15 +139,15 @@ 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 !");
@ -139,20 +162,18 @@ 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())
@ -201,6 +222,7 @@ 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();
@ -237,6 +259,7 @@ public class LGPlayer {
} }
} }
} }
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)
@ -263,7 +286,7 @@ 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)
@ -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,14 +317,10 @@ 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())
@ -308,21 +328,23 @@ public class LGPlayer {
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);
@ -350,12 +372,12 @@ public class LGPlayer {
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) {
@ -369,4 +391,8 @@ public class LGPlayer {
public String toString() { public String toString() {
return super.toString() + " (" + getName() + ")"; return super.toString() + " (" + getName() + ")";
} }
public interface LGChooseCallback {
void callback(LGPlayer choosen);
}
} }

View file

@ -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,6 +12,7 @@ public enum LGSound {
@Getter @Getter
final Sound sound; final Sound sound;
LGSound(Sound sound) { LGSound(Sound sound) {
this.sound = sound; this.sound = sound;
} }

View file

@ -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");
@ -105,6 +46,70 @@ public class LGVote {
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)
@ -204,12 +209,14 @@ 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.");
@ -283,6 +290,7 @@ public class LGVote {
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();
@ -368,11 +376,7 @@ 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();
@ -469,6 +473,7 @@ 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) {

View file

@ -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;
} }

View file

@ -1,21 +1,18 @@
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);
@ -29,7 +26,16 @@ public class LGChat {
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;
}
}
} }

View file

@ -7,11 +7,13 @@ public class LGNoChat extends LGChat{
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) {
} }

View file

@ -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);

View file

@ -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 { public class LGDayStartEvent extends LGEvent implements Cancellable {
@Getter
@Setter
private boolean cancelled;
public LGDayStartEvent(LGGame game) { public LGDayStartEvent(LGGame game) {
super(game); super(game);
} }
@Getter @Setter private boolean cancelled;
} }

View file

@ -6,10 +6,12 @@ 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;
} }

View file

@ -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;
}
} }

View file

@ -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 { public class LGGameEndEvent extends LGEvent implements Cancellable {
@Getter @Setter private boolean cancelled; @Getter
@Getter private final LGWinType winType; private final LGWinType winType;
@Getter private final List<LGPlayer> winners; @Getter
private final List<LGPlayer> winners;
@Getter
@Setter
private boolean cancelled;
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;

View file

@ -5,11 +5,11 @@ 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;
} }

View file

@ -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 { public class LGMayorVoteEvent extends LGEvent implements Cancellable {
@Getter
@Setter
private boolean cancelled;
public LGMayorVoteEvent(LGGame game) { public LGMayorVoteEvent(LGGame game) {
super(game); super(game);
} }
@Getter @Setter private boolean cancelled;
} }

View file

@ -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 { public class LGNightEndEvent extends LGEvent implements Cancellable {
@Getter
@Setter
private boolean cancelled;
public LGNightEndEvent(LGGame game) { public LGNightEndEvent(LGGame game) {
super(game); super(game);
} }
@Getter @Setter private boolean cancelled;
} }

View file

@ -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;
} }

View file

@ -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;
} }

View file

@ -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;
} }

View file

@ -1,25 +1,28 @@
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"),
@ -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;
} }
} }

View file

@ -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 { public class LGPreDayStartEvent extends LGEvent implements Cancellable {
@Getter
@Setter
private boolean cancelled;
public LGPreDayStartEvent(LGGame game) { public LGPreDayStartEvent(LGGame game) {
super(game); super(game);
} }
@Getter @Setter private boolean cancelled;
} }

View file

@ -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;
} }

View file

@ -5,11 +5,12 @@ 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;
} }

View file

@ -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;

View file

@ -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;

View file

@ -6,11 +6,14 @@ 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;
} }

View file

@ -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 { public class LGVoteEvent extends LGEvent implements Cancellable {
@Getter
@Setter
private boolean cancelled;
public LGVoteEvent(LGGame game) { public LGVoteEvent(LGGame game) {
super(game); super(game);
} }
@Getter @Setter private boolean cancelled;
} }

View file

@ -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;
}
} }

View file

@ -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,41 +16,46 @@ 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,15 +64,18 @@ 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)

View file

@ -1,13 +1,12 @@
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;

View file

@ -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,12 +16,7 @@ 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;
import fr.leomelki.loupgarou.MainLg;
import fr.leomelki.loupgarou.classes.LGPlayer;
import fr.leomelki.loupgarou.events.LGPlayerKilledEvent.Reason;
public class JoinListener implements Listener { public class JoinListener implements Listener {
private final MainLg plugin; private final MainLg plugin;
@ -65,6 +63,7 @@ public class JoinListener implements Listener{
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) {
@ -75,6 +74,7 @@ public class JoinListener implements Listener{
} 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();

View file

@ -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

View file

@ -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);

View file

@ -1,59 +1,68 @@
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 { public class RAnge extends Role {
final ArrayList<LGPlayer> winners = new ArrayList<>();
boolean vote;
int night = 1;
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()) {
@ -64,7 +73,7 @@ public class RAnge extends Role{
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()) {
@ -91,8 +100,7 @@ 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())

View file

@ -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;
@ -105,6 +107,7 @@ public class RAssassin extends Role{
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())

View file

@ -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 { public class RBouffon extends Role {
final ArrayList<LGPlayer> needToPlay = new ArrayList<>();
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 nimporte 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 nimporte 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 quelquun à hanter parmi ceux qui ont voté pour ta mort."; return "Choisis quelquun à 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;
@ -67,19 +77,21 @@ public class RBouffon extends Role{
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(), () -> {
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.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);
@ -119,8 +131,6 @@ 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()) {

View file

@ -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;
@ -63,6 +71,7 @@ public class RChaperonRouge extends Role{
} }
} }
} }
@EventHandler @EventHandler
public void onTour(LGRoleTurnEndEvent e) { public void onTour(LGRoleTurnEndEvent e) {
if (e.getGame() == getGame()) { if (e.getGame() == getGame()) {
@ -82,6 +91,7 @@ public class RChaperonRouge extends Role{
} }
} }
} }
@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()) {

View file

@ -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 { public class RChasseur extends Role {
final ArrayList<LGPlayer> needToPlay = new ArrayList<>();
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;
@ -85,13 +95,12 @@ 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;

View file

@ -8,42 +8,52 @@ 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())

View file

@ -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);
} }
@ -68,10 +72,12 @@ public class RChienLoup extends Role{
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,12 +118,11 @@ 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();

View file

@ -1,15 +1,15 @@
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())
@ -42,10 +42,12 @@ public class RChienLoupLG extends Role{
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;

View file

@ -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;

View file

@ -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,59 +21,52 @@ 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;
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;
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 class RCupidon extends Role {
final WrappedDataWatcherObject invisible = new WrappedDataWatcherObject(0, WrappedDataWatcher.Registry.get(Byte.class));
final WrappedDataWatcherObject noGravity = new WrappedDataWatcherObject(5, WrappedDataWatcher.Registry.get(Boolean.class));
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.";
@ -75,6 +76,7 @@ public class RCupidon extends Role{
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;
@ -113,6 +115,7 @@ 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());
@ -130,8 +133,6 @@ 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();
@ -163,7 +164,6 @@ public class RCupidon extends Role{
meta.sendPacket(to.getPlayer()); meta.sendPacket(to.getPlayer());
new BukkitRunnable() { new BukkitRunnable() {
@Override @Override
@ -261,6 +261,7 @@ public class RCupidon extends Role{
} }
} }
} }
@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())

View file

@ -7,34 +7,42 @@ 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...";
@ -44,6 +52,7 @@ public class RDetective extends Role{
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();

View file

@ -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,37 +51,49 @@ 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.";
@ -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,12 +126,11 @@ 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();
@ -187,6 +199,7 @@ public class RDictateur extends Role{
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())
@ -237,6 +250,7 @@ public class RDictateur extends Role{
} }
}.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();

View file

@ -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 { public class REnfantSauvage extends Role {
private static final Random random = new Random();
public REnfantSauvage(LGGame game) { public REnfantSauvage(LGGame game) {
super(game); super(game);
} }
@ -43,10 +44,12 @@ public class REnfantSauvage extends Role{
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;
@ -74,7 +77,7 @@ 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();

View file

@ -1,10 +1,9 @@
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;
@ -12,6 +11,7 @@ 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())
@ -44,10 +44,12 @@ public class REnfantSauvageLG extends Role{
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;

View file

@ -1,61 +1,69 @@
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 { public class RFaucheur extends Role {
private static final Random random = new Random();
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 lun dentre 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 lun dentre 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()) {

View file

@ -1,49 +1,58 @@
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 { 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 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 daffilé 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 daffilé 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.";
@ -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,8 +102,6 @@ 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")) {
@ -101,11 +109,13 @@ public class RGarde extends Role{
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())

View file

@ -1,14 +1,16 @@
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);
} }
@ -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,8 +64,7 @@ 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;
@ -87,7 +90,6 @@ public class RGrandMechantLoup extends Role{
} }
@Override @Override
protected void onNightTurnTimeout(LGPlayer player) { protected void onNightTurnTimeout(LGPlayer player) {
player.stopChoosing(); player.stopChoosing();

View file

@ -1,29 +1,25 @@
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;
import org.bukkit.event.EventPriority;
import fr.leomelki.com.comphenix.packetwrapper.WrapperPlayServerScoreboardTeam;
import fr.leomelki.loupgarou.classes.LGCustomSkin;
import fr.leomelki.loupgarou.classes.LGGame;
import fr.leomelki.loupgarou.classes.LGPlayer;
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 class RLoupGarou extends Role {
@Getter
private final LGChat chat = new LGChat((sender, message) -> "§c" + sender.getName() + " §6» §f" + message);
boolean showSkins = false;
LGVote vote;
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,10 +69,6 @@ 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);
@ -98,6 +92,7 @@ public class RLoupGarou extends Role{
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)
@ -158,6 +153,7 @@ public class RLoupGarou extends Role{
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)
@ -181,6 +177,7 @@ public class RLoupGarou extends Role{
player.updateOwnSkin(); player.updateOwnSkin();
} }
} }
@EventHandler @EventHandler
public void onNight(LGDayEndEvent e) { public void onNight(LGDayEndEvent e) {
if (e.getGame() == getGame()) { if (e.getGame() == getGame()) {

View file

@ -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);
} }
@ -60,10 +63,12 @@ public class RLoupGarouBlanc extends Role{
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;
@ -78,7 +83,7 @@ public class RLoupGarouBlanc extends Role{
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;
@ -109,6 +114,7 @@ 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();
@ -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,7 +138,6 @@ 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);

View file

@ -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);
} }
@ -78,10 +83,12 @@ public class RLoupGarouNoir extends Role{
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,10 +104,6 @@ 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() + " ?");
@ -108,6 +111,7 @@ public class RLoupGarouNoir 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) {
toInfect = getGame().getDeaths().get(Reason.LOUP_GAROU); toInfect = getGame().getDeaths().get(Reason.LOUP_GAROU);
@ -117,6 +121,7 @@ public class RLoupGarouNoir 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) {
player.getPlayer().getInventory().setItem(8, null); player.getPlayer().getInventory().setItem(8, null);
@ -128,12 +133,11 @@ 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();
@ -166,6 +170,7 @@ public class RLoupGarouNoir extends Role{
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())

View file

@ -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;
@ -75,6 +83,7 @@ public class RMedium extends Role{
}); });
} }
@EventHandler @EventHandler
public void onRoleTurn(LGRoleTurnEndEvent e) { public void onRoleTurn(LGRoleTurnEndEvent e) {
if (e.getGame() == getGame()) if (e.getGame() == getGame())

View file

@ -1,60 +1,68 @@
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 { public class RMontreurDOurs extends Role {
private static final Random random = new Random();
private int lastNight = -1;
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) {

View file

@ -1,57 +1,65 @@
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 { 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 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()) {

View file

@ -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);
} }
@ -74,10 +77,12 @@ public class RPirate extends Role{
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,12 +119,11 @@ 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();
@ -161,6 +165,7 @@ public class RPirate extends Role{
}, 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)
@ -190,6 +195,7 @@ 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) {

View file

@ -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;
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 { 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);
} }
@ -82,10 +86,12 @@ public class RPretre extends Role{
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,6 +101,7 @@ 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())
@ -104,8 +111,6 @@ public class RPretre extends Role{
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,7 +118,7 @@ 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();
@ -131,6 +136,7 @@ public class RPretre 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) {
player.getPlayer().getInventory().setItem(8, null); player.getPlayer().getInventory().setItem(8, null);
@ -151,13 +157,11 @@ public class RPretre extends Role{
} }
} }
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();
@ -212,6 +216,7 @@ 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();
@ -267,6 +272,7 @@ public class RPretre extends Role{
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) {

View file

@ -7,38 +7,47 @@ 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;
@ -60,6 +69,7 @@ public class RPronostiqueur extends Role{
} }
}); });
} }
@Override @Override
protected void onNightTurnTimeout(LGPlayer player) { protected void onNightTurnTimeout(LGPlayer player) {
player.stopChoosing(); player.stopChoosing();

View file

@ -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);
} }
@ -92,10 +96,12 @@ public class RPyromane extends Role{
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,8 +112,6 @@ 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 ?");
@ -121,6 +125,7 @@ public class RPyromane 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) {
first = null; first = null;
@ -128,6 +133,7 @@ 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) {
@ -149,13 +155,11 @@ 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();
@ -245,6 +249,7 @@ 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();
@ -259,6 +264,7 @@ 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())
@ -269,6 +275,7 @@ public class RPyromane extends Role{
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) {
@ -294,6 +301,7 @@ public class RPyromane extends Role{
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) {

View file

@ -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,50 +46,59 @@ 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();
@ -100,6 +109,7 @@ public class RSorciere extends Role{
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,6 +120,7 @@ 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é");
@ -129,12 +140,12 @@ public class RSorciere extends Role{
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();
@ -186,6 +197,7 @@ 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) {
@ -212,6 +224,7 @@ public class RSorciere extends Role{
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);

View file

@ -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,58 +22,62 @@ 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;
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;
public class RSurvivant extends Role { public class RSurvivant extends Role {
boolean inMenu;
Runnable callback;
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 ?");
@ -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,6 +132,7 @@ 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();
@ -152,11 +165,13 @@ public class RSurvivant extends Role{
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())
@ -182,9 +197,6 @@ 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) {

View file

@ -1,30 +1,26 @@
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;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import fr.leomelki.loupgarou.classes.LGCustomItems;
import fr.leomelki.loupgarou.classes.LGGame;
import fr.leomelki.loupgarou.classes.LGPlayer;
import fr.leomelki.loupgarou.classes.LGVote;
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 class RVampire extends Role {
@Getter
private final LGChat chat = new LGChat((sender, message) -> "§5" + sender.getName() + " §6» §f" + message);
int nextCanInfect = 0;
LGVote vote;
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,14 +69,12 @@ 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);
@ -101,6 +97,7 @@ public class RVampire extends Role{
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)
@ -167,6 +164,7 @@ public class RVampire extends Role{
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())

View file

@ -6,38 +6,47 @@ 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;

View file

@ -7,22 +7,27 @@ 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;
@ -60,6 +68,7 @@ public class RVoyante extends Role{
} }
}); });
} }
@Override @Override
protected void onNightTurnTimeout(LGPlayer player) { protected void onNightTurnTimeout(LGPlayer player) {
player.stopChoosing(); player.stopChoosing();

View file

@ -1,24 +1,27 @@
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;
import java.util.ArrayList;
import java.util.concurrent.ThreadLocalRandom;
public abstract class Role implements Listener { public abstract class Role implements Listener {
@Getter @Setter private int waitedPlayers; @Getter
@Getter private final ArrayList<LGPlayer> players = new ArrayList<>(); private final ArrayList<LGPlayer> players = new ArrayList<>();
@Getter private final LGGame game; @Getter
private final LGGame game;
@Getter
@Setter
private int waitedPlayers;
public Role(LGGame game) { public Role(LGGame game) {
this.game = game; this.game = game;
@ -31,19 +34,33 @@ public abstract class Role implements Listener{
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
*/ */
@ -75,7 +92,8 @@ public abstract class Role implements Listener{
// 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() {
@ -88,6 +106,7 @@ public abstract class Role implements Listener{
} }
}.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);
@ -100,18 +119,26 @@ public abstract class Role implements Listener{
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));

View file

@ -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);

View file

@ -1,23 +1,23 @@
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) {
@ -61,8 +61,7 @@ public class CustomScoreboardEntry {
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
@ -87,10 +86,12 @@ public class CustomScoreboardEntry {
} }
} }
} }
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();

View file

@ -1,19 +1,21 @@
package fr.leomelki.loupgarou.utils; package fr.leomelki.loupgarou.utils;
import lombok.AllArgsConstructor;
import lombok.Getter;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map.Entry; import java.util.Map.Entry;
import lombok.AllArgsConstructor;
import lombok.Getter;
public class MultipleValueMap<K, V> { public class MultipleValueMap<K, V> {
private final HashMap<K, List<V>> map = new HashMap<>(); private final HashMap<K, List<V>> map = new HashMap<>();
public void put(K key, V value) { public void put(K key, V value) {
List<V> list = map.computeIfAbsent(key, k -> new ArrayList<>()); List<V> list = map.computeIfAbsent(key, k -> new ArrayList<>());
list.add(value); list.add(value);
} }
public V remove(K key, V value) { public V remove(K key, V value) {
List<V> list = map.get(key); List<V> list = map.get(key);
if (list != null) { if (list != null) {
@ -25,9 +27,11 @@ public class MultipleValueMap<K, V> {
} }
return null; return null;
} }
public boolean containsKey(K key) { public boolean containsKey(K key) {
return map.containsKey(key); return map.containsKey(key);
} }
public boolean containsValue(V value) { public boolean containsValue(V value) {
if (value != null) if (value != null)
for (List<V> list : map.values()) for (List<V> list : map.values())
@ -36,9 +40,11 @@ public class MultipleValueMap<K, V> {
return true; return true;
return false; return false;
} }
public V get(K key) { public V get(K key) {
return map.containsKey(key) ? map.get(key).get(0) : null; return map.containsKey(key) ? map.get(key).get(0) : null;
} }
public List<Entry<K, V>> entrySet() { public List<Entry<K, V>> entrySet() {
ArrayList<Entry<K, V>> toReturn = new ArrayList<>(); ArrayList<Entry<K, V>> toReturn = new ArrayList<>();
for (Entry<K, List<V>> entry : map.entrySet()) for (Entry<K, List<V>> entry : map.entrySet())
@ -47,15 +53,18 @@ public class MultipleValueMap<K, V> {
return toReturn; return toReturn;
} }
public void clear() { public void clear() {
map.clear(); map.clear();
} }
@AllArgsConstructor @AllArgsConstructor
public static class MultipleValueKeyEntry<K, V> implements Entry<K, V> { public static class MultipleValueKeyEntry<K, V> implements Entry<K, V> {
@Getter @Getter
private final K key; private final K key;
@Getter @Getter
private V value; private V value;
@Override @Override
public V setValue(V value) { public V setValue(V value) {
return this.value = value; return this.value = value;

Some files were not shown because too many files have changed in this diff Show more