_TheRoy_
Активный участник
- Баллы
- 61
- Имя в Minecraft
- _TheRoy_
Доброго времени суток, я являюсь автором канала TheRoy развитие каналу предало создание и организация мини-игр среди них "Осада замка" серия видеороликов занявших первые места в поиске по запросам "Осада" "Осада замка" и подобные.
В настоящее время для облегчения организации игр я занялся написанием плагина который обеспечит некую "автоматизацию" процессу игры, позволит не использовать командные блоки
Настоятельно попрошу хейтеров-"Java-рождённых" покинуть данную тему, меня не беспокоит кривизна кода, его цвет и запах, нужно только что-бы "Это" работало также прошу учесть что пишу что то похожее на плагины первый раз
Спасибо!
Теперь к делу, при написании кода столкнулся с проблемой, я пытался от имени плагина подавать в консоль команды, сохраняя предварительно параметры в файл для возможности "перегрузить" всё в случае неудачной записи
Запись\считывание работает, беда в телепортации игроков на стартовые поинты команд, работает очень криво, желательно сделать телепортацию как в мини-игре BedWars (телепортирует даже если блоки застроены без надписи "Кровать уничтожена или недоступна") Будет очень круто если Вы сможете скинуть мне метод получающий player и locations, просьба к форумчанам помочь и аргументировано указать на другие существенные ошибки в коде (думаю их там много) но повторюсь, мне нужно что-бы "Это" просто как то более-менее стабильно работало
Файл plugin.yml
Файл Command.java
Файл GameMode.java
Игра начинается командой /start запускается метод start в Gamemode
Предварительно командами
В настоящее время для облегчения организации игр я занялся написанием плагина который обеспечит некую "автоматизацию" процессу игры, позволит не использовать командные блоки
Настоятельно попрошу хейтеров-"Java-рождённых" покинуть данную тему, меня не беспокоит кривизна кода, его цвет и запах, нужно только что-бы "Это" работало также прошу учесть что пишу что то похожее на плагины первый раз
Спасибо!
Теперь к делу, при написании кода столкнулся с проблемой, я пытался от имени плагина подавать в консоль команды, сохраняя предварительно параметры в файл для возможности "перегрузить" всё в случае неудачной записи
Внутри "yml" файла
red:
cords:
x: -267.0
y: 70.0
z: 175.0
players:
- test1
- _TheRoy_
blue:
cords:
x: -260.0
y: 71.0
z: 165.0
players:
- test2
- test3
game:
pointR:
x: -267.0
y: 71.0
z: 173.0
pointB:
x: -265.0
y: 71.0
z: 165.0
fillpoint1: {}
fillpoint2: {}
lobbypoint: {}
red:
cords:
x: -267.0
y: 70.0
z: 175.0
players:
- test1
- _TheRoy_
blue:
cords:
x: -260.0
y: 71.0
z: 165.0
players:
- test2
- test3
game:
pointR:
x: -267.0
y: 71.0
z: 173.0
pointB:
x: -265.0
y: 71.0
z: 165.0
fillpoint1: {}
fillpoint2: {}
lobbypoint: {}
Запись\считывание работает, беда в телепортации игроков на стартовые поинты команд, работает очень криво, желательно сделать телепортацию как в мини-игре BedWars (телепортирует даже если блоки застроены без надписи "Кровать уничтожена или недоступна") Будет очень круто если Вы сможете скинуть мне метод получающий player и locations, просьба к форумчанам помочь и аргументировано указать на другие существенные ошибки в коде (думаю их там много) но повторюсь, мне нужно что-бы "Это" просто как то более-менее стабильно работало
Файл plugin.yml
name: TRSiegeSystem
version: 1.0
main: TheRoy.main.TRSiegeSystem
author: TheRoy
description: Test
commands:
setBase:
usage: /setBase <team>
description: Set base crystal
addToTeam:
usage: /addToTeam <team> <player>
description: Add player to team
setup:
usage: /setup
description: Setup game
removePlayer:
usage: /removePlayer <player>
description: Remove player from team
teamSpawnPoint:
usage: /teamSpawnPoint <team>
description: Set team spawn point
start:
usage: /start
description: Start game!!!
startWar:
usage: /startWar
description: Start WAR!!!
setLobby:
usage: /setLobby
description: Set lobby
setFill:
usage: /setFill <N point>
description: Set fill point
version: 1.0
main: TheRoy.main.TRSiegeSystem
author: TheRoy
description: Test
commands:
setBase:
usage: /setBase <team>
description: Set base crystal
addToTeam:
usage: /addToTeam <team> <player>
description: Add player to team
setup:
usage: /setup
description: Setup game
removePlayer:
usage: /removePlayer <player>
description: Remove player from team
teamSpawnPoint:
usage: /teamSpawnPoint <team>
description: Set team spawn point
start:
usage: /start
description: Start game!!!
startWar:
usage: /startWar
description: Start WAR!!!
setLobby:
usage: /setLobby
description: Set lobby
setFill:
usage: /setFill <N point>
description: Set fill point
Файл Command.java
Лишнее удалил
//START
if(laber.equals("start")) {
GameMode.start(plugin);
}
//STARTWAR
if(laber.equals("startwar")||laber.equals("startWar")) {
GameMode.startWar(plugin);
}
return true;
}
}
//START
if(laber.equals("start")) {
GameMode.start(plugin);
}
//STARTWAR
if(laber.equals("startwar")||laber.equals("startWar")) {
GameMode.startWar(plugin);
}
return true;
}
}
Файл GameMode.java
package TheRoy.main;
import java.io.File;
import java.util.List;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
public class GameMode {
public static void start(TRSiegeSystem plugin)
{
File fteam = new File(plugin.getDataFolder()+File.separator+"team.yml");
FileConfiguration file =YamlConfiguration.loadConfiguration(fteam);
double x1 = file.getDouble("game.pointR.x");
double y1 = file.getDouble("game.pointR.y");
double z1 = file.getDouble("game.pointR.z");
double x2 = file.getDouble("game.pointB.x");
double y2 = file.getDouble("game.pointB.y");
double z2 = file.getDouble("game.pointB.z");
String command = "gamemode 0 @a";
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), command);
command = "title @a title {\"text\":\"\\u0418\\u0433\\u0440\\u0430 \\u043d\\u0430\\u0447\\u0430\\u0442\\u0430\",\"color\":\"yellow\"}";
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), command);
tpTeam("red", plugin, x1, y1, z1, x2, y2, z2);
tpTeam("blue", plugin, x1, y1, z1, x2, y2, z2);
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "spawnpoint @a");
}
public static void startWar(TRSiegeSystem plugin)
{
File fteam = new File(plugin.getDataFolder()+File.separator+"team.yml");
FileConfiguration file =YamlConfiguration.loadConfiguration(fteam);
String command = "fill " + file.getDouble("game.fillpoint1.x") + " " + file.getDouble("game.fillpoint1.y") + " " + file.getDouble("game.fillpoint1.z") + " " + file.getDouble("game.fillpoint2.x") + " " + file.getDouble("game.fillpoint2.y") + " " + file.getDouble("game.fillpoint2.z") + " minecraft:air";
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), command);
command = "title @a title {\"text\":\"\\u0411\\u043e\\u0439 \\u043d\\u0430\\u0447\\u0430\\u0442!\",\"color\":\"yellow\"}";
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), command);
}
private static void tpTeam(String team, TRSiegeSystem plugin, double x1, double y1, double z1, double x2, double y2, double z2)
{
File fteam = new File(plugin.getDataFolder()+File.separator+"team.yml");
FileConfiguration file =YamlConfiguration.loadConfiguration(fteam);
if(team.equals("red"))
{
List<String> list = file.getStringList("red.players");
//World world = Bukkit.getWorld("World");
for(int i=0;i<=list.size(); ++i)
{
//Location location = new Location(world, x1, y1+1, z1);
Player player = Bukkit.getPlayer(list.get(i));
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "tp " + player.getName() + " " + x1 + " " + y1+1 + " " + z1);
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "spawnpoint " + player.getName() + " " + x1 + " " + y1+1 + " " + z1);
}
}
else if(team.equals("blue"))
{
List<String> list = file.getStringList("blue.players");
//World world = Bukkit.getWorld("World");
for(int i=0;i<=list.size(); ++i)
{
//Location location = new Location(world, x2, y2+1, z2);
Player player = Bukkit.getPlayer(list.get(i));
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "tp " + player.getName() + " " + x2 + " " + y2+1 + " " + z2);
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "spawnpoint " + player.getName() + " " + x2 + " " + y2+1 + " " + z2);
}
}
}
}
import java.io.File;
import java.util.List;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
public class GameMode {
public static void start(TRSiegeSystem plugin)
{
File fteam = new File(plugin.getDataFolder()+File.separator+"team.yml");
FileConfiguration file =YamlConfiguration.loadConfiguration(fteam);
double x1 = file.getDouble("game.pointR.x");
double y1 = file.getDouble("game.pointR.y");
double z1 = file.getDouble("game.pointR.z");
double x2 = file.getDouble("game.pointB.x");
double y2 = file.getDouble("game.pointB.y");
double z2 = file.getDouble("game.pointB.z");
String command = "gamemode 0 @a";
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), command);
command = "title @a title {\"text\":\"\\u0418\\u0433\\u0440\\u0430 \\u043d\\u0430\\u0447\\u0430\\u0442\\u0430\",\"color\":\"yellow\"}";
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), command);
tpTeam("red", plugin, x1, y1, z1, x2, y2, z2);
tpTeam("blue", plugin, x1, y1, z1, x2, y2, z2);
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "spawnpoint @a");
}
public static void startWar(TRSiegeSystem plugin)
{
File fteam = new File(plugin.getDataFolder()+File.separator+"team.yml");
FileConfiguration file =YamlConfiguration.loadConfiguration(fteam);
String command = "fill " + file.getDouble("game.fillpoint1.x") + " " + file.getDouble("game.fillpoint1.y") + " " + file.getDouble("game.fillpoint1.z") + " " + file.getDouble("game.fillpoint2.x") + " " + file.getDouble("game.fillpoint2.y") + " " + file.getDouble("game.fillpoint2.z") + " minecraft:air";
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), command);
command = "title @a title {\"text\":\"\\u0411\\u043e\\u0439 \\u043d\\u0430\\u0447\\u0430\\u0442!\",\"color\":\"yellow\"}";
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), command);
}
private static void tpTeam(String team, TRSiegeSystem plugin, double x1, double y1, double z1, double x2, double y2, double z2)
{
File fteam = new File(plugin.getDataFolder()+File.separator+"team.yml");
FileConfiguration file =YamlConfiguration.loadConfiguration(fteam);
if(team.equals("red"))
{
List<String> list = file.getStringList("red.players");
//World world = Bukkit.getWorld("World");
for(int i=0;i<=list.size(); ++i)
{
//Location location = new Location(world, x1, y1+1, z1);
Player player = Bukkit.getPlayer(list.get(i));
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "tp " + player.getName() + " " + x1 + " " + y1+1 + " " + z1);
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "spawnpoint " + player.getName() + " " + x1 + " " + y1+1 + " " + z1);
}
}
else if(team.equals("blue"))
{
List<String> list = file.getStringList("blue.players");
//World world = Bukkit.getWorld("World");
for(int i=0;i<=list.size(); ++i)
{
//Location location = new Location(world, x2, y2+1, z2);
Player player = Bukkit.getPlayer(list.get(i));
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "tp " + player.getName() + " " + x2 + " " + y2+1 + " " + z2);
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "spawnpoint " + player.getName() + " " + x2 + " " + y2+1 + " " + z2);
}
}
}
}
Игра начинается командой /start запускается метод start в Gamemode
Предварительно командами
Последнее редактирование: