realtime and the superior sword

This commit is contained in:
Super_ 2020-01-12 09:51:29 -05:00
parent 93a9885477
commit 939e0730fd
12 changed files with 368 additions and 104 deletions

View File

@ -47,80 +47,42 @@
<orderEntry type="library" scope="PROVIDED" name="Maven: org.json:json:20160810" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.coreprotect:coreprotect:2.15.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.bukkit:bukkit:1.13-R0.1-SNAPSHOT" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.ow2.asm:asm:7.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.ow2.asm:asm-commons:7.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.ow2.asm:asm-tree:7.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.ow2.asm:asm-analysis:7.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.projectlombok:lombok:1.18.0" level="project" />
<orderEntry type="library" name="Maven: commons-io:commons-io:2.6" level="project" />
<orderEntry type="library" name="Maven: org.apache.commons:commons-lang3:3.9" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.spigotmc:spigot:1.15-R0.1-SNAPSHOT" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.github.Pravian:Aero:5f82926" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.spigotmc:spigot-api:1.12-R0.1-SNAPSHOT" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: commons-lang:commons-lang:2.6" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.googlecode.json-simple:json-simple:1.1.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: junit:junit:4.10" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.hamcrest:hamcrest-core:1.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.google.guava:guava:21.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.google.code.gson:gson:2.8.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.yaml:snakeyaml:1.18" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.md-5:bungeecord-chat:1.12-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: org.spigotmc:spigot-api:1.12-R0.1-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: commons-lang:commons-lang:2.6" level="project" />
<orderEntry type="library" name="Maven: com.googlecode.json-simple:json-simple:1.1.1" level="project" />
<orderEntry type="library" name="Maven: junit:junit:4.10" level="project" />
<orderEntry type="library" name="Maven: org.hamcrest:hamcrest-core:1.1" level="project" />
<orderEntry type="library" name="Maven: com.google.guava:guava:21.0" level="project" />
<orderEntry type="library" name="Maven: com.google.code.gson:gson:2.8.0" level="project" />
<orderEntry type="library" name="Maven: org.yaml:snakeyaml:1.18" level="project" />
<orderEntry type="library" name="Maven: net.md-5:bungeecord-chat:1.12-SNAPSHOT" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.github.TotalFreedom:BukkitTelnet:4.5-pre1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.apache.logging.log4j:log4j-core:2.5" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.apache.logging.log4j:log4j-api:2.5" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.github.TFPatches:TF-LibsDisguises:11aea9b3cd" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.comphenix.protocol:ProtocolLib:4.5.1-SNAPSHOT" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: cglib:cglib-nodep:3.2.5" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.comphenix.executors:BukkitExecutors:1.1-SNAPSHOT" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.github.TFPatches:TF-WorldEdit:fd3f56f015" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.github.TFPatches.TF-WorldEdit:ap:fd3f56f015" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.github.TFPatches.TF-WorldEdit:bukkit:fd3f56f015" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.github.TFPatches.TF-WorldEdit:core:fd3f56f015" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.github.TFPatches.TF-WorldEdit:worldedit-bukkit:fd3f56f015" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.apache.logging.log4j:log4j-slf4j-impl:2.8.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.bstats:bstats-bukkit:1.5" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.github.TFPatches.TF-WorldEdit:worldedit-core:fd3f56f015" level="project" />
<orderEntry type="library" name="Maven: com.github.TFPatches:TF-LibsDisguises:11aea9b3cd" level="project" />
<orderEntry type="library" name="Maven: com.comphenix.protocol:ProtocolLib:4.5.1-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: cglib:cglib-nodep:3.2.5" level="project" />
<orderEntry type="library" name="Maven: com.comphenix.executors:BukkitExecutors:1.1-SNAPSHOT" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.github.TFPatches:TotalFreedomMod:4a91c81" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.github.TFPatches:TF-WorldEdit:0909dc1972" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.github.TFPatches.TF-WorldEdit:worldedit-bukkit:0909dc1972" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.sk89q:dummypermscompat:1.8" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.bstats:bstats-bukkit:1.4" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.github.TFPatches.TF-WorldEdit:worldedit-core:0909dc1972" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: de.schlichtherle:truezip:6.8.3" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truevfs:truevfs-profile-default_2.13:0.12.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.scala-lang:scala-library:2.13.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truevfs:truevfs-driver-http:0.12.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truevfs:truevfs-kernel-spec:0.12.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truecommons:truecommons-annotations:2.5.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.google.code.findbugs:annotations:3.0.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truecommons:truecommons-cio:2.5.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truecommons:truecommons-io:2.5.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truecommons:truecommons-services:2.5.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truecommons:truecommons-logging:2.5.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: javax.inject:javax.inject:1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.apache.httpcomponents:httpclient:4.5.10" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.apache.httpcomponents:httpcore:4.4.12" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: commons-codec:commons-codec:1.11" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.slf4j:jcl-over-slf4j:1.7.28" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truevfs:truevfs-driver-odf:0.12.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truevfs:truevfs-comp-zipdriver:0.12.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truevfs:truevfs-comp-zip:0.12.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.bouncycastle:bcprov-jdk15on:1.63" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truevfs:truevfs-driver-tar:0.12.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truevfs:truevfs-comp-tardriver:0.12.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.apache.commons:commons-compress:1.19" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truevfs:truevfs-driver-tar-bzip2:0.12.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truevfs:truevfs-driver-tar-gzip:0.12.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truevfs:truevfs-driver-tar-xz:0.12.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.tukaani:xz:1.8" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truevfs:truevfs-driver-zip-raes:0.12.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truevfs:truevfs-profile-base_2.13:0.12.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truevfs:truevfs-access-swing:0.12.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truevfs:truevfs-access:0.12.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truevfs:truevfs-driver-file:0.12.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truevfs:truevfs-driver-jar:0.12.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truevfs:truevfs-driver-zip:0.12.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truevfs:truevfs-comp-ibm437:0.12.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truevfs:truevfs-kernel-impl_2.13:0.12.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truecommons:truecommons-key-console:2.5.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truecommons:truecommons-key-default:2.5.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truecommons:truecommons-key-swing:2.5.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truecommons:truecommons-key-macosx:2.5.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truecommons:truecommons-key-spec:2.5.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truecommons:truecommons-shed:2.5.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.mozilla:rhino:1.7.11" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: it.unimi.dsi:fastutil:8.2.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.antlr:antlr4-runtime:4.7.2" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: rhino:js:1.7R2" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.sk89q:jchronic:0.2.4a" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.thoughtworks.paranamer:paranamer:2.6" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.sk89q.lib:jlibnoise:1.0.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.ess3:EssentialsX:2.16.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: io.papermc:paperlib:1.0.2" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.ess3:NMSProvider:2.16.1" level="project" />
@ -150,18 +112,16 @@
<orderEntry type="library" scope="PROVIDED" name="Maven: com.sk89q.worldedit:worldedit-bukkit:7.0.0-SNAPSHOT" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.sk89q.worldedit:worldedit-core:7.0.0-SNAPSHOT" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.sk89q.worldedit.worldedit-libs:core:7.0.0-SNAPSHOT" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: rhino:js:1.7R2" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.sk89q.worldedit.worldedit-libs:bukkit:7.0.0-SNAPSHOT" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.github.TFPatches:TF-WorldGuard:bb12813214" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.github.TFPatches.TF-WorldGuard:core:bb12813214" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.github.TFPatches.TF-WorldGuard:worldguard-bukkit:bb12813214" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.sk89q:commandbook:2.3" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.github.TFPatches.TF-WorldGuard:worldguard-core:bb12813214" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.destroystokyo.paper:paper-api:1.15-R0.1-SNAPSHOT" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.ow2.asm:asm:7.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.ow2.asm:asm-commons:7.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.ow2.asm:asm-tree:7.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.ow2.asm:asm-analysis:7.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.apache.logging.log4j:log4j-slf4j-impl:2.8.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.github.TFPatches:TF-WorldGuard:50fd4cb470" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.github.TFPatches.TF-WorldGuard:worldguard-core:50fd4cb470" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.sk89q.intake:intake:4.2-SNAPSHOT" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.sk89q:squirrelid:0.2.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.flywaydb:flyway-core:3.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.khelekore:prtree:1.5.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.sf.opencsv:opencsv:2.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.github.TFPatches.TF-WorldGuard:worldguard-legacy:50fd4cb470" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.sk89q:commandbook:2.3" level="project" />
</component>
</module>

