Merge branch 'bench'
Conflicts: Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilText.java Plugins/Mineplex.Core/src/mineplex/core/chat/Chat.java Plugins/Mineplex.StaffServer/.classpath
This commit is contained in:
commit
e36b0440a4
@ -0,0 +1,65 @@
|
||||
package mineplex.core.common;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class Pair<L, R> implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = -7631968541502978704L;
|
||||
|
||||
private L left;
|
||||
private R right;
|
||||
|
||||
public static <L, R> Pair<L, R> create(L left, R right)
|
||||
{
|
||||
return new Pair<L, R>(left, right);
|
||||
}
|
||||
|
||||
private Pair(L left, R right) {
|
||||
this.setLeft(left);
|
||||
this.setRight(right);
|
||||
}
|
||||
|
||||
public L getLeft()
|
||||
{
|
||||
return left;
|
||||
}
|
||||
|
||||
public void setLeft(L left)
|
||||
{
|
||||
this.left = left;
|
||||
}
|
||||
|
||||
public R getRight()
|
||||
{
|
||||
return right;
|
||||
}
|
||||
|
||||
public void setRight(R right)
|
||||
{
|
||||
this.right = right;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return getLeft().toString() + ":" + getRight().toString();
|
||||
}
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
@Override
|
||||
public boolean equals(Object obj)
|
||||
{
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (!(obj instanceof Pair))
|
||||
return false;
|
||||
|
||||
Pair localPair = (Pair) obj;
|
||||
|
||||
if (getLeft() != null ? !getLeft().equals(localPair.getLeft()) : localPair.getLeft() != null)
|
||||
return false;
|
||||
if (getRight() != null ? !getRight().equals(localPair.getRight()) : localPair.getRight() != null)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
}
|
@ -18,7 +18,31 @@ import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class UtilBlock
|
||||
{
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
for (Material m : Material.values()) {
|
||||
|
||||
boolean thisSolid = fullSolid(m.getId());
|
||||
boolean solid = m.isSolid();
|
||||
if (thisSolid != solid) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("Failed: ");
|
||||
sb.append(m.name());
|
||||
int amount = 40 - sb.length();
|
||||
for (int i = 0; i < amount; i++) {
|
||||
sb.append(" ");
|
||||
}
|
||||
sb.append(thisSolid);
|
||||
System.out.println(sb);
|
||||
}
|
||||
|
||||
}
|
||||
System.out.println("done!");
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* A list of blocks that are usable
|
||||
*/
|
||||
|
@ -2,25 +2,50 @@ package mineplex.core.common.util;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
public class UtilText
|
||||
{
|
||||
public static <T> String listToString(Collection<T> inputList, boolean comma)
|
||||
{
|
||||
public class UtilText {
|
||||
public static <T> String listToString(Collection<T> inputList, boolean comma) {
|
||||
String out = "";
|
||||
|
||||
for (T cur : inputList)
|
||||
{
|
||||
|
||||
for (T cur : inputList) {
|
||||
out += cur.toString() + (comma ? ", " : " ");
|
||||
}
|
||||
|
||||
if (out.length() > 0)
|
||||
{
|
||||
out = out.substring(0, out.length()-(comma ? 2 : 1));
|
||||
|
||||
if (out.length() > 0) {
|
||||
out = out.substring(0, out.length() - (comma ? 2 : 1));
|
||||
}
|
||||
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
public static int upperCaseCount(String input) {
|
||||
int count = 0;
|
||||
|
||||
for (int k = 0; k < input.length(); k++) {
|
||||
|
||||
|
||||
char ch = input.charAt(k);
|
||||
if (Character.isUpperCase(ch))
|
||||
count++;
|
||||
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
public static int lowerCaseCount(String input) {
|
||||
int count = 0;
|
||||
|
||||
for (int k = 0; k < input.length(); k++) {
|
||||
|
||||
|
||||
char ch = input.charAt(k);
|
||||
if (Character.isLowerCase(ch))
|
||||
count++;
|
||||
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
public static boolean isStringSimilar(String newString, String oldString, float matchRequirement)
|
||||
{
|
||||
for (int i=0 ; i < newString.length() * matchRequirement ; i++)
|
||||
|
@ -54,6 +54,7 @@ public class Chat extends MiniPlugin
|
||||
private PreferencesManager _preferences;
|
||||
private AchievementManager _achievements;
|
||||
|
||||
private String[] _hackusations = {"hack", "hax", "hacker", "hacking", "cheat", "cheater", "cheating", "forcefield", "flyhack", "flyhacking", "autoclick", "aimbot"};
|
||||
private String _filterUrl = "https://10.33.53.5:8003/content/item/moderate";
|
||||
private String _appId = "34018d65-466d-4a91-8e92-29ca49f022c4";
|
||||
private String _apiKey = "oUywMpwZcIzZO5AWnfDx";
|
||||
@ -355,22 +356,13 @@ public class Chat extends MiniPlugin
|
||||
|
||||
private boolean msgContainsHack(String msg)
|
||||
{
|
||||
msg = " " + msg.toLowerCase() + " ";
|
||||
msg.replaceAll("[^a-zA-Z ]", " ");
|
||||
|
||||
return (msg.contains(" hack ") ||
|
||||
msg.contains(" hacker ") ||
|
||||
msg.contains(" hacking ") ||
|
||||
msg.contains(" cheat ") ||
|
||||
msg.contains(" cheater ") ||
|
||||
msg.contains(" cheating ") ||
|
||||
msg.contains(" forcefield ") ||
|
||||
msg.contains(" flyhack ") ||
|
||||
msg.contains(" flyhacker ") ||
|
||||
msg.contains(" flyhacking ") ||
|
||||
msg.contains(" autoclick ") ||
|
||||
msg.contains(" flyhacking ") ||
|
||||
msg.contains(" aimbot "));
|
||||
msg = " " + msg.toLowerCase().replaceAll("[^a-z ]", "") + " ";
|
||||
for (String s : _hackusations) {
|
||||
if (msg.contains(" " + s + " ")) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public String hasher(JSONArray hasharray, String message)
|
||||
|
@ -46,6 +46,7 @@ import org.bukkit.event.entity.EntityExplodeEvent;
|
||||
import org.bukkit.event.entity.EntityTargetEvent;
|
||||
import org.bukkit.event.player.PlayerDropItemEvent;
|
||||
import org.bukkit.event.player.PlayerPickupItemEvent;
|
||||
import org.bukkit.event.weather.WeatherChangeEvent;
|
||||
|
||||
public class WorldManager extends MiniPlugin
|
||||
{
|
||||
@ -61,6 +62,18 @@ public class WorldManager extends MiniPlugin
|
||||
super("World Manager", manager.getPlugin());
|
||||
|
||||
Manager = manager;
|
||||
|
||||
//Added by TheMineBench, to stop day cycles instead of setting the time on update event.
|
||||
World world = UtilWorld.getWorld("world");
|
||||
|
||||
world.setGameRuleValue("doDaylightCycle", "false");
|
||||
|
||||
if (Manager.Type == HubType.Halloween)
|
||||
world.setTime(16000);
|
||||
else
|
||||
world.setTime(6000);
|
||||
world.setStorm(false);
|
||||
world.setThundering(false);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@ -216,7 +229,8 @@ public class WorldManager extends MiniPlugin
|
||||
ent.remove();
|
||||
}
|
||||
}
|
||||
|
||||
//Removed by TheMineBench, time is now stopped when the WorldManager is created
|
||||
/*
|
||||
@EventHandler
|
||||
public void UpdateWeather(UpdateEvent event)
|
||||
{
|
||||
@ -232,7 +246,17 @@ public class WorldManager extends MiniPlugin
|
||||
|
||||
world.setStorm(false);
|
||||
}
|
||||
|
||||
*/
|
||||
//Added by TheMineBench. Stops weather from changing.
|
||||
@EventHandler
|
||||
public void OnWeather(WeatherChangeEvent event) {
|
||||
|
||||
if (!event.getWorld().getName().equals("world"))
|
||||
return;
|
||||
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void HalloweenUpdates(UpdateEvent event)
|
||||
{
|
||||
|
@ -63,7 +63,9 @@ public abstract class FireGrenadeBase extends Grenade
|
||||
final int round = game.getRound();
|
||||
for (final Block block : blocks.keySet())
|
||||
{
|
||||
if (block.getType() != Material.AIR && !block.getType().name().toLowerCase().contains("step"))
|
||||
|
||||
//Edited by TheMineBench, to keep the two-half-slabs from burning
|
||||
if (block.getType() != Material.AIR && !block.getType().name().toLowerCase().contains("step") || block.getType().name().toLowerCase().contains("double"))
|
||||
continue;
|
||||
|
||||
if (!UtilBlock.solid(block.getRelative(BlockFace.DOWN)))
|
||||
|
@ -16,13 +16,16 @@ import org.bukkit.craftbukkit.v1_7_R4.entity.CraftArrow;
|
||||
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer;
|
||||
import org.bukkit.entity.Arrow;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.event.block.BlockEvent;
|
||||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
||||
import org.bukkit.event.entity.EntityShootBowEvent;
|
||||
import org.bukkit.event.entity.ItemSpawnEvent;
|
||||
import org.bukkit.event.entity.PlayerDeathEvent;
|
||||
import org.bukkit.event.entity.ProjectileHitEvent;
|
||||
|
||||
@ -112,7 +115,6 @@ public class TurfForts extends TeamGame
|
||||
|
||||
new Kit[]
|
||||
{
|
||||
|
||||
new KitMarksman(manager),
|
||||
new KitInfiltrator(manager),
|
||||
new KitShredder(manager),
|
||||
@ -124,7 +126,6 @@ public class TurfForts extends TeamGame
|
||||
"",
|
||||
"Each kill advances your turf forwards.",
|
||||
"Take over all the turf to win!"
|
||||
|
||||
});
|
||||
|
||||
this.StrictAntiHack = true;
|
||||
@ -268,7 +269,7 @@ public class TurfForts extends TeamGame
|
||||
EndCheck();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@EventHandler
|
||||
public void BowCancel(EntityShootBowEvent event)
|
||||
{
|
||||
@ -280,12 +281,13 @@ public class TurfForts extends TeamGame
|
||||
((Player) event.getEntity()).updateInventory();
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void BlockPlace(BlockPlaceEvent event)
|
||||
{
|
||||
if (event.isCancelled())
|
||||
return;
|
||||
//Remoeved and replaced by ignoreCancelled = true
|
||||
//if (event.isCancelled())
|
||||
// return;
|
||||
|
||||
GameTeam team = GetTeam(event.getPlayer());
|
||||
if (team == null)
|
||||
@ -324,6 +326,7 @@ public class TurfForts extends TeamGame
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@ -331,7 +334,7 @@ public class TurfForts extends TeamGame
|
||||
{
|
||||
if (event.getEntity().getShooter() == null)
|
||||
return;
|
||||
|
||||
|
||||
if (!(event.getEntity() instanceof Arrow))
|
||||
return;
|
||||
|
||||
@ -347,6 +350,7 @@ public class TurfForts extends TeamGame
|
||||
|
||||
Manager.getPlugin().getServer().getScheduler().scheduleSyncDelayedTask(Manager.getPlugin(), new Runnable()
|
||||
{
|
||||
|
||||
public void run()
|
||||
{
|
||||
try
|
||||
@ -366,21 +370,22 @@ public class TurfForts extends TeamGame
|
||||
int z = fieldZ.getInt(entityArrow);
|
||||
|
||||
Block block = arrow.getWorld().getBlockAt(x, y, z);
|
||||
|
||||
|
||||
if (block.getTypeId() == 35)
|
||||
{
|
||||
if (block.getData() == 14 && team.GetColor() != ChatColor.RED)
|
||||
if (block.getData() == 14 /* && team.GetColor() != ChatColor.RED */)
|
||||
{
|
||||
block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, Material.REDSTONE_BLOCK.getId());
|
||||
}
|
||||
else if (block.getData() == 3 && team.GetColor() != ChatColor.AQUA)
|
||||
else if (block.getData() == 3 /* && team.GetColor() != ChatColor.AQUA */)
|
||||
{
|
||||
block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, Material.LAPIS_BLOCK.getId());
|
||||
}
|
||||
|
||||
|
||||
Bukkit.getPluginManager().callEvent(new ShredBlockEvent(block, arrow));
|
||||
|
||||
block.breakNaturally();
|
||||
|
||||
|
||||
block.setType(Material.AIR);
|
||||
}
|
||||
|
||||
arrow.remove();
|
||||
@ -655,7 +660,8 @@ public class TurfForts extends TeamGame
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
@EventHandler
|
||||
public void ItemRemoval(UpdateEvent event)
|
||||
{
|
||||
@ -674,7 +680,37 @@ public class TurfForts extends TeamGame
|
||||
ent.remove();
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
//Added by TheMineBench.
|
||||
@EventHandler
|
||||
public void blockBreak(BlockBreakEvent event) {
|
||||
|
||||
Block block = event.getBlock();
|
||||
|
||||
GameTeam team = GetTeam(event.getPlayer());
|
||||
GameTeam otherTeam = GetOtherTeam(team);
|
||||
|
||||
if (block.getType().equals(Material.WOOL) && (block.getData() == 14 && team.GetColor() != ChatColor.RED) || (block.getData() == 3 && team.GetColor() != ChatColor.AQUA))
|
||||
{
|
||||
UtilPlayer.message(event.getPlayer(), F.main("Game", "You cannot break the " + F.elem(otherTeam.GetColor() + otherTeam.GetName()) + " team's blocks!"));
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public GameTeam GetOtherTeam(GameTeam team) {
|
||||
return team.GetColor() == ChatColor.RED ? GetTeam(ChatColor.AQUA) : GetTeam(ChatColor.RED);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onItem(ItemSpawnEvent e) {
|
||||
if (e.getEntityType().equals(EntityType.DROPPED_ITEM)) {
|
||||
e.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void EndCheck()
|
||||
{
|
||||
@ -704,7 +740,7 @@ public class TurfForts extends TeamGame
|
||||
if (player.isOnline())
|
||||
AddGems(player, 10, "Participation", false, false);
|
||||
}
|
||||
|
||||
|
||||
//End
|
||||
SetState(GameState.End);
|
||||
}
|
||||
|
@ -32,6 +32,7 @@ import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.event.inventory.InventoryType;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.event.player.PlayerVelocityEvent;
|
||||
import org.bukkit.event.weather.WeatherChangeEvent;
|
||||
import org.bukkit.scoreboard.DisplaySlot;
|
||||
import org.bukkit.scoreboard.Objective;
|
||||
import org.bukkit.scoreboard.Scoreboard;
|
||||
@ -121,7 +122,12 @@ public class GameLobbyManager implements Listener, IPacketHandler
|
||||
packetHandler.addPacketHandler(this);
|
||||
|
||||
World world = UtilWorld.getWorld("world");
|
||||
|
||||
|
||||
world.setTime(6000);
|
||||
world.setStorm(false);
|
||||
world.setThundering(false);
|
||||
world.setGameRuleValue("doDaylightCycle", "false");
|
||||
|
||||
spawn = new Location(world, 0, 104, 0);
|
||||
|
||||
_gameText = new Location(world, 0, 130, 50);
|
||||
@ -752,9 +758,9 @@ public class GameLobbyManager implements Listener, IPacketHandler
|
||||
{
|
||||
if (event.getType() == UpdateType.FAST)
|
||||
{
|
||||
spawn.getWorld().setTime(6000);
|
||||
spawn.getWorld().setStorm(false);
|
||||
spawn.getWorld().setThundering(false);
|
||||
//spawn.getWorld().setTime(6000);
|
||||
//spawn.getWorld().setStorm(false);
|
||||
//spawn.getWorld().setThundering(false);
|
||||
}
|
||||
|
||||
|
||||
@ -770,7 +776,16 @@ public class GameLobbyManager implements Listener, IPacketHandler
|
||||
ScoreboardDisplay(event);
|
||||
ScoreboardSet(event);
|
||||
}
|
||||
|
||||
|
||||
@EventHandler
|
||||
public void onWeather(WeatherChangeEvent event) {
|
||||
|
||||
if (!event.getWorld().equals(spawn.getWorld()))
|
||||
return;
|
||||
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
private void RemoveInvalidEnts(GameStateChangeEvent event)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user