use of com.solinia.solinia.Models.SoliniaZone in project solinia3-core by mixxit.
the class SoliniaZoneFactory method Create.
public static SoliniaZone Create(String zonename, int x, int y, int z, boolean operatorCreated) throws CoreStateInitException, SoliniaZoneCreationException {
if (StateManager.getInstance().getConfigurationManager().getZone(zonename.toUpperCase()) != null)
throw new SoliniaZoneCreationException("Zone already exists");
SoliniaZone zone = new SoliniaZone();
zone.setId(StateManager.getInstance().getConfigurationManager().getNextZoneId());
zone.setName(zonename.toUpperCase());
zone.setX(x);
zone.setY(y);
zone.setZ(z);
zone.setOperatorCreated(operatorCreated);
StateManager.getInstance().getConfigurationManager().addZone(zone);
return zone;
}
use of com.solinia.solinia.Models.SoliniaZone in project solinia3-core by mixxit.
the class CommandEditZone method onCommand.
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (!(sender instanceof Player) && !(sender instanceof CommandSender))
return false;
if (sender instanceof Player) {
Player player = (Player) sender;
if (!player.isOp() && !player.hasPermission("solinia.editzone")) {
player.sendMessage("You do not have permission to access this command");
return false;
}
}
if (args.length < 1) {
sender.sendMessage("Insufficient arguments: zoneid");
return false;
}
if (args.length == 0) {
return false;
}
int zoneid = Integer.parseInt(args[0]);
if (args.length == 1) {
try {
SoliniaZone zone = StateManager.getInstance().getConfigurationManager().getZone(zoneid);
if (zone != null) {
zone.sendZoneSettingsToSender(sender);
} else {
sender.sendMessage("Zone ID doesnt exist");
}
return true;
} catch (CoreStateInitException e) {
sender.sendMessage(e.getMessage());
}
}
if (args.length < 3) {
sender.sendMessage("Insufficient arguments: zoneid setting value");
return false;
}
String setting = args[1];
String value = args[2];
if (zoneid < 1) {
sender.sendMessage("Invalid zoneid");
return false;
}
try {
if (StateManager.getInstance().getConfigurationManager().getZone(zoneid) == null) {
sender.sendMessage("Cannot locate zone id: " + zoneid);
return false;
}
/*if (StateManager.getInstance().getConfigurationManager().getZone(zoneid).isOperatorCreated() && !sender.isOp())
{
sender.sendMessage("This zone was op created and you are not an op. Only ops can edit op zone items");
return false;
}*/
StateManager.getInstance().getConfigurationManager().editZone(zoneid, setting, value);
sender.sendMessage("Updating setting on Zone");
} catch (InvalidZoneSettingException ne) {
sender.sendMessage("Invalid zone setting: " + ne.getMessage());
} catch (CoreStateInitException e) {
// TODO Auto-generated catch block
sender.sendMessage(e.getMessage());
}
return true;
}
use of com.solinia.solinia.Models.SoliniaZone in project solinia3-core by mixxit.
the class CommandCreateZone method onCommand.
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (!(sender instanceof Player) && !(sender instanceof CommandSender))
return false;
if (sender instanceof Player) {
Player player = (Player) sender;
if (!player.isOp() && !player.hasPermission("solinia.createzone")) {
player.sendMessage("You do not have permission to access this command");
return false;
}
}
if (args.length < 4) {
sender.sendMessage("Insufficient arguments: namenospaces x y z");
return false;
}
String zonename = args[0].toUpperCase();
int x = Integer.parseInt(args[1]);
int y = Integer.parseInt(args[2]);
int z = Integer.parseInt(args[3]);
if (zonename.equals("")) {
sender.sendMessage("Name of Zone cannot be null");
return false;
}
try {
SoliniaZone zone = SoliniaZoneFactory.Create(zonename, x, y, z, sender.isOp());
sender.sendMessage("Created Zone: " + zone.getId());
} catch (CoreStateInitException | SoliniaZoneCreationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
sender.sendMessage(e.getMessage());
}
return true;
}
use of com.solinia.solinia.Models.SoliniaZone in project solinia3-core by mixxit.
the class CoreState method setRandomHotzones.
public void setRandomHotzones() {
currentHotZones.clear();
try {
int maxCheckSize = StateManager.getInstance().getConfigurationManager().getZones().size() * 4;
int currentCount = 0;
List<SoliniaZone> possibleHotZones = new ArrayList<SoliniaZone>();
for (SoliniaZone zone : StateManager.getInstance().getConfigurationManager().getZones()) {
if (!zone.isHotzone())
continue;
possibleHotZones.add(zone);
}
// if there isnt any just skip this
if (possibleHotZones.size() < 1)
return;
// If only one, just always return it
if (possibleHotZones.size() == 1) {
currentHotZones.add(possibleHotZones.get(0).getId());
return;
}
// Else try to pick two random ones
while (currentHotZones.size() < 2) {
if (currentCount > maxCheckSize)
break;
SoliniaZone zone = Utils.getRandomItemFromList(possibleHotZones);
if (!zone.isHotzone())
continue;
if (currentHotZones.contains(zone.getId()))
continue;
System.out.println("Hotzone set to: " + zone.getName());
currentHotZones.add(zone.getId());
}
} catch (CoreStateInitException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
use of com.solinia.solinia.Models.SoliniaZone in project solinia3-core by mixxit.
the class ChannelManager method sendHotzonesToDiscordChannel.
private void sendHotzonesToDiscordChannel(DiscordChannel discordChannel) {
String list = "";
String targetChannelId = getDefaultDiscordChannel();
if (discordChannel.equals(DiscordChannel.ADMIN))
targetChannelId = getAdminDiscordChannel();
try {
sendToDiscordMC(null, targetChannelId, "Current 100% bonus XP Hotzones are: ");
for (SoliniaZone zone : StateManager.getInstance().getCurrentHotzones()) {
sendToDiscordMC(null, targetChannelId, zone.getName() + ": " + zone.getX() + "," + zone.getY() + "," + zone.getZ());
}
} catch (Exception e) {
// ignore it
}
}
Aggregations