View File

@ -43,7 +43,8 @@ public class AntiNuke extends FreedomService
if (fPlayer.incrementAndGetBlockDestroyCount() > ConfigEntry.NUKE_MONITOR_COUNT_BREAK.getInteger())
{
FUtil.bcastMsg(player.getName() + " is breaking blocks too fast!", ChatColor.RED);
plugin.ae.autoEject(player, "You are breaking blocks too fast. Nukers are not permitted on this server.");
//plugin.ae.autoEject(player, "You are breaking blocks too fast. Nukers are not permitted on this server.");
player.kickPlayer(ChatColor.RED + "You are breaking blocks too fast. Nukers are not permitted on this server.");
fPlayer.resetBlockDestroyCount();
@ -66,7 +67,8 @@ public class AntiNuke extends FreedomService
if (fPlayer.incrementAndGetBlockPlaceCount() > ConfigEntry.NUKE_MONITOR_COUNT_PLACE.getInteger())
{
FUtil.bcastMsg(player.getName() + " is placing blocks too fast!", ChatColor.RED);
plugin.ae.autoEject(player, "You are placing blocks too fast.");
//plugin.ae.autoEject(player, "You are placing blocks too fast.");
player.kickPlayer(ChatColor.RED + "You are placing blocks too fast.");
fPlayer.resetBlockPlaceCount();

View File

@ -34,6 +34,7 @@ import me.totalfreedom.totalfreedommod.fun.Jumppads;
import me.totalfreedom.totalfreedommod.fun.Landminer;
import me.totalfreedom.totalfreedommod.fun.MP44;
import me.totalfreedom.totalfreedommod.fun.MobStacker;
import me.totalfreedom.totalfreedommod.fun.RealTimer;
import me.totalfreedom.totalfreedommod.fun.Trailer;
import me.totalfreedom.totalfreedommod.httpd.HTTPDaemon;
import me.totalfreedom.totalfreedommod.masterbuilder.MasterBuilder;
@ -127,6 +128,7 @@ public class TotalFreedomMod extends AeroPlugin<TotalFreedomMod>
public SignBlocker snp;
public PlayerVerification pv;
public EntityWiper ew;
public RealTimer rt;
//public HubWorldRestrictions hwr;
//
// Bridges
@ -240,6 +242,7 @@ public class TotalFreedomMod extends AeroPlugin<TotalFreedomMod>
mp = services.registerService(MP44.class);
jp = services.registerService(Jumppads.class);
tr = services.registerService(Trailer.class);
rt = services.registerService(RealTimer.class);
// HTTPD
hd = services.registerService(HTTPDaemon.class);

View File

@ -1,16 +1,18 @@
package me.totalfreedom.totalfreedommod.blocking;
import java.util.List;
import me.totalfreedom.totalfreedommod.FreedomService;
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
import me.totalfreedom.totalfreedommod.util.FLog;
import me.totalfreedom.totalfreedommod.util.FUtil;
import me.totalfreedom.totalfreedommod.util.Groups;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.block.Banner;
import org.bukkit.block.Block;
import org.bukkit.block.Chest;
import org.bukkit.block.ShulkerBox;
import org.bukkit.block.Skull;
import org.bukkit.block.banner.Pattern;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
@ -177,5 +179,19 @@ public class BlockBlocker extends FreedomService
}
}
if (Groups.BANNERS.contains(event.getBlockPlaced().getType()))
{
Banner banner = (Banner) event.getBlockPlaced().getState();
List<Pattern> patterns = banner.getPatterns();
Banner handBanner = (Banner) (((Block) event.getItemInHand()).getState());
List<Pattern> handPatterns = banner.getPatterns();
if (patterns.size() >= 2)
{
banner.setPatterns(patterns.subList(0, 2));
handBanner.setPatterns(handPatterns.subList(0, 2));
player.sendMessage(ChatColor.GRAY + "Your banner had too many patterns on it, so some were removed.");
}
}
}
}

