Avancement du Plugin

This commit is contained in:
BunSLaPatate
2018-09-14 15:43:17 +02:00
parent 65eab9e648
commit 1d483846c9
17 changed files with 273 additions and 96 deletions

View File

@@ -69,8 +69,13 @@
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.13.1-R0.1-SNAPSHOT</version>
<version>1.12.2-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId>
<version>1.12.2-R0.1-SNAPSHOT</version>
</dependency>
</dependencies>
</project>

View File

@@ -1,5 +1,7 @@
package net.berrygames.witchrush;
import net.berrygames.witchrush.game.GameState;
import net.berrygames.witchrush.tools.Locations;
import org.bukkit.Color;
import org.bukkit.Material;
import org.bukkit.entity.Player;
@@ -20,13 +22,19 @@ public class WitchPlayer {
public WitchPlayer(Player player) {
this.player = player;
this.spectator = false;
this.spectator =
(WitchRush.get().getState().equals(GameState.WAITING) ||
WitchRush.get().getState().equals(GameState.WAITING)) ? false : true;
this.kills = 0;
this.death = 0;
}
public void teleportPlayer(){
if(spectator){
player.teleport(Locations.SPAWN_SPECTATORS.getLocation());
} else {
player.teleport(Locations.PLAYER_SPAWN_WAITING_ROOM.getLocation());
}
}
public void giveStuff(){

View File

@@ -57,6 +57,6 @@ public class WitchRush extends JavaPlugin {
}
public static String prefix(){
return "§5§lWitchRush §8§l| §d";
return "§5§lWitchRush §8§l\u258f §d";
}
}

View File

@@ -1,7 +1,8 @@
package net.berrygames.witchrush.commands.admins;
import net.berrygames.witchrush.game.SpawnPNJ;
import net.berrygames.witchrush.tools.SpawnPNJ;
import net.berrygames.witchrush.tools.Locations;
import net.berrygames.witchrush.tools.SpawnWitch;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
@@ -26,6 +27,13 @@ public class TestCMD implements CommandExecutor {
new SpawnPNJ("U jaune", Locations.UPGRADE_JAUNE.getLocation()).spawn();
}
if(args[0].equals("w")){
new SpawnWitch("W Rouge", Locations.WITCH_ROUGE.getLocation()).spawn();
new SpawnWitch("W Bleu", Locations.WITCH_BLEU.getLocation()).spawn();
new SpawnWitch("W Vert", Locations.WITCH_VERT.getLocation()).spawn();
new SpawnWitch("W Jaune", Locations.WITCH_JAUNE.getLocation()).spawn();
}
return false;
}
}

View File

