mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2024-12-30 13:27:37 +00:00
Fixes, added /hub, removed CONSOLE restrictions on some commands
This commit is contained in:
parent
1c3970b984
commit
7d0ea0837e
4
pom.xml
4
pom.xml
@ -5,12 +5,12 @@
|
||||
|
||||
<groupId>me.totalfreedom</groupId>
|
||||
<artifactId>totalfreedom</artifactId>
|
||||
<version>5.2</version>
|
||||
<version>6.0</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<tfm.build.codename>God</tfm.build.codename>
|
||||
<tfm.build.codename>Smartn't</tfm.build.codename>
|
||||
<jar.finalName>${project.name}</jar.finalName>
|
||||
<timestamp>${maven.build.timestamp}</timestamp>
|
||||
<maven.build.timestamp.format>MM/dd/yyyy HH:mm</maven.build.timestamp.format>
|
||||
|
@ -120,6 +120,10 @@ public class ChatManager extends FreedomService
|
||||
{
|
||||
color = ChatColor.LIGHT_PURPLE;
|
||||
}
|
||||
else if (color.equals(ChatColor.DARK_RED))
|
||||
{
|
||||
color = ChatColor.BLUE;
|
||||
}
|
||||
}
|
||||
return color;
|
||||
}
|
||||
@ -138,6 +142,10 @@ public class ChatManager extends FreedomService
|
||||
{
|
||||
color = ChatColor.LIGHT_PURPLE;
|
||||
}
|
||||
else if (color.equals(ChatColor.DARK_RED))
|
||||
{
|
||||
color = ChatColor.BLUE;
|
||||
}
|
||||
}
|
||||
return color + display.getAbbr();
|
||||
}
|
||||
@ -177,4 +185,4 @@ public class ChatManager extends FreedomService
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -39,6 +39,7 @@ import me.totalfreedom.totalfreedommod.httpd.HTTPDaemon;
|
||||
import me.totalfreedom.totalfreedommod.masterbuilder.MasterBuilder;
|
||||
import me.totalfreedom.totalfreedommod.masterbuilder.MasterBuilderList;
|
||||
import me.totalfreedom.totalfreedommod.masterbuilder.MasterBuilderWorldRestrictions;
|
||||
import me.totalfreedom.totalfreedommod.hub.HubWorldRestrictions;
|
||||
import me.totalfreedom.totalfreedommod.player.PlayerList;
|
||||
import me.totalfreedom.totalfreedommod.playerverification.PlayerVerification;
|
||||
import me.totalfreedom.totalfreedommod.punishments.PunishmentList;
|
||||
@ -125,6 +126,7 @@ public class TotalFreedomMod extends AeroPlugin<TotalFreedomMod>
|
||||
public MasterBuilderWorldRestrictions mbwr;
|
||||
public SignBlocker snp;
|
||||
public PlayerVerification pv;
|
||||
public HubWorldRestrictions hwr;
|
||||
//
|
||||
// Bridges
|
||||
public ServiceManager<TotalFreedomMod> bridges;
|
||||
@ -199,6 +201,7 @@ public class TotalFreedomMod extends AeroPlugin<TotalFreedomMod>
|
||||
as = services.registerService(AntiSpam.class);
|
||||
mbl = services.registerService(MasterBuilderList.class);
|
||||
mbwr = services.registerService(MasterBuilderWorldRestrictions.class);
|
||||
hwr = services.registerService(HubWorldRestrictions.class);
|
||||
|
||||
pl = services.registerService(PlayerList.class);
|
||||
an = services.registerService(Announcer.class);
|
||||
|
@ -10,7 +10,7 @@ import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.ONLY_CONSOLE, blockHostConsole = true)
|
||||
@CommandPermissions(level = Rank.TELNET_ADMIN, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Close server to non-admins.", usage = "/<command> [on | off]")
|
||||
public class Command_adminmode extends FreedomCommand
|
||||
{
|
||||
|
@ -11,9 +11,9 @@ import org.bukkit.ChatColor;
|
||||
|
||||
@CommandPermissions(level = Rank.SENIOR_ADMIN, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Cuck someone", usage = "/<command> <player>")
|
||||
public class Command_cuck extends FreedomCommand
|
||||
public class Command_cuck extends FreedomCommand
|
||||
{
|
||||
|
||||
/* This command will not work on Paper because there was a patch to remove it. This will work on Spigot and Bukkit. */
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
@ -55,4 +55,4 @@ public class Command_cuck extends FreedomCommand
|
||||
}
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
}
|
@ -9,7 +9,7 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
@CommandPermissions(level = Rank.SENIOR_ADMIN, source = SourceType.BOTH, blockHostConsole = true)
|
||||
@CommandPermissions(level = Rank.SENIOR_ADMIN, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Make some noise.", usage = "/<command>")
|
||||
public class Command_deafen extends FreedomCommand
|
||||
{
|
||||
|
@ -141,11 +141,11 @@ public class Command_gtfo extends FreedomCommand
|
||||
.append(" - ")
|
||||
.append("Banning: ")
|
||||
.append(username);
|
||||
playerMsg(sender, ChatColor.GRAY + username + " has been banned and IP is: " + StringUtils.join(ips, ", "));
|
||||
if (reason != null)
|
||||
{
|
||||
bcast.append(" - Reason: ").append(ChatColor.YELLOW).append(reason);
|
||||
}
|
||||
playerMsg(sender, ChatColor.GRAY + username + " has been banned and IP is: " + StringUtils.join(ips, ", "));
|
||||
FUtil.bcastMsg(bcast.toString());
|
||||
|
||||
// Kick player
|
||||
|
@ -0,0 +1,203 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import me.totalfreedom.totalfreedommod.world.WorldTime;
|
||||
import me.totalfreedom.totalfreedommod.world.WorldWeather;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = Rank.OP, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Go to the MasterBuilderWorld.",
|
||||
usage = "/<command> [time <morning | noon | evening | night> | weather <off | rain | storm>]",
|
||||
aliases = "hw,hworld")
|
||||
public class Command_hubworld extends FreedomCommand
|
||||
{
|
||||
|
||||
private enum CommandMode
|
||||
{
|
||||
TELEPORT, TIME, WEATHER
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
CommandMode commandMode = null;
|
||||
|
||||
if (args.length == 0)
|
||||
{
|
||||
commandMode = CommandMode.TELEPORT;
|
||||
}
|
||||
else if (args.length >= 2)
|
||||
{
|
||||
if ("time".equalsIgnoreCase(args[0]))
|
||||
{
|
||||
commandMode = CommandMode.TIME;
|
||||
}
|
||||
else if ("weather".equalsIgnoreCase(args[0]))
|
||||
{
|
||||
commandMode = CommandMode.WEATHER;
|
||||
}
|
||||
}
|
||||
|
||||
if (commandMode == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
switch (commandMode)
|
||||
{
|
||||
case TELEPORT:
|
||||
{
|
||||
if (!(sender instanceof Player) || playerSender == null)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
World masterBuilderWorld = null;
|
||||
try
|
||||
{
|
||||
masterBuilderWorld = plugin.wm.hubworld.getWorld();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
}
|
||||
|
||||
if (masterBuilderWorld == null || playerSender.getWorld() == masterBuilderWorld)
|
||||
{
|
||||
msg("Going to the main world.");
|
||||
playerSender.teleport(server.getWorlds().get(0).getSpawnLocation());
|
||||
}
|
||||
else
|
||||
{
|
||||
msg("Going to the Hub");
|
||||
plugin.wm.hubworld.sendToWorld(playerSender);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case TIME:
|
||||
{
|
||||
assertCommandPerms(sender, playerSender);
|
||||
|
||||
if (args.length == 2)
|
||||
{
|
||||
WorldTime timeOfDay = WorldTime.getByAlias(args[1]);
|
||||
if (timeOfDay != null)
|
||||
{
|
||||
plugin.wm.hubworld.setTimeOfDay(timeOfDay);
|
||||
msg("Hub time set to: " + timeOfDay.name());
|
||||
}
|
||||
else
|
||||
{
|
||||
msg("Invalid time of day. Can be: sunrise, noon, sunset, midnight");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case WEATHER:
|
||||
{
|
||||
assertCommandPerms(sender, playerSender);
|
||||
|
||||
if (args.length == 2)
|
||||
{
|
||||
WorldWeather weatherMode = WorldWeather.getByAlias(args[1]);
|
||||
if (weatherMode != null)
|
||||
{
|
||||
plugin.wm.hubworld.setWeatherMode(weatherMode);
|
||||
msg("Hub weather set to: " + weatherMode.name());
|
||||
}
|
||||
else
|
||||
{
|
||||
msg("Invalid weather mode. Can be: off, rain, storm");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (PermissionDeniedException ex)
|
||||
{
|
||||
if (ex.getMessage().isEmpty())
|
||||
{
|
||||
return noPerms();
|
||||
}
|
||||
sender.sendMessage(ex.getMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getTabCompleteOptions(CommandSender sender, Command command, String alias, String[] args)
|
||||
{
|
||||
if (!plugin.al.isAdmin(sender))
|
||||
{
|
||||
return Collections.emptyList();
|
||||
}
|
||||
if (args.length == 1)
|
||||
{
|
||||
return Arrays.asList("time", "weather");
|
||||
}
|
||||
else if (args.length == 2)
|
||||
{
|
||||
if (args[0].equals("time"))
|
||||
{
|
||||
return Arrays.asList("morning", "noon", "evening", "night");
|
||||
}
|
||||
else if (args[0].equals("weather"))
|
||||
{
|
||||
return Arrays.asList("off", "rain", "storm");
|
||||
}
|
||||
}
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
// TODO: Redo this properly
|
||||
private void assertCommandPerms(CommandSender sender, Player playerSender) throws PermissionDeniedException
|
||||
{
|
||||
if (!(sender instanceof Player) || playerSender == null || !plugin.al.isSeniorAdmin(playerSender))
|
||||
{
|
||||
throw new PermissionDeniedException();
|
||||
}
|
||||
}
|
||||
|
||||
private class PermissionDeniedException extends Exception
|
||||
{
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private PermissionDeniedException()
|
||||
{
|
||||
super("");
|
||||
}
|
||||
|
||||
private PermissionDeniedException(String string)
|
||||
{
|
||||
super(string);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -7,7 +7,7 @@ import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = Rank.SENIOR_ADMIN, source = SourceType.BOTH, blockHostConsole = true)
|
||||
@CommandPermissions(level = Rank.SENIOR_ADMIN, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Kick all non-admins on server.", usage = "/<command>")
|
||||
public class Command_kicknoob extends FreedomCommand
|
||||
{
|
||||
|
@ -19,24 +19,6 @@ public class Command_opall extends FreedomCommand
|
||||
|
||||
boolean doSetGamemode = false;
|
||||
GameMode targetGamemode = GameMode.CREATIVE;
|
||||
if (args.length != 0)
|
||||
{
|
||||
if (args[0].equals("-c"))
|
||||
{
|
||||
doSetGamemode = true;
|
||||
targetGamemode = GameMode.CREATIVE;
|
||||
}
|
||||
else if (args[0].equals("-s"))
|
||||
{
|
||||
doSetGamemode = true;
|
||||
targetGamemode = GameMode.SURVIVAL;
|
||||
}
|
||||
else if (args[0].equals("-a"))
|
||||
{
|
||||
doSetGamemode = true;
|
||||
targetGamemode = GameMode.ADVENTURE;
|
||||
}
|
||||
}
|
||||
|
||||
for (Player player : server.getOnlinePlayers())
|
||||
{
|
||||
|
@ -6,7 +6,7 @@ import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.ONLY_CONSOLE, blockHostConsole = true)
|
||||
@CommandPermissions(level = Rank.SENIOR_ADMIN, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Manage permanently banned players and IPs.", usage = "/<command> reload")
|
||||
public class Command_permban extends FreedomCommand
|
||||
{
|
||||
|
@ -1,113 +0,0 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = Rank.NON_OP, source = SourceType.ONLY_IN_GAME)
|
||||
@CommandParameters(description = "Shows nearby people sorted by distance.", usage = "/<command> [range]")
|
||||
public class Command_radar extends FreedomCommand
|
||||
{
|
||||
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
Location playerSenderos = playerSender.getLocation();
|
||||
|
||||
List<RadarData> radar_data = new ArrayList<>();
|
||||
|
||||
for (Player player : playerSenderos.getWorld().getPlayers())
|
||||
{
|
||||
if (!player.equals(playerSender))
|
||||
{
|
||||
try
|
||||
{
|
||||
radar_data.add(new RadarData(player, playerSenderos.distance(player.getLocation()), player.getLocation()));
|
||||
}
|
||||
catch (IllegalArgumentException ex)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (radar_data.isEmpty())
|
||||
{
|
||||
msg("You are the only player in this world. (" + ChatColor.GREEN + "Forever alone..." + ChatColor.YELLOW + ")", ChatColor.YELLOW); //lol
|
||||
return true;
|
||||
}
|
||||
|
||||
Collections.sort(radar_data, new RadarData());
|
||||
|
||||
msg("People nearby in " + playerSenderos.getWorld().getName() + ":", ChatColor.YELLOW);
|
||||
|
||||
int countmax = 5;
|
||||
if (args.length == 1)
|
||||
{
|
||||
try
|
||||
{
|
||||
countmax = Math.max(1, Math.min(64, Integer.parseInt(args[0])));
|
||||
}
|
||||
catch (NumberFormatException nfex)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
for (RadarData i : radar_data)
|
||||
{
|
||||
msg(String.format("%s - %d",
|
||||
i.player.getName(),
|
||||
Math.round(i.distance)), ChatColor.YELLOW);
|
||||
|
||||
if (--countmax <= 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private class RadarData implements Comparator<RadarData>
|
||||
{
|
||||
|
||||
public Player player;
|
||||
public double distance;
|
||||
public Location location;
|
||||
|
||||
public RadarData(Player player, double distance, Location location)
|
||||
{
|
||||
this.player = player;
|
||||
this.distance = distance;
|
||||
this.location = location;
|
||||
}
|
||||
|
||||
public RadarData()
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compare(RadarData t1, RadarData t2)
|
||||
{
|
||||
if (t1.distance > t2.distance)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
else if (t1.distance < t2.distance)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -7,7 +7,7 @@ import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = Rank.SENIOR_ADMIN, source = SourceType.ONLY_CONSOLE, blockHostConsole = true)
|
||||
@CommandPermissions(level = Rank.SENIOR_ADMIN, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Broadcasts the given message. Supports colors.", usage = "/<command> <message>")
|
||||
public class Command_rawsay extends FreedomCommand
|
||||
{
|
||||
|
@ -42,8 +42,7 @@ public class Command_saconfig extends FreedomCommand
|
||||
|
||||
case "clean":
|
||||
{
|
||||
checkConsole();
|
||||
checkRank(Rank.TELNET_ADMIN);
|
||||
checkRank(Rank.SENIOR_ADMIN);
|
||||
|
||||
FUtil.adminAction(sender.getName(), "Cleaning admin list", true);
|
||||
plugin.al.deactivateOldEntries(true);
|
||||
@ -54,7 +53,7 @@ public class Command_saconfig extends FreedomCommand
|
||||
|
||||
case "reload":
|
||||
{
|
||||
checkRank(Rank.SUPER_ADMIN);
|
||||
checkRank(Rank.SENIOR_ADMIN);
|
||||
|
||||
FUtil.adminAction(sender.getName(), "Reloading the admin list", true);
|
||||
plugin.al.load();
|
||||
@ -64,9 +63,7 @@ public class Command_saconfig extends FreedomCommand
|
||||
|
||||
case "setrank":
|
||||
{
|
||||
checkConsole();
|
||||
checkNotHostConsole();
|
||||
checkRank(Rank.SENIOR_CONSOLE);
|
||||
checkRank(Rank.SENIOR_ADMIN);
|
||||
|
||||
if (args.length < 3)
|
||||
{
|
||||
@ -158,7 +155,6 @@ public class Command_saconfig extends FreedomCommand
|
||||
return false;
|
||||
}
|
||||
|
||||
checkConsole();
|
||||
checkRank(Rank.TELNET_ADMIN);
|
||||
|
||||
// Player already an admin?
|
||||
@ -330,7 +326,6 @@ public class Command_saconfig extends FreedomCommand
|
||||
return false;
|
||||
}
|
||||
|
||||
checkConsole();
|
||||
checkRank(Rank.TELNET_ADMIN);
|
||||
|
||||
Player player = getPlayer(args[1]);
|
||||
|
@ -10,6 +10,8 @@ import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.ChatColor;
|
||||
import static me.totalfreedom.totalfreedommod.util.FUtil.playerMsg;
|
||||
|
||||
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Unbans a player", usage = "/<command> <username> [-r[estore]]")
|
||||
@ -35,7 +37,8 @@ public class Command_unban extends FreedomCommand
|
||||
username = entry.getUsername();
|
||||
ips.addAll(entry.getIps());
|
||||
|
||||
FUtil.adminAction(sender.getName(), "Unbanning " + username + " and IPs: " + StringUtils.join(ips, ", "), true);
|
||||
FUtil.adminAction(sender.getName(), "Unbanning " + username, true);
|
||||
playerMsg(sender, ChatColor.GRAY + username + " has been unbanned and IP is: " + StringUtils.join(ips, ", "));
|
||||
plugin.bm.removeBan(plugin.bm.getByUsername(username));
|
||||
|
||||
if (args.length >= 2)
|
||||
|
@ -0,0 +1,34 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import java.util.List;
|
||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = Rank.OP, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Information on how to vote", usage = "/<command>", aliases = "ai")
|
||||
public class Command_vote extends FreedomCommand
|
||||
{
|
||||
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
List<String> voteInfo = ConfigEntry.VOTING_INFO.getStringList();
|
||||
|
||||
if (voteInfo.isEmpty())
|
||||
{
|
||||
msg("There is no voting information set in the config.", ChatColor.RED);
|
||||
}
|
||||
else
|
||||
{
|
||||
msg(FUtil.colorize(StringUtils.join(voteInfo, "\n")));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
@ -111,6 +111,7 @@ public enum ConfigEntry
|
||||
NOADMIN_IPS(List.class, "noadmin_ips"),
|
||||
ADMIN_ONLY_MODE(Boolean.class, "admin_only_mode"),
|
||||
ADMIN_INFO(List.class, "admininfo"),
|
||||
VOTING_INFO(List.class, "votinginfo"),
|
||||
MASTER_BUILDER_INFO(List.class, "masterbuilderinfo"),
|
||||
AUTO_ENTITY_WIPE(Boolean.class, "auto_wipe"),
|
||||
//
|
||||
|
@ -141,6 +141,11 @@ public class ItemFun extends FreedomService
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
if (player.getWorld().equals(plugin.wm.hubworld.getWorld()) && plugin.hwr.doRestrict(player))
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
Location location = player.getLocation().clone();
|
||||
|
||||
|
@ -0,0 +1,132 @@
|
||||
package me.totalfreedom.totalfreedommod.hub;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.player.PlayerArmorStandManipulateEvent;
|
||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
|
||||
public class HubWorldRestrictions extends FreedomService
|
||||
{
|
||||
|
||||
public final List<String> ALLOWED_COMMANDS = Arrays.asList(
|
||||
"list", "opall", "gmc", "gms", "gma", "gmsp", "purgeall", "stfu", "tempban", "gtfo", "noob", "adminworld", "masterbuilderworld", "world", "nether", "spawn", "tpo", "tp", "expel", "item", "i", "give", "adminchat", "adventure", "creative", "survival", "spectator", "say", "blockcmd", "blockpvp", "blockredstone", "stoplag", "halt-activity", "nickclean", "nick", "nicknyan", "vanish", "verify", "verifynoadmin", "co", "coreprotect", "core", "mobpurge", "logs", "links", "vote");
|
||||
|
||||
public HubWorldRestrictions(TotalFreedomMod plugin)
|
||||
{
|
||||
super(plugin);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStart()
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStop()
|
||||
{
|
||||
}
|
||||
|
||||
public boolean doRestrict(Player player)
|
||||
{
|
||||
if (!FUtil.isExecutive(player.getName()) && player.getWorld().equals(plugin.wm.hubworld.getWorld()))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
public void onBlockPlace(BlockPlaceEvent event)
|
||||
{
|
||||
final Player player = event.getPlayer();
|
||||
|
||||
if (doRestrict(player))
|
||||
{
|
||||
player.sendMessage(ChatColor.RED + "Only Executives can build in the Hub.");
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||
public void onBlockBreak(BlockBreakEvent event)
|
||||
{
|
||||
final Player player = event.getPlayer();
|
||||
|
||||
if (doRestrict(player))
|
||||
{
|
||||
player.sendMessage(ChatColor.RED + "Only Executives can build in the Hub.");
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
public void onPlayerInteract(PlayerInteractEvent event)
|
||||
{
|
||||
final Player player = event.getPlayer();
|
||||
|
||||
if (doRestrict(player))
|
||||
{
|
||||
player.sendMessage(ChatColor.RED + "Only Executives can PVP in the Hub.");
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
public void onArmorStandManipulate(PlayerArmorStandManipulateEvent event)
|
||||
{
|
||||
final Player player = event.getPlayer();
|
||||
|
||||
if (doRestrict(player))
|
||||
{
|
||||
player.sendMessage(ChatColor.RED + "Only Executives can interact with armorstands in the Hub.");
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
public void onEntityDamageByEntity(EntityDamageByEntityEvent event)
|
||||
{
|
||||
if (event.getDamager() instanceof Player)
|
||||
{
|
||||
Player player = (Player)event.getDamager();
|
||||
|
||||
if (doRestrict(player))
|
||||
{
|
||||
player.sendMessage(ChatColor.RED + "Only Executives can damage entities in the Hub.");
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
public void onCommandPreprocess(PlayerCommandPreprocessEvent event)
|
||||
{
|
||||
final Player player = event.getPlayer();
|
||||
if (doRestrict(player))
|
||||
{
|
||||
String command = event.getMessage().split("\\s+")[0].substring(1, event.getMessage().split("\\s+")[0].length()).toLowerCase();
|
||||
|
||||
if (ALLOWED_COMMANDS.contains(command))
|
||||
{
|
||||
event.setCancelled(false);
|
||||
}
|
||||
else if (command.startsWith(""))
|
||||
{
|
||||
player.sendMessage(ChatColor.RED + "Only Executives are allowed to execute commands in the Hub World!");
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,99 @@
|
||||
package me.totalfreedom.totalfreedommod.world;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.WorldCreator;
|
||||
import org.bukkit.WorldType;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public final class HubWorld extends CustomWorld
|
||||
{
|
||||
|
||||
private static final String GENERATION_PARAMETERS = ConfigEntry.FLATLANDS_GENERATE_PARAMS.getString();
|
||||
//
|
||||
private WorldWeather weather = WorldWeather.OFF;
|
||||
private WorldTime time = WorldTime.INHERIT;
|
||||
|
||||
public HubWorld()
|
||||
{
|
||||
super("hubworld");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendToWorld(Player player)
|
||||
{
|
||||
super.sendToWorld(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected World generateWorld()
|
||||
{
|
||||
final WorldCreator worldCreator = new WorldCreator(getName());
|
||||
worldCreator.generateStructures(false);
|
||||
worldCreator.type(WorldType.NORMAL);
|
||||
worldCreator.environment(World.Environment.NORMAL);
|
||||
worldCreator.generator(new CleanroomChunkGenerator(GENERATION_PARAMETERS));
|
||||
|
||||
final World world = server.createWorld(worldCreator);
|
||||
|
||||
world.setSpawnFlags(false, false);
|
||||
world.setSpawnLocation(0, 50, 0);
|
||||
|
||||
final Block welcomeSignBlock = world.getBlockAt(0, 50, 0);
|
||||
welcomeSignBlock.setType(Material.OAK_SIGN);
|
||||
org.bukkit.block.Sign welcomeSign = (org.bukkit.block.Sign)welcomeSignBlock.getState();
|
||||
|
||||
org.bukkit.material.Sign signData = (org.bukkit.material.Sign)welcomeSign.getData();
|
||||
signData.setFacingDirection(BlockFace.NORTH);
|
||||
|
||||
welcomeSign.setLine(0, ChatColor.GREEN + "Hub World");
|
||||
welcomeSign.setLine(1, ChatColor.DARK_GRAY + "---");
|
||||
welcomeSign.setLine(2, ChatColor.YELLOW + "Spawn Point");
|
||||
welcomeSign.setLine(3, ChatColor.DARK_GRAY + "---");
|
||||
welcomeSign.update();
|
||||
|
||||
plugin.gr.commitGameRules();
|
||||
return world;
|
||||
}
|
||||
|
||||
public WorldWeather getWeatherMode()
|
||||
{
|
||||
return weather;
|
||||
}
|
||||
|
||||
public void setWeatherMode(final WorldWeather weatherMode)
|
||||
{
|
||||
this.weather = weatherMode;
|
||||
|
||||
try
|
||||
{
|
||||
weatherMode.setWorldToWeather(getWorld());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public WorldTime getTimeOfDay()
|
||||
{
|
||||
return time;
|
||||
}
|
||||
|
||||
public void setTimeOfDay(final WorldTime timeOfDay)
|
||||
{
|
||||
this.time = timeOfDay;
|
||||
|
||||
try
|
||||
{
|
||||
timeOfDay.setWorldToTime(getWorld());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -23,6 +23,7 @@ public class WorldManager extends FreedomService
|
||||
public Flatlands flatlands;
|
||||
public AdminWorld adminworld;
|
||||
public MasterBuilderWorld masterBuilderWorld;
|
||||
public HubWorld hubworld;
|
||||
|
||||
public WorldManager(TotalFreedomMod plugin)
|
||||
{
|
||||
@ -31,6 +32,7 @@ public class WorldManager extends FreedomService
|
||||
this.flatlands = new Flatlands();
|
||||
this.adminworld = new AdminWorld();
|
||||
this.masterBuilderWorld = new MasterBuilderWorld();
|
||||
this.hubworld = new HubWorld();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -39,6 +41,7 @@ public class WorldManager extends FreedomService
|
||||
flatlands.getWorld();
|
||||
adminworld.getWorld();
|
||||
masterBuilderWorld.getWorld();
|
||||
hubworld.getWorld();
|
||||
|
||||
// Disable weather
|
||||
if (ConfigEntry.DISABLE_WEATHER.getBoolean())
|
||||
@ -59,6 +62,7 @@ public class WorldManager extends FreedomService
|
||||
flatlands.getWorld().save();
|
||||
adminworld.getWorld().save();
|
||||
masterBuilderWorld.getWorld().save();
|
||||
hubworld.getWorld().save();
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
@ -109,6 +113,10 @@ public class WorldManager extends FreedomService
|
||||
{
|
||||
return;
|
||||
}
|
||||
else if (event.getWorld().equals(hubworld.getWorld()) && hubworld.getWeatherMode() != WorldWeather.OFF)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@ -133,6 +141,10 @@ public class WorldManager extends FreedomService
|
||||
{
|
||||
return;
|
||||
}
|
||||
else if (event.getWorld().equals(hubworld.getWorld()) && hubworld.getWeatherMode() != WorldWeather.OFF)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
@ -315,6 +315,13 @@ admininfo:
|
||||
- ' &6- Report those breaking the rules'
|
||||
- ' &2- And apply on our forums at the link:'
|
||||
- ' &9www.totalfreedom.boards.net'
|
||||
|
||||
# What to display in the vote command.
|
||||
votinginfo:
|
||||
- '&bVoting Links:'
|
||||
- ' &6- https://minecraft-mp.com/server/228386/vote/'
|
||||
- ' &2- https://minecraft-server-list.com/server/443272/vote/'
|
||||
- ' &6- https://topg.org/Minecraft/in-518809'
|
||||
|
||||
# What to display in the Master Builder info command.
|
||||
masterbuilderinfo:
|
||||
|
Loading…
Reference in New Issue
Block a user