View File

@ -19,6 +19,8 @@ import org.bukkit.Location;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.util.Vector;
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH, blockHostConsole = true)
@CommandParameters(description = "Bans a player", usage = "/<command> <username> [reason] [-nrb]", aliases = "ban")
@ -82,6 +84,7 @@ public class Command_gtfo extends FreedomCommand
String reason = null;
Boolean cancelRollback = false;
Boolean epicFail = false;
if (args.length >= 2)
{
if (args[args.length - 1].equalsIgnoreCase("-nrb"))
@ -92,6 +95,14 @@ public class Command_gtfo extends FreedomCommand
reason = StringUtils.join(ArrayUtils.subarray(args, 1, args.length - 1), " ");
}
}
if (args[args.length - 1].equalsIgnoreCase("-ef"))
{
epicFail = true;
if (args.length >= 3)
{
reason = StringUtils.join(ArrayUtils.subarray(args, 1, args.length - 1), " ");
}
}
else
{
reason = StringUtils.join(ArrayUtils.subarray(args, 1, args.length), " ");
@ -121,6 +132,26 @@ public class Command_gtfo extends FreedomCommand
}
}
if (epicFail)
{
for (int i = 0; i < 25; i++)
{
player.setVelocity(player.getVelocity().clone().add(new Vector(0, 50, 0)));
new BukkitRunnable()
{
public void run()
{
for (int i = 0; i < 8; i++)
{
player.getWorld().strikeLightning(player.getLocation());
//FUtil.
}
}
}.runTaskLater(plugin, 2L * 20L);
}
return true;
}
if (player != null)
{
FUtil.bcastMsg(player.getName() + " has been a VERY naughty, naughty boy.", ChatColor.RED);

View File

@ -0,0 +1,64 @@
package me.totalfreedom.totalfreedommod.command;
import me.totalfreedom.totalfreedommod.playerverification.VPlayer;
import me.totalfreedom.totalfreedommod.rank.Rank;
import me.totalfreedom.totalfreedommod.util.FUtil;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = Rank.OP, source = SourceType.ONLY_IN_GAME)
@CommandParameters(description = "Sync your time up with the real world time.", usage = "/<command> <on <utc_offset> | off>", aliases = "rt")
public class Command_realtime extends FreedomCommand
{
@Override
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
VPlayer player = plugin.pv.getVerificationPlayer(playerSender);
if (args.length == 0 || args.length > 2)
{
return false;
}
if (args.length == 2)
{
if (args[0].equalsIgnoreCase("on"))
{
int tz;
try
{
tz = Integer.parseInt(args[1]);
}
catch (NumberFormatException ex)
{
msg("Invalid UTC offset.");
return true;
}
if (FUtil.timeZoneOutOfBounds(tz))
{
msg("Invalid UTC offset.");
return true;
}
player.setUtcOffset(tz);
player.setRealTime(true);
plugin.rt.enable(playerSender);
plugin.pv.save();
msg("Your in-game time is now synced with real time.");
return true;
}
}
if (args[0].equalsIgnoreCase("off"))
{
if (!player.isRealTime())
{
msg("You aren't on real time.");
return true;
}
player.setRealTime(false);
msg("Your in-game time is no longer synced with real time.");
plugin.rt.disable(playerSender);
plugin.pv.save();
return true;
}
return true;
}
}

