Terrible horrible workaround for R2 behavior

This commit is contained in:
NuclearW 2012-01-30 10:09:45 -05:00
parent 3552b756e0
commit f3283de8dd
4 changed files with 69 additions and 5 deletions

View File

@ -73,13 +73,18 @@ public class mcBlockListener implements Listener
} }
//Check if the blocks placed should be monitored so they do not give out XP in the future //Check if the blocks placed should be monitored so they do not give out XP in the future
if(m.shouldBeWatched(block)) if(m.shouldBeWatched(event.getItemInHand().getTypeId())) // Modified for terrible hack for R2 issue
{ {
if(block.getTypeId() != 17 && block.getTypeId() != 39 && block.getTypeId() != 40 && block.getTypeId() != 91 && block.getTypeId() != 86) if(block.getTypeId() != 17 && block.getTypeId() != 39 && block.getTypeId() != 40 && block.getTypeId() != 91 && block.getTypeId() != 86) {
block.setData((byte) 5); //Change the byte //block.setData((byte) 5); //Change the byte
else if(block.getTypeId() == 17 || block.getTypeId() == 39 || block.getTypeId() == 40 || block.getTypeId() == 91 || block.getTypeId() == 86) //The following is a method to get around a breakage in 1.1-R2,
//it should be removed as soon as functionality to change a block
//in this event returns.
plugin.changeQueue.push(block);
} else if(block.getTypeId() == 17 || block.getTypeId() == 39 || block.getTypeId() == 40 || block.getTypeId() == 91 || block.getTypeId() == 86) {
plugin.misc.blockWatchList.add(block); plugin.misc.blockWatchList.add(block);
} }
}
if(block.getTypeId() == 42 && LoadProperties.anvilmessages) if(block.getTypeId() == 42 && LoadProperties.anvilmessages)
{ {

View File

@ -89,6 +89,9 @@ public class m
public static boolean shouldBeWatched(Block block) public static boolean shouldBeWatched(Block block)
{ {
int id = block.getTypeId(); int id = block.getTypeId();
return shouldBeWatched(id);
}
public static boolean shouldBeWatched(int id) {
return id == 103 || id == 82 || id == 16 || id == 73 || id == 49 || id == 81 || id == 83 || id == 86 || id == 91 || id == 1 || id == 17 || id == 42 || id == 87 || id == 89 || id == 2 || id == 3 || id == 12 || id == 13 || id == 21 || id == 15 || id == 14 || id == 56 || id == 38 || id == 37 || id == 39 || id == 40 || id == 24; return id == 103 || id == 82 || id == 16 || id == 73 || id == 49 || id == 81 || id == 83 || id == 86 || id == 91 || id == 1 || id == 17 || id == 42 || id == 87 || id == 89 || id == 2 || id == 3 || id == 12 || id == 13 || id == 21 || id == 15 || id == 14 || id == 56 || id == 38 || id == 37 || id == 39 || id == 40 || id == 24;
} }

View File

@ -24,7 +24,7 @@ import com.gmail.nossr50.commands.mc.*;
import com.gmail.nossr50.commands.party.*; import com.gmail.nossr50.commands.party.*;
import com.gmail.nossr50.commands.general.*; import com.gmail.nossr50.commands.general.*;
import com.gmail.nossr50.config.*; import com.gmail.nossr50.config.*;
import com.gmail.nossr50.runnables.mcTimer; import com.gmail.nossr50.runnables.*;
import com.gmail.nossr50.spout.SpoutStuff; import com.gmail.nossr50.spout.SpoutStuff;
import com.gmail.nossr50.listeners.mcBlockListener; import com.gmail.nossr50.listeners.mcBlockListener;
import com.gmail.nossr50.listeners.mcEntityListener; import com.gmail.nossr50.listeners.mcEntityListener;
@ -35,6 +35,7 @@ import com.gmail.nossr50.skills.*;
import com.nijikokun.bukkit.Permissions.Permissions; import com.nijikokun.bukkit.Permissions.Permissions;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import java.io.BufferedInputStream; import java.io.BufferedInputStream;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.BufferedWriter; import java.io.BufferedWriter;
@ -44,6 +45,7 @@ import java.io.FileNotFoundException;
import java.io.FileReader; import java.io.FileReader;
import java.io.FileWriter; import java.io.FileWriter;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayDeque;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.logging.Level; import java.util.logging.Level;
@ -52,6 +54,7 @@ import java.util.logging.Logger;
import org.bukkit.plugin.PluginDescriptionFile; import org.bukkit.plugin.PluginDescriptionFile;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.plugin.PluginManager; import org.bukkit.plugin.PluginManager;
import org.bukkit.block.Block;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.getspout.spoutapi.SpoutManager; import org.getspout.spoutapi.SpoutManager;
import org.getspout.spoutapi.player.FileManager; import org.getspout.spoutapi.player.FileManager;
@ -84,6 +87,7 @@ public class mcMMO extends JavaPlugin
private Permissions permissions; private Permissions permissions;
private Runnable mcMMO_Timer = new mcTimer(this); //BLEED AND REGENERATION private Runnable mcMMO_Timer = new mcTimer(this); //BLEED AND REGENERATION
private Runnable ChangeDataValueTimer = new ChangeDataValueTimer(this); //R2 block place workaround
//private Timer mcMMO_SpellTimer = new Timer(true); //private Timer mcMMO_SpellTimer = new Timer(true);
//Alias - Command //Alias - Command
@ -97,6 +101,9 @@ public class mcMMO extends JavaPlugin
//Jar stuff //Jar stuff
public static File mcmmo; public static File mcmmo;
//Queue for block data change for R2 workaround
public ArrayDeque<Block> changeQueue = new ArrayDeque<Block>();
public void onEnable() public void onEnable()
{ {
mcmmo = this.getFile(); mcmmo = this.getFile();
@ -157,6 +164,8 @@ public class mcMMO extends JavaPlugin
System.out.println(pdfFile.getName() + " version " + pdfFile.getVersion() + " is enabled!" ); System.out.println(pdfFile.getName() + " version " + pdfFile.getVersion() + " is enabled!" );
Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(this, mcMMO_Timer, 0, 20); Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(this, mcMMO_Timer, 0, 20);
//R2 block place workaround
Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(this, ChangeDataValueTimer, 0, 10);
registerCommands(); registerCommands();

View File

@ -0,0 +1,47 @@
/*
This file is part of mcMMO.
mcMMO is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
mcMMO is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with mcMMO. If not, see <http://www.gnu.org/licenses/>.
*/
package com.gmail.nossr50.runnables;
import org.bukkit.block.Block;
import com.gmail.nossr50.mcMMO;
/*
* This file was created for a breakage introduced in 1.1-R2
* It should be removed afterwards if the breakage is removed.
*/
public class ChangeDataValueTimer implements Runnable {
private mcMMO plugin;
public ChangeDataValueTimer(mcMMO instance) {
this.plugin = instance;
}
public void run() {
int size = plugin.changeQueue.size();
if(size == 0) return;
if(size > 25) {
size = (int) Math.floor(size / 10);
}
for(int i = 0; i < size; i++) {
Block change = plugin.changeQueue.poll();
if(change == null) continue;
change.setData((byte) 5);
}
}
}