96 lines
3.7 KiB
Diff
96 lines
3.7 KiB
Diff
|
From c2216ad38d85ac06fc2a8d3c5924ca36fab14e2f Mon Sep 17 00:00:00 2001
|
||
|
From: Poweruser_rs <poweruser.rs@hotmail.com>
|
||
|
Date: Sat, 19 Dec 2015 06:59:09 +0100
|
||
|
Subject: [PATCH] Add command setviewdistance
|
||
|
|
||
|
|
||
|
diff --git a/src/main/java/net/frozenorb/command/SetViewDistanceCommand.java b/src/main/java/net/frozenorb/command/SetViewDistanceCommand.java
|
||
|
new file mode 100644
|
||
|
index 000000000..7d5be9537
|
||
|
--- /dev/null
|
||
|
+++ b/src/main/java/net/frozenorb/command/SetViewDistanceCommand.java
|
||
|
@@ -0,0 +1,53 @@
|
||
|
+package net.frozenorb.command;
|
||
|
+
|
||
|
+import org.bukkit.Bukkit;
|
||
|
+import org.bukkit.World;
|
||
|
+import org.bukkit.command.Command;
|
||
|
+import org.bukkit.command.CommandSender;
|
||
|
+import org.bukkit.craftbukkit.CraftWorld;
|
||
|
+
|
||
|
+public class SetViewDistanceCommand extends Command {
|
||
|
+
|
||
|
+ public SetViewDistanceCommand(String name) {
|
||
|
+ super(name);
|
||
|
+ this.usageMessage = "/" + name + " <world name> <view distance>";
|
||
|
+ this.description = "Adjusts a world's viewdistance";
|
||
|
+ this.setPermission( "valor.command.setviewdistance" );
|
||
|
+ }
|
||
|
+
|
||
|
+ @Override
|
||
|
+ public boolean execute(CommandSender sender, String arg1, String[] args) {
|
||
|
+ if(!testPermission(sender)) { return true; }
|
||
|
+
|
||
|
+ if(args != null && args.length == 2) {
|
||
|
+ String worldName = args[0];
|
||
|
+ String newVD = args[1];
|
||
|
+ int vd = -1;
|
||
|
+ try {
|
||
|
+ vd = Integer.parseInt(newVD);
|
||
|
+ } catch (NumberFormatException e) {
|
||
|
+ sender.sendMessage("'" + newVD + "' is not a valid integer.");
|
||
|
+ return false;
|
||
|
+ }
|
||
|
+ World world = Bukkit.getWorld(worldName);
|
||
|
+ if(world != null) {
|
||
|
+ CraftWorld craftworld = (CraftWorld) world;
|
||
|
+ int before = craftworld.getHandle().getPlayerChunkMap().getWorldViewDistance();
|
||
|
+ craftworld.getHandle().getPlayerChunkMap().a(vd);
|
||
|
+ int after = craftworld.getHandle().getPlayerChunkMap().getWorldViewDistance();
|
||
|
+ if(before != after) {
|
||
|
+ sender.sendMessage("The view distance of world '" + world.getName() + "' was set from " + before + " to " + after);
|
||
|
+ } else {
|
||
|
+ sender.sendMessage("The view distance of world '" + world.getName() + "' remained the same ( " + before + " ).");
|
||
|
+ }
|
||
|
+ } else {
|
||
|
+ sender.sendMessage("World '" + worldName + "' was not found!");
|
||
|
+ }
|
||
|
+ return true;
|
||
|
+ } else {
|
||
|
+ sender.sendMessage("[mSpigot] Command - setviewdistance: " + this.description + "\nUsage: " + this.usageMessage);
|
||
|
+ }
|
||
|
+ return false;
|
||
|
+ }
|
||
|
+
|
||
|
+}
|
||
|
diff --git a/src/main/java/net/minecraft/server/PlayerChunkMap.java b/src/main/java/net/minecraft/server/PlayerChunkMap.java
|
||
|
index 6f60cac79..4ca5fe8eb 100644
|
||
|
--- a/src/main/java/net/minecraft/server/PlayerChunkMap.java
|
||
|
+++ b/src/main/java/net/minecraft/server/PlayerChunkMap.java
|
||
|
@@ -368,4 +368,8 @@ public class PlayerChunkMap {
|
||
|
}
|
||
|
}
|
||
|
// CraftBukkit end
|
||
|
+
|
||
|
+ public int getWorldViewDistance() {
|
||
|
+ return this.g;
|
||
|
+ }
|
||
|
}
|
||
|
diff --git a/src/main/java/org/spigotmc/SpigotConfig.java b/src/main/java/org/spigotmc/SpigotConfig.java
|
||
|
index 213af4299..50f16bee4 100644
|
||
|
--- a/src/main/java/org/spigotmc/SpigotConfig.java
|
||
|
+++ b/src/main/java/org/spigotmc/SpigotConfig.java
|
||
|
@@ -416,5 +416,9 @@ public class SpigotConfig
|
||
|
private static void worldstatsCommand() {
|
||
|
commands.put( "worldstats", new net.frozenorb.command.WorldStatsCommand( "worldstats" ) );
|
||
|
}
|
||
|
+
|
||
|
+ private static void setviewdistanceCommand() {
|
||
|
+ commands.put( "setviewdistance", new net.frozenorb.command.SetViewDistanceCommand( "setviewdistance" ) );
|
||
|
+ }
|
||
|
// Poweruser end
|
||
|
}
|
||
|
--
|
||
|
2.13.3
|
||
|
|