View File

@ -6,7 +6,6 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.TimerTask;
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
import me.totalfreedom.totalfreedommod.rank.Rank;
import me.totalfreedom.totalfreedommod.shop.ShopData;
@ -19,6 +18,7 @@ import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.scheduler.BukkitRunnable;
@CommandPermissions(level = Rank.OP, source = SourceType.ONLY_IN_GAME)
@CommandParameters(description = "Access the shop", usage = "/<command> <buy <item> | action | list>")
@ -57,7 +57,7 @@ public class Command_shop extends FreedomCommand
sd.setCoins(sd.getCoins() + 100);
plugin.sh.save(sd);
msg(prefix + ChatColor.GREEN + "You received your 100 coins!");
cooldown(86400, args[0]);
cooldown(86400, sender, args[0]);
return true;
}
case "search":
@ -67,7 +67,7 @@ public class Command_shop extends FreedomCommand
sd.setCoins(sd.getCoins() + amount);
plugin.sh.save(sd);
msg(prefix + ChatColor.AQUA + location + ChatColor.GREEN + " - Found " + ChatColor.RED + amount + ChatColor.GREEN + " coins!");
cooldown(30, args[0]);
cooldown(30, sender, args[0]);
return true;
}
case "list":
@ -80,11 +80,16 @@ public class Command_shop extends FreedomCommand
}
return true;
}
default:
{
return false;
}
}
Player player = getPlayer(args[0]);
if (player == null)
{
msg(PLAYER_NOT_FOUND);
return true;
}
ShopData psd = plugin.sh.getData(player);
msg(prefix + ChatColor.AQUA + player.getName() + ChatColor.GREEN + "'s balance: " + ChatColor.RED + psd.getCoins());
return true;
}
if (args.length != 2)
{
@ -150,17 +155,17 @@ public class Command_shop extends FreedomCommand
}
}
private void cooldown(int seconds, String feature)
private void cooldown(int seconds, CommandSender sender, String feature)
{
featureCooldown.put(sender, feature);
FreedomCommandExecutor.timer.schedule(new TimerTask()
new BukkitRunnable()
{
@Override
public void run()
{
featureCooldown.remove(sender);
}
}, seconds * 1000);
}.runTaskLater(plugin, seconds * 20);
}
}