@@ -2,16 +2,33 @@ package net.berrygames.witchrush.game;
import net.berrygames.witchrush.WitchRush;
import net.berrygames.witchrush.tools.Locations;
import net.berrygames.witchrush.tools.SpawnWitch;
import org.bukkit.Bukkit;
import org.bukkit.entity.Witch;
import org.bukkit.scheduler.BukkitRunnable;
public class NoPVPTask extends BukkitRunnable {
private int timer = 60 * 3;
private int timer = 30;
@Override
public void run() {
WitchRush.get().setState(GameState.NOPVP);
if(timer == 0){
new PVPTask().runTaskTimer(WitchRush.get(), 0, 20);
Bukkit.broadcastMessage(WitchRush.prefix()+" Les §6Witchs §dsont apparues, §d§nBonne chance à vous !");
new SpawnWitch("W", Locations.WITCH_ROUGE.getLocation()).spawn();
new SpawnWitch("W", Locations.WITCH_BLEU.getLocation()).spawn();
new SpawnWitch("W", Locations.WITCH_VERT.getLocation()).spawn();
new SpawnWitch("W", Locations.WITCH_JAUNE.getLocation()).spawn();
cancel();
}
timer--;
}

View File

@@ -0,0 +1,15 @@
package net.berrygames.witchrush.game;
import org.bukkit.scheduler.BukkitRunnable;
public class PVPTask extends BukkitRunnable {
int timer = 20 * 60;
@Override
public void run() {
timer--;
}
}

View File

@@ -1,28 +0,0 @@
package net.berrygames.witchrush.game;
import org.bukkit.Location;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
public class SpawnPNJ {
private EntityType entity;
private String name;
private Location location;
public SpawnPNJ(String name, Location location) {
this.entity = EntityType.VILLAGER;
this.name = name;
this.location = location;
}
public void spawn(){
Entity witch = location.getWorld().spawnEntity(location, entity);
witch.setCustomName(name);
witch.setCustomNameVisible(true);
witch.setSilent(true);
witch.setInvulnerable(true);
}
}

View File

@@ -1,29 +0,0 @@
package net.berrygames.witchrush.game;
import org.bukkit.Location;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
public class SpawnWitch {
private EntityType entity;
private String name;
private Location location;
public SpawnWitch(String name, Location location) {
this.entity = EntityType.WITCH;
this.name = name;
this.location = location;
}
public void spawn(){
Entity witch = location.getWorld().spawnEntity(location, entity);
witch.setCustomName(name);
witch.setCustomNameVisible(true);
witch.setSilent(true);
witch.setInvulnerable(true);
net.m
}
}

View File

@@ -1,37 +1,38 @@
package net.berrygames.witchrush.game;
import net.berrygames.witchrush.WitchPlayer;
import net.berrygames.witchrush.WitchRush;
import net.berrygames.witchrush.tools.Locations;
import net.berrygames.witchrush.tools.SpawnPNJ;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable;
public class StartTask extends BukkitRunnable {
private int timer = 120;
private int timer = 30;
@Override
public void run() {
if(timer == 0){
new NoPVPTask().runTaskTimer(WitchRush.get(), 0, 20);
Bukkit.broadcastMessage(WitchRush.prefix()+"§CLa partie commence ! Vous avez 3minutes pour vous preparer !");
Bukkit.broadcastMessage(WitchRush.prefix()+"§dLa partie commence !");
Bukkit.broadcastMessage(WitchRush.prefix()+"§Vous avez §63minutes §dpour vous préparez.");
cancel();
//TP Player
//Spawn SHOP
new SpawnPNJ("S bleu", Locations.SHOP_BLEU.getLocation()).spawn();
new SpawnPNJ("S rouge", Locations.SHOP_ROUGE.getLocation()).spawn();
new SpawnPNJ("S vert", Locations.SHOP_VERT.getLocation()).spawn();
new SpawnPNJ("S jaune", Locations.SHOP_JAUNE.getLocation()).spawn();
new SpawnPNJ("S", Locations.SHOP_BLEU.getLocation()).spawn();
new SpawnPNJ("S", Locations.SHOP_ROUGE.getLocation()).spawn();
new SpawnPNJ("S", Locations.SHOP_VERT.getLocation()).spawn();
new SpawnPNJ("S", Locations.SHOP_JAUNE.getLocation()).spawn();
//Spawn UPGRADE
new SpawnPNJ("U bleu", Locations.UPGRADE_BLEU.getLocation()).spawn();
new SpawnPNJ("U rouge", Locations.UPGRADE_ROUGE.getLocation()).spawn();
new SpawnPNJ("U vert", Locations.UPGRADE_VERT.getLocation()).spawn();
new SpawnPNJ("U jaune", Locations.UPGRADE_JAUNE.getLocation()).spawn();
new SpawnPNJ("U", Locations.UPGRADE_BLEU.getLocation()).spawn();
new SpawnPNJ("U", Locations.UPGRADE_ROUGE.getLocation()).spawn();
new SpawnPNJ("U", Locations.UPGRADE_VERT.getLocation()).spawn();
new SpawnPNJ("U", Locations.UPGRADE_JAUNE.getLocation()).spawn();
}

View File

@@ -1,8 +1,10 @@
package net.berrygames.witchrush.listeners;
import net.berrygames.witchrush.WitchRush;
import net.berrygames.witchrush.listeners.players.InteractEvent;
import net.berrygames.witchrush.listeners.players.PlayerJoin;
import net.berrygames.witchrush.listeners.players.PlayerQuit;
import net.berrygames.witchrush.listeners.world.WorldEvents;
import org.bukkit.Bukkit;
import org.bukkit.plugin.PluginManager;
@@ -14,8 +16,10 @@ public class ListenersManager {
// --- PLAYERS ---//
pm.registerEvents(new PlayerJoin(), main);
pm.registerEvents(new PlayerQuit(), main);
pm.registerEvents(new InteractEvent(), main);
// --- WORLD ---//
pm.registerEvents(new WorldEvents(), main);
System.out.println("Events register");
}

View File

@@ -0,0 +1,50 @@
package net.berrygames.witchrush.listeners.players;
import net.berrygames.witchrush.WitchRush;
import net.berrygames.witchrush.game.GameState;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityDamageByBlockEvent;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.player.PlayerInteractAtEntityEvent;
public class InteractEvent implements Listener {
@EventHandler
public void pvp(EntityDamageEvent e){
if(WitchRush.get().getState().equals(GameState.WAITING) || WitchRush.get().getState().equals(GameState.STARTING)){
e.setCancelled(true);
}
}
@EventHandler
public void pvp(EntityDamageByBlockEvent e){
if(WitchRush.get().getState().equals(GameState.WAITING) || WitchRush.get().getState().equals(GameState.STARTING)){
e.setCancelled(true);
}
}
@EventHandler
public void pvp(EntityDamageByEntityEvent e){
if(WitchRush.get().getState().equals(GameState.WAITING) || WitchRush.get().getState().equals(GameState.STARTING)){
e.setCancelled(true);
}
}
@EventHandler
public void click(PlayerInteractAtEntityEvent e){
Player player = e.getPlayer();
if(WitchRush.get().getState().equals(GameState.WAITING) || WitchRush.get().getState().equals(GameState.STARTING)){
e.setCancelled(true);
}
if(e.getRightClicked().getName().equals("S")){
player.sendMessage("s");
}
if(e.getRightClicked().getName().equals("U")){
player.sendMessage("u");
}
}
}

View File

@@ -20,10 +20,13 @@ public class PlayerJoin implements Listener {
if(WitchRush.get().getState().equals(GameState.WAITING) || WitchRush.get().getState().equals(GameState.STARTING)){
e.setJoinMessage(
WitchRush.prefix()+player.getName()+
" a rejoint la partie §7(§d"+
WitchRush.prefix()+"§e"+player.getName()+
" §da rejoint la partie §7(§d"+
WitchPlayer.getwitchMap().size()+
"§8/§d16§7)");
player.sendTitle("§5WitchRush", "§DLe rush avec des Witchs");
player.setGameMode(GameMode.ADVENTURE);
player.setLevel(0);
player.setHealth(20);
@@ -35,6 +38,21 @@ public class PlayerJoin implements Listener {
new StartTask().runTaskTimer(WitchRush.get(), 0, 20);
WitchRush.get().setState(GameState.STARTING);
}
} else {
player.sendMessage(" ");
player.sendMessage("§8(Spectateur) §7Vous êtes spectateur pour cette partie.");
player.sendMessage("§7Seul les autres spectateurs voient vos messages !");
player.sendMessage(" ");
e.setJoinMessage(null);
player.setGameMode(GameMode.SPECTATOR);
player.setLevel(0);
player.setHealth(20);
player.setFoodLevel(20);
witchPlayer.teleportPlayer();
witchPlayer.sendGameScoreboard();
}
}
}

View File

@@ -2,6 +2,7 @@ package net.berrygames.witchrush.listeners.players;
import net.berrygames.witchrush.WitchPlayer;
import net.berrygames.witchrush.WitchRush;
import net.berrygames.witchrush.game.GameState;
import net.berrygames.witchrush.game.StartTask;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
@@ -16,11 +17,26 @@ public class PlayerQuit implements Listener {
Player player = e.getPlayer();
WitchPlayer witchPlayer = WitchPlayer.get(player);
e.setQuitMessage(null);
witchPlayer.removePlayer();
if(WitchPlayer.getwitchMap().size() < 4){
if(WitchRush.get().getState().equals(GameState.WAITING) || WitchRush.get().getState().equals(GameState.STARTING)){
e.setQuitMessage(
WitchRush.prefix()+"§e"+player.getName()+
" §da rejoint la partie §7(§d"+
WitchPlayer.getwitchMap().size()+
"§8/§d16§7)");
} else {
e.setQuitMessage(null);
}
if(WitchPlayer.getwitchMap().size() < 4 && WitchRush.get().getState().equals(GameState.STARTING)){
Bukkit.broadcastMessage(WitchRush.prefix()+"§CLe lancement de la partie est annulé. Il n'y a pas assez de joueurs !");
new StartTask().cancel();
if(!new StartTask().isCancelled()){
new StartTask().cancel();
}
}
}

View File

@@ -0,0 +1,31 @@
package net.berrygames.witchrush.listeners.world;
import net.berrygames.witchrush.WitchRush;
import net.berrygames.witchrush.game.GameState;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockDamageEvent;
import org.bukkit.event.block.BlockPlaceEvent;
public class WorldEvents implements Listener {
@EventHandler
public void place(BlockPlaceEvent e){
if(WitchRush.get().getState().equals(GameState.WAITING) || WitchRush.get().getState().equals(GameState.STARTING)){
e.setCancelled(true);
}
}
@EventHandler
public void breake(BlockBreakEvent e){
if(WitchRush.get().getState().equals(GameState.WAITING) || WitchRush.get().getState().equals(GameState.STARTING)){
e.setCancelled(true);
}
}
@EventHandler
public void damage(BlockDamageEvent e){
if(WitchRush.get().getState().equals(GameState.WAITING) || WitchRush.get().getState().equals(GameState.STARTING)){
e.setCancelled(true);
}
}
}

View File

@@ -6,31 +6,31 @@ import org.bukkit.Location;
public enum Locations {
//PLAYERS
PLAYER_SPAWN_WAITING_ROOM(new Location(Bukkit.getWorld("world"), 0, 0, 0)),
PLAYER_SPAWN_BLEU(new Location(Bukkit.getWorld("world"), 0, 0, 0)),
PLAYER_SPAWN_ROUGE(new Location(Bukkit.getWorld("world"), 0, 0, 0)),
PLAYER_SPAWN_JAUNE(new Location(Bukkit.getWorld("world"), 0, 0, 0)),
PLAYER_SPAWN_VERT(new Location(Bukkit.getWorld("world"), 0, 0, 0)),
PLAYER_SPAWN_WAITING_ROOM(new Location(Bukkit.getWorld("world"), 0.5, 65, 0.5, 0, 0)),
PLAYER_SPAWN_BLEU(new Location(Bukkit.getWorld("world"), 5.5, 65, -4.5, 50, 0)),
PLAYER_SPAWN_ROUGE(new Location(Bukkit.getWorld("world"), -4.5, 65, 5.5, -120, 0)),
PLAYER_SPAWN_JAUNE(new Location(Bukkit.getWorld("world"), 5.5, 65, 5.5, 120, 0)),
PLAYER_SPAWN_VERT(new Location(Bukkit.getWorld("world"), -4.5, 65, -4.5, -50, 0)),
SPAWN_SPECTATORS(new Location(Bukkit.getWorld("world"), 0, 0, 0)),
SPAWN_SPECTATORS(new Location(Bukkit.getWorld("world"), 0.5, 70, 0.5, 0, 0)),
//WITCH
WITCH_BLEU(new Location(Bukkit.getWorld("world"), 0, 0, 0)),
WITCH_ROUGE(new Location(Bukkit.getWorld("world"), 0, 0, 0)),
WITCH_JAUNE(new Location(Bukkit.getWorld("world"), 0, 0, 0)),
WITCH_ERT(new Location(Bukkit.getWorld("world"), 0, 0, 0)),
WITCH_BLEU(new Location(Bukkit.getWorld("world"), 9.5, 65, -8.5, 50, 0)),
WITCH_ROUGE(new Location(Bukkit.getWorld("world"), -8.5, 65, 9.5, -120, 0)),
WITCH_JAUNE(new Location(Bukkit.getWorld("world"), 9.5, 65, 9.5, 120, 0)),
WITCH_VERT(new Location(Bukkit.getWorld("world"), -8.5, 65, -8.5, -50, 0)),
//PNJ SHOP
SHOP_BLEU(new Location(Bukkit.getWorld("world"), 1, 100, 0)),
SHOP_ROUGE(new Location(Bukkit.getWorld("world"), 3, 100, 0)),
SHOP_JAUNE(new Location(Bukkit.getWorld("world"), 5, 100, 0)),
SHOP_VERT(new Location(Bukkit.getWorld("world"), 7, 100, 0)),
SHOP_BLEU(new Location(Bukkit.getWorld("world"), 9.5, 65, -5.5, 90, 0)),
SHOP_ROUGE(new Location(Bukkit.getWorld("world"), -8.5, 65, 6.5, -90, 0)),
SHOP_JAUNE(new Location(Bukkit.getWorld("world"), 6.5, 65, 9.5, 190, 0)),
SHOP_VERT(new Location(Bukkit.getWorld("world"), -5.5, 65, -8.5, 0, 0)),
//PNJ SOLO UPGRADE
UPGRADE_BLEU(new Location(Bukkit.getWorld("world"), 2, 100, 0)),
UPGRADE_ROUGE(new Location(Bukkit.getWorld("world"), 4, 100, 0)),
UPGRADE_JAUNE(new Location(Bukkit.getWorld("world"), 6, 100, 0)),
UPGRADE_VERT(new Location(Bukkit.getWorld("world"), 8, 100, 0)),
UPGRADE_BLEU(new Location(Bukkit.getWorld("world"), 6, 65, -8.5, 0, 0)),
UPGRADE_ROUGE(new Location(Bukkit.getWorld("world"), -5.5, 65, 9.5, -180, 0)),
UPGRADE_JAUNE(new Location(Bukkit.getWorld("world"), 9.5, 65, 6.5, 90, 0)),
UPGRADE_VERT(new Location(Bukkit.getWorld("world"), -8.5, 65, -5.5, -90, 0)),
;

View File

@@ -0,0 +1,31 @@
package net.berrygames.witchrush.tools;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.entity.Villager;
public class SpawnPNJ {
private Villager villager;
private String name;
private Location location;
public SpawnPNJ(String name, Location location) {
this.name = name;
this.location = location;
}
public void spawn(){
this.villager = Bukkit.getWorld("world").spawn(location, Villager.class, v ->{
v.setAI(false);
v.setCustomName(name);
v.setCustomNameVisible(true);
v.setSilent(true);
v.setGravity(false);
v.setInvulnerable(true);
});
}
}

View File

@@ -0,0 +1,30 @@
package net.berrygames.witchrush.tools;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.entity.Witch;
public class SpawnWitch {
private Witch witch;
private String name;
private Location location;
public SpawnWitch(String name, Location location) {
this.name = name;
this.location = location;
}
public void spawn(){
this.witch = Bukkit.getWorld("world").spawn(location, Witch.class, w ->{
w.setAI(false);
w.setCustomName(name);
w.setCustomNameVisible(true);
w.setSilent(true);
w.setGravity(false);
w.setInvulnerable(true);
});
}
}