View File

@ -21,6 +21,8 @@ import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.entity.Arrow;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Fireball;
import org.bukkit.event.entity.ProjectileHitEvent;
import org.bukkit.Location;
import org.bukkit.Material;
@ -45,29 +47,28 @@ public class ItemFun extends FreedomService
private final Random random = new Random();
private static final String COOLDOWN_MESSAGE = ChatColor.RED + "You're on cooldown for this item.";
private static final String COOLDOWN_MESSAGE = ChatColor.RED + "You're on cooldown for this feature.";
private final Timer timer = new Timer();
private final Map<Player, Material> cooldownTracker = new HashMap<>();
private final Map<Player, String> cooldownTracker = new HashMap<>();
private final Map<Player, Float> orientationTracker = new HashMap<>();
private void cooldown(Player player, Material material, int seconds)
private void cooldown(Player player, String feature, int seconds)
{
cooldownTracker.put(player, material);
timer.schedule(new TimerTask()
cooldownTracker.put(player, feature);
new BukkitRunnable()
{
@Override
public void run()
{
cooldownTracker.remove(player);
}
}, seconds * 1000);
}.runTaskLater(plugin, seconds * 20);
}
public boolean onCooldown(Player player, Material material)
public boolean onCooldown(Player player, String feature)
{
return cooldownTracker.containsKey(player) && cooldownTracker.containsValue(material);
return cooldownTracker.containsKey(player) && cooldownTracker.containsValue(feature);
}
public ItemFun(TotalFreedomMod plugin)
@ -319,7 +320,7 @@ public class ItemFun extends FreedomService
case NETHER_STAR:
{
if (onCooldown(player, Material.NETHER_STAR))
if (onCooldown(player, "nether_star"))
{
FUtil.playerMsg(player, COOLDOWN_MESSAGE);
break;
@ -340,27 +341,66 @@ public class ItemFun extends FreedomService
{
player.getWorld().strikeLightning(targetBlock.getLocation());
}
boolean superior = FUtil.random(1, 100) == 50;
Player rplayer = FUtil.getRandomPlayer();
FUtil.bcastMsg("Thor's Star has granted " + rplayer.getName() + " an " + ChatColor.YELLOW + "Electrical Diamond Sword" + ChatColor.RED + "!", ChatColor.RED);
ShopData psd = plugin.sh.getData(rplayer);
String key = FUtil.generateKey(8);
psd.giveRawItem(key);
plugin.sh.save(psd);
FUtil.give(rplayer, Material.DIAMOND_SWORD, "&eElectrical Diamond Sword", 1, "&7RMB - Strike lightning", ChatColor.DARK_GRAY + key);
cooldown(player, Material.NETHER_STAR, 600);
if (superior)
{
for (int i = 0; i < 25; i++)
{
rplayer.getWorld().strikeLightning(rplayer.getLocation());
}
FUtil.bcastMsg("THOR'S STAR HAS GRANTED " + rplayer.getName().toUpperCase() + " A " + ChatColor.GOLD + "SUPERIOR SWORD" + ChatColor.RED + "!!!!", ChatColor.RED);
FUtil.give(rplayer, Material.GOLDEN_SWORD, "&6Superior Sword", 1, "&7RMB - Shoot fireball", ChatColor.DARK_GRAY + key);
}
else
{
FUtil.bcastMsg("Thor's Star has granted " + rplayer.getName() + " an " + ChatColor.YELLOW + "Electrical Diamond Sword" + ChatColor.RED + "!", ChatColor.RED);
FUtil.give(rplayer, Material.DIAMOND_SWORD, "&eElectrical Diamond Sword", 1, "&7RMB - Strike lightning", ChatColor.DARK_GRAY + key);
}
cooldown(player, "nether_star", 600);
break;
}
case DIAMOND_SWORD:
{
if (onCooldown(player, "eds"))
{
FUtil.playerMsg(player, COOLDOWN_MESSAGE);
break;
}
ShopData sd = plugin.sh.getData(player);
ItemStack stack = player.getInventory().getItemInMainHand();
if (sd.validate(stack, "Electrical Diamond Sword"))
{
player.getWorld().strikeLightning(player.getTargetBlock(null, 20).getLocation());
cooldown(player, "eds", 60);
}
break;
}
case GOLDEN_SWORD:
{
if (onCooldown(player, "ss"))
{
FUtil.playerMsg(player, COOLDOWN_MESSAGE);
break;
}
ShopData sd = plugin.sh.getData(player);
ItemStack stack = player.getInventory().getItemInMainHand();
if (sd.validate(stack, "Superior Sword"))
{
Entity fireball = player.getWorld().spawnEntity(player.getLocation(), EntityType.FIREBALL);
fireball.setVelocity(player.getLocation().getDirection());
cooldown(player, "ss", 60);
}
}
}
}

View File

@ -0,0 +1,71 @@
package me.totalfreedom.totalfreedommod.fun;
import java.util.HashMap;
import java.util.Map;
import me.totalfreedom.totalfreedommod.FreedomService;
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
import me.totalfreedom.totalfreedommod.playerverification.VPlayer;
import me.totalfreedom.totalfreedommod.util.FUtil;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.scheduler.BukkitTask;
public class RealTimer extends FreedomService
{
public RealTimer(TotalFreedomMod plugin)
{
super(plugin);
}
private Map<Player, BukkitTask> tasks = new HashMap<>();
@Override
protected void onStart()
{
}
@Override
protected void onStop()
{
}
@EventHandler(priority = EventPriority.MONITOR)
public void onPlayerJoin(PlayerJoinEvent event)
{
enable(event.getPlayer());
}
@EventHandler(priority = EventPriority.MONITOR)
public void onPlayerQuit(PlayerQuitEvent event)
{
disable(event.getPlayer());
}
public void enable(Player player)
{
VPlayer vPlayer = plugin.pv.getVerificationPlayer(player);
if (vPlayer.isRealTime())
{
tasks.put(player, new BukkitRunnable()
{
@Override
public void run()
{
player.setPlayerTime(FUtil.getTimeInTicks(vPlayer.getUtcOffset()), false);
}
}.runTaskTimer(plugin, 0L, 20));
}
}
public void disable(Player player)
{
if (!tasks.containsKey(player))
return;
tasks.get(player).cancel();
tasks.remove(player);
}
}

View File

@ -41,6 +41,12 @@ public class VPlayer implements ConfigLoadable, ConfigSavable, Validatable
@Getter
@Setter
private ChatColor color = null;
@Getter
@Setter
private int utcOffset = 0;
@Getter
@Setter
private boolean realTime = false;
public VPlayer(String name)
{
@ -64,6 +70,8 @@ public class VPlayer implements ConfigLoadable, ConfigSavable, Validatable
clearChatOptOut = cs.getBoolean("clearChatOptOut", false);
rideMode = cs.getString("rideMode", rideMode);
color = ChatColor.getByChar(String.valueOf(cs.get("color")));
utcOffset = cs.getInt("utcOffset", 0);
realTime = cs.getBoolean("realTime", false);
}
@Override
@ -78,6 +86,8 @@ public class VPlayer implements ConfigLoadable, ConfigSavable, Validatable
cs.set("clearChatOptOut", clearChatOptOut);
cs.set("rideMode", rideMode);
cs.set("color", color == null ? null : color.getChar());
cs.set("utcOffset", utcOffset);
cs.set("realTime", realTime);
}
public List<String> getIps()

View File

@ -100,7 +100,15 @@ public class ShopData implements ConfigLoadable, ConfigSavable, Validatable
{
for (String i : items)
{
int id = Integer.valueOf(i.substring(0, 1));
int id;
try
{
id = Integer.valueOf(i.substring(0, 1));
}
catch (NumberFormatException ex)
{
continue;
}
if (item.ordinal() == id)
{
return true;

View File

@ -18,6 +18,7 @@ import java.util.Locale;
import java.util.Map;
import java.util.Random;
import java.util.Set;
import java.util.TimeZone;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
@ -27,6 +28,7 @@ import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.OfflinePlayer;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Entity;
@ -61,6 +63,7 @@ public class FUtil
ChatColor.LIGHT_PURPLE);
private static Iterator<ChatColor> CHAT_COLOR_ITERATOR;
private static String CHARACTER_STRING = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
private static Map<Integer, String> TIMEZONE_LOOKUP = new HashMap<>();
static
{
@ -68,6 +71,24 @@ public class FUtil
{
CHAT_COLOR_NAMES.put(chatColor.name().toLowerCase().replace("_", ""), chatColor);
}
for (int i = -12; i <= 12; i++)
{
String sec = String.valueOf(i).replace("-", "");
if (i > -10 && i < 10)
{
sec = "0" + sec;
}
if (i >= 0)
{
sec = "+" + sec;
}
else
{
sec = "-" + sec;
}
TIMEZONE_LOOKUP.put(i, "GMT" + sec + ":00");
}
}
public static void cancel(BukkitTask task)
@ -529,4 +550,37 @@ public class FUtil
List<Player> players = new ArrayList<>(Bukkit.getOnlinePlayers());
return players.get(random(0, players.size() - 1));
}
// convert the current time
public static int getTimeInTicks(int tz)
{
if (timeZoneOutOfBounds(tz))
{
return -1;
}
Calendar date = Calendar.getInstance(TimeZone.getTimeZone(TIMEZONE_LOOKUP.get(tz)));
int res = 0;
for (int i = 0; i < date.get(Calendar.HOUR_OF_DAY) - 6; i++) // oh yeah i don't know why this is 6 hours ahead
{
res += 1000;
}
int addExtra = 0; // we're adding extra to account for repeating decimals
for (int i = 0; i < date.get(Calendar.MINUTE); i++)
{
res += 16;
addExtra++;
if (addExtra == 3)
{
res += 1;
addExtra = 0;
}
}
// this is the best it can be. trust me.
return res;
}
public static boolean timeZoneOutOfBounds(int tz)
{
return tz < -12 || tz > 12;
}
}